Tenho as seguintes classes e jsps abaixo.
Chamo no browser http://localhost:8080/HomeWorks/mundo/boasVindas
me deparo com o form simples “Preencha Email” (codigo esta abaixo)
preencho e clico no botao submit, a logica add eh executada mas nao sou redirecioando para add.jsp
Na verdade, me parece que o objeto user nao esta sendo criado automaticamente e passado para logica add, alguem sabe me dizer pq?
classe User
[code]package br.com.homeworks.model;
import java.util.Date;
import javax.persistence.Entity;
@Entity
public class User
{
private Long id;
private String name;
private String lastName;
private String password;
private String email;
private Date creationDate;
private Date birthDate;
public User(String name, String lastName, String password, String email,Date birthDate)
{
super();
this.name = name;
this.lastName = lastName;
this.password = password;
this.email = email;
this.birthDate = birthDate;
creationDate = new Date();
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getLastName()
{
return lastName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
public Date getBirthDate()
{
return birthDate;
}
public void setBirthDate(Date birthDate)
{
this.birthDate = birthDate;
}
public Long getId()
{
return id;
}
public Date getCreationDate()
{
return creationDate;
}
}
[/code]
Preencher Email
[code]
<%@ page language=“java” contentType="text/html; charset=ISO-8859-1"
pageEncoding=“ISO-8859-1”%>
<fieldset>
<legend>Preencha Email</legend>
<label for="nome">Email:</label>
<input id="email" type="text" name="user.email"/>
<button type="submit">Enviar</button>
${string}
[/code]
[code]
package br.com.homeworks.controller;
logica teste para Preencher email
import br.com.caelum.vraptor.Resource;
import br.com.homeworks.model.User;
@Resource
public class UserController
{
public String add(User user)
{
System.out.println("alo");
return user.getEmail();
}
}
[/code]
jsp teste para receber e exibir o email preenchido
[code]
<%@ page language=“java” contentType="text/html; charset=ISO-8859-1"
pageEncoding=“ISO-8859-1”%>