Forms do not work correcty

java
forms

(Vinicius De Andrade) #1

hello.
I have developed a form in html and there is a code to catch the information that is not working.
Pessoa is “person” for portuguese.

	@Inject
		private FormFactory formularios;
	
	
		public Result salvaPessoa() {
			Pessoa pessoa = this.formularios.form(Pessoa.class).bindFromRequest().get();
			return ok("salva pessoa "+ pessoa.getNome());			
		}
	

the code above is returning null. I also did a variation that works.

	@Inject
		private FormFactory formularios;
	
		public Result salvaPessoa2() {
			DynamicForm form = this.formularios.form().bindFromRequest();
			String nomeDaPessoa = form.get("nome");
			return ok("salvou a pessoa " + nomeDaPessoa);
		}

But it is a clean code to make the first one works. What is wrong?


(Matthias Kurz) #2

Can you show us your Pessoa class?