Re: portlet modes
Dave Brondsema wrote: > How can I create a link which changes portlet modes (view, edit, etc) > and states (minimized, normal, etc)? > > gives me a URL but > when I try to put it in a commandlink or outputlink it doesn't work. > ${viewURL} isn't allowed by the TLD and #{viewURL} outputs nothing. > Using ${viewURL} in a regular gives errors about VIEW_ID > > I am using uPortal 2.5.0 > > Thanks! > renderURL works instead of actionURL -- Dave Brondsema Software Developer Cornerstone University signature.asc Description: OpenPGP digital signature
Re: Portlet Modes
Ok, I had already seen this wiki page. An implemented a subclass o MyFacesGenericPortlet that implements these methods. But it has some limitations. First: I can't call an managed bean action when the mode is changed. Second: The rules in navigation rules are not followed. Third: It don't reset faces navigation state. So when I enter in edit mode, make some faces navigation, and go back to view mode everything work well. But when I maximize the portlet the last edit page I were before changing to view mode is displayed and not the view page I were. I would like some suggestions on how to implement these requisites Thanks 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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance());
Re: Portlet Modes
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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance());
Re: Portlet Modes
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("#{myBean.someAction}"); >> >> Object methodResult = >> binding.getValue(FacesContext.getCurrentInstance()); >> >> >> >> > -- Dave Brondsema Software Developer Cornerstone University signature.asc Description: OpenPGP digital signature
Re: Portlet Modes
It can be improved by getting the action to be executed from portlet preferences. instead of fctx.getApplication().createMethodBinding("#{PortletBackBean.edit}", null); use fctx.getApplication().createMethodBinding(request.getPreferences().getValue("VIEW_ACTION","#{PortletBackBean.view}"), null); 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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance());
Re: Portlet Modes
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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance());
Re: Portlet Modes
New release of doEdit and doView: In this code, facesRender is called. An action configured in EDIT_ACTION portlet preference is called and the result is passed to handleNavigation. handle navigation looks for an navigation rule where "from" can be "*" or value of DEFAULT_EDIT portlet init parameter (defaultEdit variable is loaded in method init() of portlet) and the "outcome" is the result of the action. I've done little test but it seems to work. 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){ editAction = request.getPreferences().getValue("EDIT_ACTION",editAction); MethodBinding mb = fctx.getApplication().createMethodBinding(editAction, null); if(mb!=null){ try{ Object methodResult = mb.invoke(fctx, null); if(fctx.getViewRoot()==null){ fctx.setViewRoot(fctx.getApplication().getViewHandler().createView(fctx,defaultEdit)); } fctx.getApplication().getNavigationHandler().handleNavigation(fctx, editAction, methodResult.toString()); }catch(EvaluationException e){ /* if the managed bean is not faound ignore the calling */ } } } } facesRender(request, response); } 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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance());
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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance()); >> >> >> >> >> > -- Dave Brondsema Software Developer Cornerstone University signature.asc Description: OpenPGP digital signature
RE: Portlet Modes
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
Re: Portlet Modes (was: Issue with MyFacesGenericPortlet)
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("#{myBean.someAction}"); Object methodResult = binding.getValue(FacesContext.getCurrentInstance()); -- Dave Brondsema Software Developer Cornerstone University signature.asc Description: OpenPGP digital signature