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

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to