jsfjsf-2primefaceselrendered-attribute

Conditionally show image in JSF inside dataList


inside a iteration with primefaces dataList I want render an image conditionally like this:

<ui:param name="curTriggerState" value="#{jobListController.getTriggerState(curJobTriggerInfo)}" />
<p:column rendered="#{showCurJobTrigger}">
    <h:outputText value="#{curTriggerState}" />
    <h:graphicImage value="/resources/images/triggerstate_none_48.png" 
        rendered="#{curTriggerState eq 'NONE'}" />
    <h:graphicImage value="/resources/images/triggerstate_normal_48.png" 
        rendered="#{curTriggerState eq 'NORMAL'}" />
    <h:graphicImage value="/resources/images/triggerstate_paused_48.png" 
        rendered="#{curTriggerState eq 'PAUSED'}" />
    <h:graphicImage value="/resources/images/triggerstate_complete_32.png" 
        rendered="#{curTriggerState eq 'COMPLETE'}" />
    <h:graphicImage value="/resources/images/triggerstate_error_48.png" 
        rendered="#{curTriggerState eq 'ERROR'}" />
    <h:graphicImage value="/resources/images/triggerstate_blocked_48.png" 
        rendered="#{curTriggerState eq 'BLOCKED'}" />
</p:column>

jobListController.getTriggerState returns a string checked in the corresponding render attribute. The ouputText prints out the correct state. But no image is drawn. The paths of the images are correct if I set rendered="true" the image is drawn. Cannot find my mistake. Thought the ui:param could be the cause, but the outputText prints out the correct string.


Solution

  • This was my fault. The backend service is a mock at this time which returns the trigger state randomly. It seems that the backing bean (and therefore the backend) is not only called once per graphicImage but several times. When each calls returns a different trigger state, the image and the title can differ of course. I am a little bit suprised about that because I assign the value with a ui:param and thought the backing bean method will be called only once per graphicImage.