Forums

Home » Liferay Portal » English » 3. Development »

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Corné Aussems
set PortletMode in JSF portlet
April 9, 2010 5:38 AM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1078

Join Date: October 3, 2006

Recent Posts

I have a problem in controlling the PortletMode back to View after changing the preferences; on a Save or Back button;
Note: navigation works but if you return to /web/guest/home you'll see the EDIT page

I tried several things;
#1 Override com.sun.faces.portlet.FacesPortlet's processAction;

public void processAction(ActionRequest request, ActionResponse response) throws IOException, PortletException {
        PortletMode portletmode = request.getPortletMode();
        if (PortletMode.EDIT.equals(portletmode)) {
            response.setPortletMode(PortletMode.VIEW);
        } else if (PortletMode.HELP.equals(portletmode)) {
            response.setPortletMode(PortletMode.VIEW);
        }

        super.processAction(request, response);

    }

To some extend this works but only if you 'Save' to the same page eg return on action = "" and then press Back.
public String doSaveEditPage() {return "";}

public String doBackEditPage() {return "toview";}


#2 set ActionResponse from FacesContext
protected void setPortletModeToView() {
  ActionResponse action_response = (ActionResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
action_response.setPortletMode(PortletMode.VIEW);

}


Even example portlets like guessnumber show same problems;

Anyone please it's driving me crazy! emoticon

using
jsf-api_1.1.jar (1.1_02-b08) Sun
jsf-impl_1.1.jar (1.1_02-b08) Sun
jsf-portlet_1.1.jar (1.1.6) Sun
Corné Aussems
RE: set PortletMode in JSF portlet
April 9, 2010 5:47 AM
Answer

Corné Aussems

Rank: Liferay Legend

Posts: 1078

Join Date: October 3, 2006

Recent Posts

Replicatable with this portlet

Deploy portlet (guessnumberportlet.war ) on /web/guest/home

>> Change preferences;
>> Press Submit;
>> navigate to /web/guest/home (by logo or nav):

BTW pressing "Return to Full Page" will solve the issue
Attachment

Attachments: ScreenShot524.png (7.6k), guessnumberportlet.war (1,568.0k)