I assume that you are using JSF 1.x, otherwise this question does not make sense. <f:param> in <h:commandButton> really not supported in legacy JSF 1.x, but is supported with JSF 2.0.
<f:attribute> can be used in combination with actionListener .
<h:commandButton action="connectedFilein" actionListener="#{bean.listener}"> <f:attribute name="fileId" value="#{fileRecord.fileId}" /> </h:commandButton>
from
public void listener(ActionEvent event) { this.fileId = (Long) event.getComponent().getAttributes().get("fileId"); }
(Assume this is a type of Long , which is classic for ID)
However, it is better to use JSF 1.2 introduced by <f:setPropertyActionListener> .
<h:commandButton action="connectedFilein"> <f:setPropertyActionListener target="#{bean.fileId}" value="#{fileRecord.fileId}" /> </h:commandButton>
Or, if you are already using a container that supports Servlet 3.0 / EL 2.2 (Tomcat 7, Glassfish 3, etc.), and your web.xml declared compatible with Servlet 3.0, you can simply pass it as an argument to the method.
<h:commandButton action="#{bean.show(fileRecord.fileId)}" />
from
public String show(Long fileId) { this.fileId = fileId; return "connectedFilein"; }
Unrelated to a specific issue, I highly recommend using JSF / Facelets tags instead of JSTL whenever possible.
<ui:fragment rendered="#{bean.fileId != null}"> <ui:include src="fileOut.xhtml" id="searchOutResults"/> </ui:fragment>
(A <h:panelGroup> also possible and a better approach when using JSP instead of Facelets)
Balusc
source share