Estava implementado a alteração de usuário, porém estou preso com o seguinte erro:
There are two rules that matches the uri '/user/list' with method GET: [[FixedMethodStrategy: /user/{user.login} UserController.edit(User) ALL], [FixedMethodStrategy: /user/list UserController.list() [GET]]] with same priority. Consider using @Path priority attribute.
at br.com.caelum.vraptor.http.route.DefaultRouter.checkIfThereIsAnotherRoute(DefaultRouter.java:106)
O erro mostra que estou usando o mesmo path, porém ao meu ver são diferentes. Já tentei colocar priority daí deu outro erro.
User bean:
@Entity
public class User implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id
private String login;
private String name;
private String password;
@OneToOne(fetch=FetchType.EAGER)
@Cascade(CascadeType.REFRESH)
private TypeUser type;
private int exclusion_state = 1;
Controller
@Resource
public class UserController
{
private final UserDao dao;
private final Result result;
public UserController(UserDao dao, Result result) {
super();
this.dao = dao;
this.result = result;
}
@Get @Path("/user/list")
public List<User> list()
{
List<User> listUser = this.dao.list();
if(listUser.size() <=0)
{
this.result.use(Results.json())
.withoutRoot().from(new JsonResponse("userNoData", false))
.serialize();
}
return this.dao.list();
}
@Get @Path("/user/{user.login}")
public User edit(User user)
{
try {
user = this.dao.load(user);
return user;
} catch (OwnException e) {
return null;
}
}
@Post @Path("user/{user.login}")
public void change(User user)
{
try {
this.dao.update(user);
this.result.use(Results.json()).withoutRoot().from(new JsonResponse("userUpdate", true)).serialize();
} catch (OwnException e) {
this.result.use(Results.json()).withoutRoot()
.from(new JsonResponse("eUserUpdate", e.getMessage(),false)).serialize();
this.result.nothing();
}
}
jsp :
<c:forEach items="${userList}" var="user">
<tr>
<td>${user.name }</td>
<td>${user.login }</td>
<td>${user.type.name}</td>
<td><a href="<c:url value="/user/${user.login}"/> ">
<img alt="Editar" src="<c:url value="imgs/icons/editar.png" /> "></a></td>
<td>
<button class="buttonDelete" id="buttonDelete" url="<c:url value="/user/exclude/${user.login}"/>"></button>
</tr>
</c:forEach>
Se alguém puder me ajudar agradeço
vlw