Bom dia, galera. Ao acionar o commandButton da minha página, ele simplesmente não executa nenhuma ação e nem envia mensagem de erro pro console… Segue o código:
Página xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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.prime.com.tr/ui">
<h:head>
<title>Cadastro de Jogos</title>
</h:head>
<h:body>
<h:form>
<p:dataTable paginator="true" rows="10" selectionMode="single"
rowsPerPageTemplate="5,10,15"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
dblClickSelect="true" value="#{partidaFace.cachedPartidas}" var="item">
<f:facet name="header">
Lista de Partidas
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="Time 1" />
</f:facet>
<h:outputText value="#{item.partidaTimesPK.time1.nome}" />
</p:column>
<p:column style="width:5%;text-align:center;">
<f:facet name="header">
<h:outputText style="" value="X" />
</f:facet>
<h:outputText value="X" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Time 2" />
</f:facet>
<h:outputText value="#{item.partidaTimesPK.time2.nome}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Data" />
</f:facet>
<h:outputText value="#{item.dataDoJogo}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Actions" />
</f:facet>
<h:commandLink action="#{partidaFace.removePartida}">
<h:graphicImage value="/icons/icon-delete.png" />
<f:setPropertyActionListener target="#{partidaFace.selectedPartida}" value="#{item}"/>
</h:commandLink>
<h:commandLink action="gotoPartida">
<h:graphicImage value="/icons/icon-edit2.png" />
<f:setPropertyActionListener target="#{partidaFace.selectedPartida}" value="#{item}"/>
</h:commandLink>
</p:column>
</p:dataTable>
<br />
<div align="center">
<p:panel style="width:50%;">
<f:facet name="header">
<h:outputText value="Selecione os Times" />
</f:facet>
<!-- Passando ID na hora de atualizar -->
<h:inputHidden value="#{partidaFace.selectedPartida.id}" />
<h:outputText value="Times:" />
<p:pickList converter="#{timeConverter}" value="#{partidaFace.times}" var="time" itemLabel="#{time.nome}" itemValue="#{time}">
<f:facet name="sourceCaption">Out</f:facet>
<f:facet name="targetCaption">In</f:facet>
</p:pickList>
<h:outputText value="Campeonato:" />
<h:selectOneMenu converter="#{campeonatoConverter}" value="#{partidaFace.selectedPartida.campeonato}">
<f:selectItems value="#{partidaFace.campeonatos}" />
</h:selectOneMenu><br />
<h:outputText value="Data do jogo:" />
<p:inputText value="#{partidaFace.selectedPartida.dataDoJogo}" /> <br />
<p:commandButton value="Salvar" action="#{partidaFace.salvaOuAtualizaPartida}" ajax="false"/>
<p:commandButton value="Cancelar" action="gotoMenu" ajax="false"/>
</p:panel>
</div>
</h:form>
<!-- <script type="text/javascript">-->
<!-- function handleTransfer {-->
<!-- item = e.item -->
<!-- fromList = e.from -->
<!-- toList = e.toList-->
<!-- -->
<!-- }-->
<!-- </script>-->
</hbody>
</html>
Controller
package br.edu.anhanguera.faces;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.faces.model.SelectItem;
import org.primefaces.model.DualListModel;
import br.edu.anhanguera.DAO.CampeonatoDAO;
import br.edu.anhanguera.DAO.JogadorDAO;
import br.edu.anhanguera.DAO.PartidaDAO;
import br.edu.anhanguera.DAO.TimeDAO;
import br.edu.anhanguera.entity.Campeonato;
import br.edu.anhanguera.entity.Partida;
import br.edu.anhanguera.entity.PartidaTimesPK;
import br.edu.anhanguera.entity.Time;
public class PartidaFace {
JogadorDAO jogadorDAO = new JogadorDAO();
CampeonatoDAO campeonatoDAO = new CampeonatoDAO();
TimeDAO timeDAO = new TimeDAO();
private DualListModel<Time> times = new DualListModel<Time>();
private List<Partida> cachedPartidas = null;
private Partida selectedPartida = new Partida();
private PartidaDAO partidaDAO = new PartidaDAO();
public List<Partida> getCachedPartidas(){
if(cachedPartidas == null){
cachedPartidas = partidaDAO.getPartidas();
}
return cachedPartidas;
}
public String salvaOuAtualizaPartida(){
partidaDAO.salvaOuAtualizaPartida(selectedPartida);
selectedPartida = new Partida();
cachedPartidas = null;
return "gotoPartidas";
}
public String removePartida(){
partidaDAO.removePartida(selectedPartida);
selectedPartida = new Partida();
cachedPartidas = null;
return "gotoPartidas";
}
// public DualListModel<SelectItem> getTimes(){
// List<SelectItem> listaDeTimes = new LinkedList<SelectItem>();
// DualListModel<SelectItem> toReturn = new DualListModel<SelectItem>();
// List<Time> times = timeDAO.getTimes();
// for(Time time : times){
// listaDeTimes.add(new SelectItem(time, time.getNome()));
// }
// toReturn.setSource(listaDeTimes);
// toReturn.setTarget(new ArrayList<SelectItem>());
// return toReturn;
// }
public List<SelectItem> getCampeonatos(){
List<SelectItem> toReturn = new LinkedList<SelectItem>();
for(Campeonato campeonato : campeonatoDAO.getCampeonatos()){
toReturn.add(new SelectItem(campeonato, campeonato.getNome()));
}
return toReturn;
}
public DualListModel<Time> getTimes() {
// DualListModel<Time> toReturn = new DualListModel<Time>();
List<Time> listaTimes = timeDAO.getTimes();
times.setSource(listaTimes);
times.setTarget(new ArrayList<Time>());
return times;
}
public void setTimes(DualListModel<Time> times) {
PartidaTimesPK partidaTimesPK = new PartidaTimesPK();
partidaTimesPK.setTime1(times.getTarget().get(0));
partidaTimesPK.setTime2(times.getTarget().get(1));
selectedPartida.setPartidaTimesPK(partidaTimesPK);
}
public Partida getSelectedPartida() {
return selectedPartida;
}
public void setSelectedPartida(Partida selectedPartida) {
this.selectedPartida = selectedPartida;
}
}
Já revisei várias vezes o código e não sei o que pode estar errado. Se alguém puder dar uma luz, agradeço. Abraço.