jsf 1.2, jboss 4.2.3 and richfaces 3.3.3
I'm trying to send the index of a as a , but it keeps returning null:
<ui:repeat id="al11" var="albumslistvalue1" value="#{AlbumDetailBean.getAlbumImagesList()}" varStatus="listimages">
<h:form>
<h:commandLink value="proxima" id="next" action="#{AlbumDetailBean.escreveparam()}">
<f:param name="fotoid" value="#{listimages}" />
</h:commandLink>
</h:form>
</ui:repeat>
the escreveparam() method only writes the param:
public void escreveparam(){
String fotoid = ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getParameter("fotoid");
System.out.println("Teste:" + fotoid);
}
Why is it always null?
You're using JSF 1.x which thus implies that you're using Facelets 1.x (as in
jsf-facelets.jarfile). The<ui:repeat>tag has in Facelets 1.x novarStatusattribute. It was been introduced in Facelets 2.0.You need to look for alternate means. E.g.
<c:forEach>(please note that your initial usage of
varStatusobject was completely wrong, it does not give you the raw index back, but a complete object holding all iteration status details, with among others agetIndex()method, you should actually have used#{listimages.index}or something instead --provided that you were using Facelets 2.x)or just the ID of the iterated
Albumobject itselfeither way, just use
<managed-property>infaces-config.xmlwith a value of#{param.id}or theExternalContext#getRequestParameterMap()to retrieve it:By the way, since your environment seems to support JBoss EL (as indicated by using full method names with parentheses in EL), you could also just pass the whole
Albumas the action method argumentwith