You are correct Dave. That's why we did it. It's sort of hackey, but it works very well.
Stan Silvert JBoss, Inc. [EMAIL PROTECTED] callto://stansilvert > -----Original Message----- > From: Dave Brondsema [mailto:[EMAIL PROTECTED] > Sent: Thursday, October 06, 2005 8:42 AM > To: MyFaces Discussion > Subject: Re: Portlet Modes > > This description is off the top of my head, but I know for sure that I > had problems when I didn't set it. > > There are some places in MyFaces where it needs to cast > ExternalContext.getContext() as either a PortletContext or a > ServletContext. MyFaces shouldn't require having a portlet.jar so it > cannot make the determination of the type of request based on > "instanceof" checks and casting. So it determines the request type with > an attribute flag. setPortletRequestFlag() sets that. > > I figured this out by looking at the source and reading some discussion > in the JIRA issue tracker regarding the initial creation of > MyFacesGenericPortlet. Look into those areas if you want more info. > > Dave > > Patrick Dalla Bernardina wrote: > > What is setPortletRequestFlag(request); for? > > > > > > > > Dave Brondsema wrote: > > > >> Cool. Make sure you call setPortletRequestFlag(request); before > >> nonFacesRequest. > >> > >> It might be useful to include part of this on the wiki page as an > >> example for anyone else who wants to do that. > >> > >> Patrick Dalla Bernardina wrote: > >> > >> > >>> With your help I've made an improvement to the implementation in wiki > >>> page. > >>> > >>> Before calling nonFacesRequest I call an action of an bean called > >>> PortletBackBean. > >>> If this bean is not declared in managed beans, no method is called. > >>> I'm showing only doEdit, but the same can be applied to doView. > >>> > >>> > >>> public void doEdit(RenderRequest request, RenderResponse > >>> response)throws PortletException, IOException { > >>> Boolean isPortletModeChanged = > >>> (Boolean)request.getAttribute(ATTR_PORTLET_MODE_CHANGED); > >>> > >>> if (isPortletModeChanged.booleanValue()) { > >>> response.setContentType("text/html"); > >>> > >>> FacesContext fctx = facesContext(request, response); > >>> if(fctx!=null){ > >>> MethodBinding mb = > >>> fctx.getApplication().createMethodBinding("#{PortletBackBean.edit}", > >>> null); > >>> if(mb!=null){ > >>> try{ > >>> Object methodResult = mb.invoke(fctx, null); > >>> }catch(PropertyNotFoundException e){ > >>> /* if the managed bean is not faound ignore the > >>> calling*/ > >>> } > >>> } > >>> } > >>> > >>> nonFacesRequest(request, response, defaultEdit); > >>> return; > >>> } > >>> > >>> facesRender(request, response); > >>> } > >>> > >>> > >>> > >>> > >>> Dave Brondsema wrote: > >>> > >>> > >>> > >>>> Patrick Dalla Bernardina wrote: > >>>> > >>>> > >>>> > >>>> > >>>>> How can I call an managed bean action when portlet mode (EDIT,VIEW) > is > >>>>> changed and process the navigation rules to discover the page to be > >>>>> rendered? > >>>>> > >>>>> > >>>> > >>>> You can use http://wiki.apache.org/myfaces/UsingPortletModes as a > >>>> starting point. > >>>> > >>>> To invoke a managed bean action, something like this will work I > think: > >>>> > >>>> ValueBinding binding = > >>>> > FacesContext.getCurrentInstance().getApplication().createValueBinding("# {m > yBean.someAction}"); > >>>> > >>>> > >>>> Object methodResult = > >>>> binding.getValue(FacesContext.getCurrentInstance()); > >>>> > >>>> > >>>> > >>>> > >>>> > >> > >> > >> > >> > >> > > > > > -- > Dave Brondsema > Software Developer > Cornerstone University