Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a conf menu to my portlet

I'm trying to add a tab in the conf of my custom portlet, beside the natives import/export and permissions.

Like in this image : http://imageshack.us/photo/my-images/716/sampledn.png/

This tab had to allow, to change the value of a parameter in a conf.properties which define some variable.

How can I do that?

Regards.

like image 861
provençal le breton Avatar asked Jan 16 '23 09:01

provençal le breton


2 Answers

Yup you can do it by first of all adding this to your portlet.xml as a child of the "portlet" node:

    <init-param>
        <name>config-jsp</name>
        <value>/html/config.jsp</value>
    </init-param>

The in your liferay-portlet.xml you need to add this as a child of the "portlet" node:

<configuration-action-class>com.yourportlet.action.ConfigurationActionImpl</configuration-action-class>

Then you need to create this files in the directories you've specified in your XML, and your ConfigurationActionImpl should implement the ConfigurationAction interface so the skeleton would look like this:

public class ConfigurationActionImpl implements ConfigurationAction {

@Override
public String render(PortletConfig config, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {                   
    return "/html/config.jsp";
}

Let me know if this helps or you have any other questions! :)

like image 59
Jonny Avatar answered Feb 20 '23 21:02

Jonny


Add edit mode to your portlet.xml:

    <supports>
        <mime-type>text/html</mime-type>
        <portlet-mode>view</portlet-mode>
        <portlet-mode>edit</portlet-mode> <!-- add this line -->
    </supports>

Then you will see preferences option in the menu. Override doEdit method in your portlet class to render content of the edit mode.

EDIT:

More advanced solution:

You can add another tab by changing portal jsp via hook. The jsp you need to change is:

/html/portlet/portlet_configuration/tabs1.jsp

Note that this will change configuration window for ALL portlets.

like image 29
František Hartman Avatar answered Feb 20 '23 22:02

František Hartman