Olá pessoal, gostaria de expor um problema a vcs. Esse problema é conhecido mas a solução que encontrei não resolveu, por isso escrevo aqui esse tópico.
<h:dataTable border="1" value="#{loginSistema.menuUsuario.itens}" id="tabsist" var="item">
<h:column>
<h:commandLink action="#{carregarSistema.execute}">
<f:setPropertyActionListener target="#{carregarSistema.codigo}" value="#{item.codigo}"/>
<h:outputText value="#{item.nome}"/>
</h:commandLink>
</h:column>
</h:dataTable>
Por causa do atributo var no DataTable, ocorre a seguinte exceção:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 24 in the jsp file: /jsp/sca/listasistemas.jsp
The method setVar(String) in the type DataTableTag is not applicable for the arguments (JspValueExpression)
21: </tr>
22: </c:forEach>
23: </table>
24: <h:dataTable border="1" value="#{loginSistema.menuUsuario.itens}" id="tabsist" var="item">
25: <h:column>
26: <h:commandLink action="#{carregarSistema.execute}">
27: <f:setPropertyActionListener target="#{carregarSistema.codigo}" value="#{item.codigo}"/>
Então, eu parti pra uma solução retirando o atributo var, e fiz um teste, colocando um link e implementando um actionListener, dessa forma:
<h:commandLink action="#{carregarSistema.execute}" actionListener="eventoListener">
<h:outputText value="Atualizar a página atual"></h:outputText>
</h:commandLink>
Olha o código ao actionListener:
public void eventoListener (ActionEvent event) {
Login loginAtual = (Login) this.recuperaParamSession("loginSistema");
Menu menuUsuario = (Menu) loginAtual.getMenuUsuario();
UIComponent component = event.getComponent().findComponent("tabsist");
if (component != null) {
HashMap atributos = (HashMap) component.getAttributes();
atributos.put("value", menuUsuario.getItens());
atributos.put("var", "item");
}
}
Nesse teste, quando eu clico no link de atualização da página, a listagem do DataTable aparece normalmente. Alguem sabe uma forma de resolver esse problema do DataTable sem precisar de um actionlistener? Tô usando Apache Tomcat 6.0.14, e JSF 1.2