Link to home
Start Free TrialLog in
Avatar of Lo-Tan
Lo-TanFlag for United States of America

asked on

SiteMesh decorators

I need an easy way to use separate decorators based upon the users DIRECTORY

Here is a simple example of the current web-application directory

-jsp
---admin
-----index.jsp
---client
-----index.jsp
---employee
-----index.jsp

Basicly, I have three different types of users that can log in, and I *need* a way to say that if this user is in /admin/*, to use a separate decorator.

My current decorators.xml looks like this:

<decorators defaultdir="/jsp/decorators">
  <decorator name="admin_layout" page="admin.jsp">
    <pattern>/admin/*</pattern>
  </decorator>
  <decorator name="client_layout" page="client.jsp">
    <pattern>/client/*</pattern>
  </decorator>
  <decorator name="employee_layout" page="employee.jsp">
    <pattern>/employee/*</pattern>
  </decorator>
  <decorator name="basic_layout" page="main.jsp">
    <pattern>/*</pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
  </decorator>
</decorators>

Also, there isn't just an index page, there are actually folders under each directory (like admin/managing/*) containing jsp management files... so I need every jsp in the admin directory and all of its subdirectories to be using a certain decoratory, and different decorators if im an employee, client, etc...

Please help!
Avatar of Lo-Tan
Lo-Tan
Flag of United States of America image

ASKER

And a side note, I am using Apache MyFaces, and the faces and its implementation xml looks like this:

<servlet>
  <servlet-name>Faces Servlet</servlet-name>
  <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

JSF decorator won't work in SiteMesh because FacesContext associated with current thread was destroyed when SiteMesh processes the JSF decorator in writeDecorator() method. Therefore, we have to reinitiate FacesContext before processing JSF decorators. Most of the important code is in FacesContextUtil class and only one line is added to current PageFilter. I think it's probably better to create a new filter (JSFPageFilter) for example to avoid unnecessary processing for non-JSF decorators.
This is a bug in SiteMesh and is not yet solved
Avatar of Lo-Tan

ASKER

Well is it possible to at least have multiple, separate views.

For example, I want the admin have a different navigation, that uses certain navigation rules (because I have to prepare the beans for the next page), but also I want a body to be loaded separate, but it also contains a view.

Will this be possible if I write a filter?
Avatar of Lo-Tan

ASKER

Or, actually, if there are any other layouts I can use that work fine with JSF, please let me know.  I need a solution fast.
ASKER CERTIFIED SOLUTION
Avatar of Gibu George
Gibu George
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial