I'm working with JSF and PrimeFaces, but I need to get the value of the id of a component. Because I'm building dinamycally panels with diferent id, to show a the panel I need to compare if is the current panel, then show it.
For example if I've the next panel
<p:outputPanel id="#{bean.getID}" autoUpdate="true" renderer=#{@this.id == bean.currentPanel} > </p:outputPanel> And Bean
public class Bean(){ private int numberPanels =0; private int currentPanel = 0; public int getID(){ //...a process that return different ID } // getter's and setters }
Obviously, @this.id doesn't work. So, how to get the value of ID of componente ne JSF with PrimeFaces?
#{bean.ID}instead of#{bean.getID}. Second, you should not have business logic in your getters methods, see here (if you still insist to place business logic in the getter, don't complain for performance problems later =\). To the question, I guess you can dynamically bind the<p:outputPanel id="#{bean.id}" binding="#{theOutputPanel}" rendered="#{theOutputPanel.id eq bean.currentPanel}">. I haven't tested this but may do what you want/need (but you should changebean.currentPaneltoString).