I have an arraylist with a custom object type named “StartsideElement”.
<c:forEach items="#{startsideClient.brukerelementer}" var="element" begin="0" step="1">
<div class="#{element.headerStyle}">
<div>
<table width="100%" cellpadding="0" cellspacing="0">
<tr height="25px">
<td width="5px">
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_lefttop.gif" width="5" height="5" />
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_left.gif" width="5" height="15" />
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_leftbottom.gif" width="5" height="5" />
</td>
<td background="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_bg.gif" style="width: 920px;">
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/Calendar_16x16.png" width="16" height="16" style="float:left; margin-bottom:2px;"/>
<div class="headerText" style="text-align:left; position:relative; left: 15px; margin-top:2px"><h:outputText value="#{element.tittel}" /></div>
</td>
<td width="5px">
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_righttop.gif" width="5" height="5" />
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_right.gif" width="5" height="15" />
<img src="#{facesContext.externalContext.requestContextPath}/resources/gfx/topmenu_rightbottom.gif" width="5" height="5" />
</td>
</tr>
</table>
</div>
<!-- InnholdsDIV til Kommende oppgaver -->
<div class="#{element.boxStyle}" style="clear: both;">
<div class="boxDokumenterFont">
<ui:include src="#{element.mal}" />
</div>
</div>
</div>
<!-- END CONTAINER FOR WIDGET -->
</c:forEach>
The problem here is that the loop c:foreach will loop 6 times, which is correct, but the value of element will change as i use it. The title of the box created <h:outputText value="#{element.tittel}" /> will not correnspond with the correct value. If I do: <h:outputText value="#{element.tittel element.tittel}" /> the value printed by element.tittel will not be the same both places.
Any suggestions on what to do would be great. I cannot use <ui:repeat> because the #{element.mal} contains a filename that I need to pass to ui:include and that doesn’t work with ui:repeat.
If I understand correctly, the title
<h:outputText value="#{element.tittel}" />within your custom object “StartsideElement” is changing as the jsf code iterates over your arrayList. You would like that value to remain static and not change.Why not create another attribute in your “StartsideElement” custom object that has the correct corresponding value?