[jboss-dev-forums] [Design of JBoss Portal] - Accessing UserModule with MyFaces

djmacpac do-not-reply at jboss.com
Fri Nov 24 05:51:02 EST 2006


Hi,
i have a MyFaces Portlet with a managed Bean. The Portlet works fine. Now I want to access the UserModule in the managed Bean but it won't work.
The Portlet.XML looks like this:

  | <portlet id="tree_example">
  |     <portlet-name>tree_example</portlet-name>
  |     <display-name>Tree</display-name>
  |     <portlet-class>org.apache.myfaces.portlet.MyFacesGenericPortlet</portlet-class>
  |     <init-param>
  |    		<name>default-view</name>
  |   	 	<value>/tree2.jsp</value>
  | 	</init-param>
  |     <supports>
  |       <mime-type>text/html</mime-type>
  |       <portlet-mode>VIEW</portlet-mode>
  |     </supports>
  |     <supported-locale>en</supported-locale>
  |     <portlet-info>
  |       <title>Tree-Navigation</title>
  |       <short-title>The world's simplest tree</short-title>
  |     </portlet-info>
  |   </portlet>
  | 

I try to access the UserModule on this way:

  | PortletSession session = (PortletSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
  | UserModule userModule = (UserModule) session.getPortletContext().getAttribute("UserModule");
  | 			   	RoleModule roleModule = (RoleModule) session.getPortletContext().getAttribute("RoleModule");
  | 
But it seems that the UserModule is NULL (probably because of the FacesContext???)

Accessing the UserModule via 

  |  UserModule userModule = (UserModule)new InitialContext().lookup ("java:portal/UserModule");   
  | 
doesn't work because of a ClassCastException...
Can anybody help me?
I'm using JBoss Portal 2.4 and JBoss 4

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3988379#3988379

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3988379



More information about the jboss-dev-forums mailing list