2

I have a context loader class which loads an XML file with info on which components to show or hide on a page. On the JSP pages, within the 'rendered' attribute for a subView,, I would like to make a call to ContextLoader.displayPageComponent(String pageId, String componentId) which returns a boolean. Does this work in JSF? If not, is there another way to achieve the same?

jsfQ
  • 925
  • 1
  • 8
  • 8

2 Answers2

2

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

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
1

The most direct way to do this would be have a backing bean with a method like this...

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

with

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

Drew
  • 15,158
  • 17
  • 68
  • 77
  • I am trying to externalize the page component configuration. So I don't want to go this route. – jsfQ Apr 13 '10 at 19:28