Access to portlet preferences is not defined in the JSF spec.  I have
spoken to the JSF spec lead about it so we can take care of this in JSF
2.0.

For now, you can get the RenderResponse from the ExternalContext as you
showed.  In MyFaces, you can protect your code with a guard clause like
this:

if (PortletUtil.isRenderRequest(facesContext)) {
   // cast request to a RenderRequest
}

Another approach is to extend MyFacesGenericPortlet and put portlet
preferences into an appropriate context such as the session.  This makes
them available from the ExternalContext without casting.

Stan Silvert
JBoss, Inc.
[EMAIL PROTECTED]
callto://stansilvert

> -----Original Message-----
> From: j m [mailto:[EMAIL PROTECTED]
> Sent: Saturday, September 03, 2005 1:22 PM
> To: dev@myfaces.apache.org
> Subject: Access default portlet preferences from backing bean (JSR-168
> portlet)
> 
> hi,
> 
> I'm using MyFaces snapshot 20050826 for my JSR-168 portlets.
> 
> I'd like to access default portlet preferences which are stored in
> portlet.xml from my backing bean. But this didn't work - can anybody
help
> me?
> 
> What I managed was to store and get portlet preferences from my
> running portlet - so
> these preferences are not stored in portle.xml but are managed by a
> persistance manager of the portlet container.
> 
> But I need to get some default pref. from portlet.xml - which are
> normally available
> within the PortletPreferences object.
> 
> This is the code I'm using to access the portlet preferences:
> 
> int prefCount =
>
((javax.portlet.RenderRequest)FacesContext.getCurrentInstance().getExter
na
> lContext().getRequest()).getPreferences().getMap().size();
> 
> I also tried to cast the faces request to PortletRequest and
> ActionRequest but that didn't help.
> 
> 
> 
> Thanks in advance
> jm

Reply via email to