Ola pessoal, estou com um problema por causa de uma migraçao que fiz de JSP para XHTML.
O problema é na ActionListener de Alterar e Excluir, que com o jsf funcionavam, agora naum funcionam mais...
os métodospublic String excluir(ActionEvent event) {
System.out.println("Excluindo: " + perguntas.getCod_perguntas());
UIComponent link = event.getComponent();
UIParameter param = (UIParameter) link.findComponent("excluir");
Long id = (Long) param.getValue();
Session session = HibernateUtil.currentSession();
Dao<Perguntas> perguntasDao = new Dao<Perguntas>(session,
Perguntas.class);
this.perguntas = perguntasDao.load(id);
perguntasDao.delete(this.perguntas);
this.perguntas = new Perguntas();
return "excluido";
}
public void escolhePerguntas(ActionEvent event) {
UIComponent link = event.getComponent();
UIParameter param = (UIParameter) link.findComponent("editCod");
Long id = (Long) param.getValue();
Session session = HibernateUtil.currentSession();
Dao<Perguntas> dao = new Dao<Perguntas>(session, Perguntas.class);
this.perguntas = dao.load(id);
}
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link rel="StyleSheet" type="text/css" href="/style/style.css" media="screen" />
</head>
<ui:composition template="/pages/template/template.xhtml">
<ui:define name="corpo">
<body>
<f:view>
<h:form>
<h:panelGrid>
<h:outputText value="Descrição: " />
<h:inputText value="#{perguntasHandler.perguntas.descricao}" required="true" validator="#{perguntasHandler.validaCase}">
<f:validateLength minimum="5" />
</h:inputText>
<h:outputText value="Tipo: " />
<h:inputText value="#{perguntasHandler.perguntas.tipo}" required="true" validator="#{perguntasHandler.validaCase}">
<f:validateLength minimum="2" />
</h:inputText>
<h:commandButton value="Salvar" action="#{perguntasHandler.salva}" />
<rich:spacer height="10"/>
<rich:separator height="1" lineType="dotted"/>
<rich:spacer height="10"/>
<ui:include src="listaperguntas.xhtml" />
</h:panelGrid>
</h:form>
</f:view>
</body>
</ui:define>
</ui:composition>
</html>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<f:subview id="listaperguntas">
<h:form>
<rich:dataTable value="#{perguntasHandler.listaPerguntas}" var="f" rendered="#{not empty perguntasHandler.listaPerguntas}" rows="5" id="perguntas">
<h:column>
<f:facet name="header">
<h:outputText value="Código"/>
</f:facet>
<h:outputText value="#{f.cod_perguntas}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Descrição"/>
</f:facet>
<h:outputText value="#{f.descricao}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Tipo"/>
</f:facet>
<h:outputText value="#{f.tipo}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Alterar"/>
</f:facet>
<h:commandButton value="Alterar" actionListener="#{perguntasHandler.escolhePerguntas}">
<f:param id="editCod" name="cod_perguntas" value="#{f.cod_perguntas}"/>
</h:commandButton>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Excluir"/>
</f:facet>
<h:commandButton value="Excluir" actionListener="#{perguntasHandler.excluir}" />
<f:param id="excluir" name="cod_perguntas" value="#{f.cod_perguntas}"/>
</h:column>
<f:facet name="footer">
<rich:datascroller/>
</f:facet>
</rich:dataTable>
</h:form>
</f:subview>
</body>
</html>
A diferença básica foi o include da listapergunta.xhtml na pergunta.xhtml:
era assim:
<f:include page="listaperguntas.xhtml" />
ficou assim:
<ui:include src="listaperguntas.xhtml" />
An Error Occurred:
/pages/questionario/perguntas.xhtml @41,43 <f:include> Tag Library supports namespace: http://java.sun.com/jsf/core, but no tag was defined for name: include
Eae galera, alguma sugestão??