An addition to this. Right now I am seeing the first image rendering for
every item in my list. This means that the index-currentVehicleIndex is
always 0. When I print index and currentVehicle index next to the image, it
shows that the expression before is not always true. This is again what
makes me think it is not evaluating that expression each time it renders a
row.



Toppac wrote:
> 
> Mike thanks for the reply. Yes I am using facelets and I have a custom
> function that is being called in the render section of the image tag. 
> Here is a simplified example of what I am trying to do.
> 
> <c:set var="currentVehicleIndex" value="#{sessionData.currentVehicle}"
> scope="page"/> 
> <t:dataTable var="curVehicle" rowIndexVar="index" rendered="#{!(empty
> policy.vehicles)}" value="#{policy.vehicles}" border="0" cellpadding="0"
> cellspacing="0">
>                       <t:column id="column1">
>                           <f:facet name="header">
>                               <f:verbatim>&nbsp;</f:verbatim>
>                           </f:facet>
>                               <h:graphicImage alt="Working" 
> rendered="#{(index -
> currentVehicleIndex) eq 0}" value="snapc/images/icons/working.gif" />
>                               <h:graphicImage alt="Complete"
> rendered="#{sf:isCompleteVehicle(curVehicle) and ((index -
> currentVehicleIndex) ne 0)}" value="snapc/images/icons/complete.gif" />
>                               <h:graphicImage alt="Incomplete"
> rendered="#{!sf:isCompleteVehicle(curVehicle) and ((index -
> currentVehicleIndex) ne 0)}" value="snapc/images/icons/red_arrow.gif" />      
>                   
>                         </t:column>
>                     </t:dataTable>
> 
> What I expect to see is the correct image displayed based on the rendered
> EL statements. What I end up seeing is the second image rendered for every
> item in my list. Sometimes I see 2 images rendered at the same time, when
> in reality they are mutually exclusive. It almost seems like the dataTable
> at render time is treating all the images as 1 component and either the
> first or last time it processes all the EL is the one that wins out for
> every row.
> 
> The custom function returns a boolean, false by default. The
> currentVehicleIndex is an Integer and there is custom property resolver to
> get it. Would the fact that is an Integer and not an int cause any
> problems?
> 
> Sorry to jump on this as a MyFaces problem, I am just very frustrated
> because the code looks like it should work. I've been pulling my hair out
> trying to figure out what is going on. I read the facelets wiki link you
> posted but I don't think that applies here.
> 
> 
> 
> Mike Kienenberger wrote:
>> 
>> Are you using facelets?  You talked about using JSTL tags, and as far
>> as I know these are only available with Facelets.  I also see
>> functions in there, which again  makes me think you're using facelets.
>> 
>> If you define something with the c: tags, that only happens at compile
>> time, not at render time.
>> 
>> http://wiki.java.net/bin/view/Projects/FaceletsFAQ#What_s_the_difference_between_c
>> 
>> I recommend that you greatly simplify your example, and post the exact
>> page code here the expected results, and the actual results, so we're
>> better able to help you.   What you discussed earlier and what you
>> posted didn't match up, and there's so many references to index and
>> currentItemIndex in there that it's hard for us to guess which part
>> isn't working for you.
>> 
>> I use el expressions in rendered statements inside dataTable column
>> children without problems (with facelets).
>> 
>> 
>> On 9/13/06, Toppac <[EMAIL PROTECTED]> wrote:
>>>
>>> Thanks for the response but it definately does not work. For some reason
>>> when
>>> it is rendering the dataTable, whatever the first or last evaluation of
>>> the
>>> expression is, gets applied to every instance of the image within the
>>> datatable. It seems to cache the result of the EL expression for render
>>> and
>>> then use that for all the images at render time, rather than each image
>>> having its own value. I think this is a bug with myfaces
>>>
>>>
>>>
>>> Mike Kienenberger wrote:
>>> >
>>> > 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>&nbsp;</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>&nbsp;</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>
>>> >>
>>> >>                                         &nbsp;&nbsp;|&nbsp;&nbsp;
>>> >>                                         <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.
>>> >>
>>> >>
>>> >
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/datatable-with-multiple-images-not-interpretting-rendered-attribute-tf2261743.html#a6293762
>>> Sent from the MyFaces - Users forum at Nabble.com.
>>>
>>>
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/datatable-with-multiple-images-not-interpretting-rendered-attribute-tf2261743.html#a6295918
Sent from the MyFaces - Users forum at Nabble.com.

Reply via email to