Of the code you posted, it looks ok to me.
However, id="#{index + 'working'}" is not legal. id must be a static value.
On 9/12/06, Toppac <[EMAIL PROTECTED]> wrote:
I am trying to use a datatable to render bunch of data and display an image
next to each row rendered based on the rowIndex. My code is below. The
problem I am seeing is that inside the graphicImage tag, the index doesn't
have scope. I can print the index before and after the graphicImage, but
when used inside the rendered attribute it always rendered to empty string.
I tried to use the index as part of the id for the graphicImage, something
like id="#{index + 'working'}" and it always rendered to just "working". I
have tried just using rowIndex, tried naming the rowIndexVar something other
than index, and no luck. I am wondering how I can use the current index
inside other tags. I have also tried using JSTL tags c:if to do the
rendering and it looks like the index doesn't have scope inside there
either.
The only other thing I can think may be wrong is that that the rendered
attribute of the graphicImage is only calculated once or is calculated and
applied to all the rows. The last c:if I have in my code below does work, so
it seems to only be something with the rowIndexVar inside a dataTable.
Last thing, ignore typos in variable names, as I changed the names of the
variables to hide the real function of this code (requirement). And
currentItemIndex is a c:set var defined earlier in the page.
<t:dataTable var="curItem" rowIndexVar="index" value="#{someData.someItems}"
border="0" cellpadding="0" cellspacing="0">
<t:column id="column1">
<f:facet name="header">
<f:verbatim> </f:verbatim>
</f:facet>
#{index} and #{currentItemIndex} and
#{(index - currentItemIndex) eq 0}
<h:graphicImage alt="Working"
rendered="#{(index - currentItemIndex) eq
0}" value="snapc/images/icons/working.gif" />
<h:graphicImage alt="Complete"
rendered="#{sf:isCompleteItem(curItem)
and ((index - currentItemIndex) ne 0)}"
value="snapc/images/icons/complete.gif" />
<h:graphicImage alt="Incomplete"
rendered="#{!sf:isCompleteItem(curItem) and ((index - currentItemIndex) ne
0)}" value="snapc/images/icons/red_arrow.gif" />
</t:column>
<t:column id="column2">
<f:facet name="header">
<h:outputText value="Year" />
</f:facet>
#{curItem.currentlYear}
</t:column>
<t:column id="column3">
<f:facet name="header">
<f:verbatim> </f:verbatim>
</f:facet>
<c:if test="#{fn:length(someData.someItems) >
1}">
<h:commandLink action="edit"
type="submit"
id="edit">
#{bundle.usage_editdetails_label}
<f:param name="editIndex"
value="#{index}"/>
</h:commandLink>
|
<h:commandLink action="delete" id="delete"
>
#{bundle.usage_delete_label}
<f:param name="deleteIndex"
value="#{index}"/>
</h:commandLink>
</c:if>
</t:column>
</t:dataTable>
--
View this message in context:
http://www.nabble.com/datatable-with-multiple-images-not-interpretting-rendered-attribute-tf2261743.html#a6275415
Sent from the MyFaces - Users forum at Nabble.com.