开发者

Primefaces conditional logic within <p:dataGrid>

I have a data table which has two images per column, one that is displayed and also a hidden image that is not. The idea is to dislpay the hidden image on top of the other image if an attribute #{person.isLocked} result set is set to 'T'. My code has a div and within that div has two div's, one for the main image and then one for the image that will be overlayed. (Code below) The image that is to be overlayed has a style attribute display: none; . I need somehow to check to see if the #{person.isLocked} equals 'T', if so then I need to change the css to display:block; else leave it be.

<p:dataGrid var="person" value="myBean.people">
    <p:column>
        <h:panelGird style="margin-left:auto; margin-right:auto;">
           <div>
              <div style="position:absolute; z-index:1;">
                   <p:graphicImage value="image?id=#{person.id}" cache="false"/>
              </div>
              <div style="position:absolute; z-index:100; display: none;">
                   <p:graphicImage value="./images/lock.png" cache="true"/>
              </div>
           </div>
        </h:panelGrad>
    </p:column>
</p:dataGrid>

The only solution I have come up with is instead of storing 'T' or 'F' in the database as #{person.isLocked}, store the css attribute instead, so I would store 'block' or 'none' and then call the person attribute in the style like so.

     <div style="position:absolute: z-index:100; display: #{person.isLocked}">
         <p:graphicImage value="./images/lock.png" cache="true"/>
     </div>

This seems like a bad design though. I don't want to manipulate the data in my database j开发者_StackOverflow中文版ust for display purposes. Has anyone found a different way of doing this?


I've never used Primefaces, but you could try

<ui:fragment rendered="#{person.isLocked}">
 <!-- your div here -->
</ui fragment>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜