views:

120

answers:

1

Hi

I have an include page which is a navigation menu. When i click on those menu i want to refresh the content area of layout with a certain page. How can i pass the page name into a JSF page using include tag

I dont want to switch to facelets and also i tried using $ and calling the backing bean method. It works but no css or richfaces components renders properly.

Thanks Raj

+1  A: 

I am not sure about the RichFaces part, but you can just use EL in <jsp:include> as well.

<jsp:include page="/WEB-INF/#{bean.pagename}.jsp" />

If bean.getPagename() returns for example home, then this will include /WEB-INF/home.jsp. You also need to ensure that the JSF/HTML contents of home.jsp is wrapped by a <f:subview> with an unique ID.

As to the CSS trouble, just ensure that the generated HTML validates and that the CSS imports in the <link> tags are all valid.

BalusC
I tried this <jsp:include page="#{panelMenu.current}" />and this is what i get in browser-- The requested resource (/cdclassifieds/members/#{panelMenu.current}) is not available Please help
Rajesh
Did you declare `web.xml` to be Servlet 2.5? This sounds like as if it's Servlet 2.4. Unified EL in template text would then indeed not be parsed. I'd update the `web.xml` to comply Servlet 2.5 (if your appserver supports it). You can also use `${panelMenu.current}`, but if it's a request scoped bean which is to be created yet, then you need to ensure as well that you've called `#{panelMenu.xxx}` somewhere before the `jsp:include` line with `${}`. JSF will then create the bean if not created. The `${}` namely won't do that.
BalusC
Also see this article http://balusc.blogspot.com/2007/01/dynamic-jsf-subviews.html
BalusC
Hey Balu .. Thanks for your help .. I tried the things mentioned in the article and this is what i get in error stack java.lang.NullPointerException javax.faces.component.UIComponentBase.doPostAddProcessing(UIComponentBase.java:1691) javax.faces.component.UIComponentBase.setParent(UIComponentBase.java:403)
Rajesh