How do I render or hide a jsf subview based on a method call (which returns a boolean)?

I have a context loader class that loads an XML file with information about which components should be shown or hidden on the page. In JSP pages, in the "rendered" attribute for the subView, I would like to call ContextLoader.displayPageComponent (String pageId, String componentId) which returns a boolean. Does this work in JSF? If not, is there any other way to achieve the same?

+2


a source to share


2 answers


Wrap it in an EL function. How to do this depends exactly on the technology in question. You can find a JSP oriented example in this answer and a Facelets oriented example in this answer .



+2


a source


The most direct way to do it is to have bean support with a method like this ...

public boolean isRenderSubview1Comp1() {
   return ContextLoader.displayPageComponent("subview1", "comp1");
}

      



from

<h:outputText value="foo" rendered="#{MyBean.rednerSubview1Comp1}"/>

+1


a source







All Articles