简体   繁体   中英

render jsf commandLink on basis of bean value

Hi as per my requirement I have a datatable and last column is activate/deactivate. I have to create a commandLink for deactivate the row, once it get deactivated, activate commandLink should appear.To acheive this I have created two commandLink one for activate and other for deactivate.but problem is that both are appearing same time.How to restrict appearing one at a time. also I have to show these on the basis of statusId(1-active,2-deactive)

<h:commandLink id="a" rendered=#{status=1} action="#{bean.activate}"  value="Activate" />
<h:commandLink id="b" rendered=#{status=2} action="#{bean.deactivate}"  value="Deactivate" />

http://docs.oracle.com/javaee/6/tutorial/doc/bnaik.html

The correct expression would be

 <h:commandLink id="a" rendered="#{status == 1}" action="#{bean.activate}"  value="Activate" />

eq is also a valid operator. Notice also the quotes.

It would have been nicer if it was a boolean property deactivated or ( activated ), but that is more a matter of opinion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM