Boa noite pessoal,
Tenho um Segue xhtml e classe: xhtml: Bean: Obrigado pela ajuda!<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<div class="container">
<h:form id="formTournament">
<p:messages id="messages" />
<p:dataTable id="tableTournaments" paginator="true" lazy="true" rows="5"
value="#{tournamentBean.lazyModel}" var="tournament" paginatorPosition="bottom">
<p:column>
<!-- Editar -->
<p:commandLink id="signupt" actionListener="#{userBean.signUpTournament}"
update=":formTournament">
<h:graphicImage value="/web/images/icons/signup_tournament.png"/>
<f:setPropertyActionListener value="#{tournament}"
target="#{userBean.selectedTournament}" />
</p:commandLink>
</p:column>
</p:dataTable>
</h:form>
</div>
</h:body>
</html>
import java.io.IOException;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.view.ViewScoped;
import javax.persistence.PersistenceException;
import javax.servlet.http.HttpServletRequest;
import br.com.wt.business.SimpleAbstractBean;
import br.com.wt.business.exception.WTCustomException;
import br.com.wt.business.platform.PlatformManagerBeanLocal;
import br.com.wt.business.tournament.TournamentManagerBeanLocal;
import br.com.wt.dao.Tournament;
import br.com.wt.dao.User;
import br.com.wt.utils.MessageUtils;
@ManagedBean
@ViewScoped
public class UserBean extends SimpleAbstractBean {
/**
*
*/
private static final long serialVersionUID = 1L;
@EJB
private PlatformManagerBeanLocal platformController;
@EJB
private UserManagerBeanLocal userController;
@EJB
private TournamentManagerBeanLocal tournamentController;
private User user;
private int idPlatform;
private Tournament selectedTournament;
public UserBean() {
this.user = new User();
this.selectedTournament = new Tournament();
}
public void createUser(ActionEvent event) {
try {
this.userController.validateLogin(this.user.getDsLogin());
this.userController.createUser(this.user, idPlatform);
super.exibiMensagem(MessageUtils.getMessage(FacesContext
.getCurrentInstance().getViewRoot().getLocale(),
"user.create.success"));
} catch (WTCustomException e) {
super.exibiMensagemErro(e.getMessage(), e.getMessage(), e);
} catch (Exception e) {
if (e.getCause() instanceof PersistenceException) {
super.exibiMensagemErro(MessageUtils.getMessage(FacesContext
.getCurrentInstance().getViewRoot().getLocale(),
"email.duplicated"), MessageUtils.getMessage(
FacesContext.getCurrentInstance().getViewRoot()
.getLocale(), "email.duplicated"), e);
} else {
super.exibiMensagemErro(MessageUtils.getMessage(FacesContext
.getCurrentInstance().getViewRoot().getLocale(),
"msg.erro.default"), MessageUtils.getMessage(
FacesContext.getCurrentInstance().getViewRoot()
.getLocale(), "msg.erro.default"), e);
}
}
}
public void redirectNewTournament(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) context
.getExternalContext().getRequest();
try {
context.getExternalContext().redirect(
request.getContextPath() + "/tournament/newtournament.wt");
} catch (IOException e) {
super.exibiMensagemErro(
MessageUtils.getMessage(FacesContext.getCurrentInstance()
.getViewRoot().getLocale(), "msg.erro.default"), e);
}
}
public void signUpTournament(ActionEvent actionEvent) {
this.tournamentController.signUpTournament(this.selectedTournament);
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public int getIdPlatform() {
return idPlatform;
}
public void setIdPlatform(int idPlatform) {
this.idPlatform = idPlatform;
}
public Tournament getSelectedTournament() {
return selectedTournament;
}
public void setSelectedTournament(Tournament selectedTournament) {
this.selectedTournament = selectedTournament;
}
}