AnsweredAssumed Answered

WebScriptPortlet Edit Mode

Question asked by thagan on Sep 28, 2007
Latest reply on May 12, 2008 by kimmoilppola
Hi there

I'm developing a portlet under Liferay 4.3.1 using Alfresco 2.1.
I extended WebScriptPortlet and I would like to customize its behavior when in EDIT-MODE.

This is the render() method on the original WebScriptPortlet:

        if (PortletMode.VIEW.equals(portletMode))
        {
           doView(req, res);
        }
//        else if (PortletMode.HELP.equals(portletMode))
//        {//           doHelp(req, res);
//        }
//      else if (PortletMode.EDIT.equals(portletMode))
//      {
//         doEdit(req, res);
//      }


I redefined the render() method uncommenting the code related to EDIT-MODE case and creating a customized doEdit() method.

I also added the highlighted entry in the following code on portlet.xml:

        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>EDIT</portlet-mode> <!– my entry –>
        </supports>

When I execute my portlet, the VIEW-MODE works fine, but the EDIT-MODE doesn't.
I would expect that when i click on [img]http://img232.imageshack.us/img232/5616/configuration1jl3.png[/img] button on the top bar, my portlet was executed as follows:
render() -> if on EDIT-MODE -> doEdit().
But render() method isn't invoked.

Instead of that, the [img]http://img232.imageshack.us/img232/5616/configuration1jl3.png[/img] button redirects to the following url:
javascript: self.location = 'http%3A%2F%2Flocalhost%3A8080%2Fuser%2Fjoebloggs%2F2%3Fp_p_id%3D86%26p_p_action
%3D0%26p_p_state%3Dmaximized%26p_p_col_id%3Dcolumn-1%26p_p_col_count
%3D1%26_86_struts_action%3D%252Fportlet_configuration%252Fedit_permissions%26_86_portletResource
%3DAlfrescoLancioPortlet_WAR_alfresco%26_86_resourcePrimKey%3D10317_LAYOUT_AlfrescoLancioPortlet_WAR_alfresco
%26_86_redirect%3D%252Fuser%252Fjoebloggs%252F2%26_86_backURL%3D%252Fuser%252Fjoebloggs
%252F2&_86_previewWidth=' + document.getElementById('p_p_id_AlfrescoLancioPortlet_WAR_alfresco_').offsetWidth;

The (longest ever :D ) url takes to the following page (I created my portlet backing up "My Web Files" portlet and customizing it):
[img]http://img241.imageshack.us/img241/1520/editpagebi5.gif[/img]

I tried to find a jsp or an xml file where the portlet top bar commands are defined and configured, but I didn't find it.

Summing up, when I click on [img]http://img232.imageshack.us/img232/5616/configuration1jl3.png[/img] button, I want my portlet to be executed in the same way as for VIEW-MODE except for the portlet-mode parameter which should be set with EDIT value (edit or EDIT is the same).

Thanks in advance

Outcomes