It definitely does! Thank you very much! it works great!

On May 18, 2007, at 9:08 AM, Cooper, Stephen wrote:

Here's how I do it for Edit Mode going back to View mode after the user
presses "Save".

I have a public String save() method which tells the preferences to save
themselves, then it calls this static method (I made it static so that
any JSF bean can call it as part of its action method):

    /**
* Change the mode for this portlet to VIEW. This method is static
so
     * that it may be accessed from any bean.
     */
    public static void switchToView() {
        if (null == FacesContext.getCurrentInstance()) return;
        ExternalContext externalContext =
            FacesContext.getCurrentInstance().getExternalContext();
        if (externalContext.getResponse() instanceof ActionResponse)
        {
            ActionResponse response =
                (ActionResponse) externalContext.getResponse();
            try
            {
                response.setPortletMode(PortletMode.VIEW);
            }
            catch (PortletModeException e)
            {
                logException(e);
            }
        }
    }

Hope this helps.



-----Original Message-----
From: Alexander Wallace [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 17, 2007 3:17 PM
To: MyFaces Discussion
Subject: Re: using portlet modes

I see... Indeed i can change the next page displayed doing this.. But i
have not found how to switch the mode back to view so that the portlet
decoration icons go back to the set displayed when in view mode... What
I have is the page displayed normally under view mode, but the portlet
still is in  edit mode...

I've googled a lot and there is not a clear hit telling me how to switch
the mode in my faces...

help?

On May 15, 2007, at 12:28 PM, Ryan Wynn wrote:

On 5/11/07, Alexander Wallace <[EMAIL PROTECTED]> wrote:
I can't find much info about the suggestion you make in google... Any

more details are greatly appreciated... Thanks!

what I meant is that command buttons and command links have an
attribute called action which is set to a method binding expression.
This method will be invoked in the jsf process action phase.  Inside
this method it is ok to change the portlet mode.  You do not need to
introduce phase listeners.



On May 10, 2007, at 6:07 PM, Ryan Wynn wrote:

On 5/10/07, Alexander Wallace <[EMAIL PROTECTED]> wrote:
Hi All... I'm finding using portlet modes in jsf at the very least

cumbersome... Is this really how it is? Should I just forget about

portlet modes and use jsf navigation rules to compensate?

I'm doing stuff like this: If you hit the edit icon you are
taken to
the edit jsp correctly (so far so good) via override to doEdit and

calling nonFacesRequest

However, when I want to switch back to view mode, I'm having to
override processAction where i can switch the mode, however, i
can't
see any of the parameters and attributes changed in portlet
request
by my bean action listeners... So... i either use a session
attribute
or do the switch blindly...

You should not have to override processAction in
MyFacesGenericPortlet
to accomplish this.  You can change the portlet mode during the
process action phase of the jsf lifecycle because this phase
happens
within the portlet action phase.  You will, however, have to
cast the
to portlet specific objects from the external context because
jsf does
not provide a portlet api.



Worse, switching modes doesn't change the VIEW_ID (expected) but i

seem to only be able to change that back in doView now (since i
changed mode back to view) by checking if i was looking at my
"edit"
view page... Still is too late to validate if i really wanted
to go
there...

Is this really how it is done? Anyone else using portlet modes?

Thanks in advance!









Reply via email to