Reputation: 443
I am trying to create a liferay portlet that supports edit as well as view mode. I am using the default MVCPortlet provided in liferay source.
I have configured the portlet.xml as follows
<portlet>
<portlet-name>inline-portlet</portlet-name>
<display-name>inline</display-name>
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
<init-param>
<name>edit-jsp</name>
<value>/edit.jsp</value>
</init-param>
<init-param>
<name>view-jsp</name>
<value>/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
</supports>
<portlet-info>
<title>inline</title>
<short-title>inline</short-title>
<keywords>inline</keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
When I deploy it I am unable to see any new tab created in the edit mode that is when we click on the wrench like icon.
Is there any configuration I am missing. I already have edit.jsp and view.jsp in root directory. The view is consistent but cannot find the edit.jsp in other words it is not called.
Any ideas on this ?
Upvotes: 2
Views: 10045
Reputation: 2618
Depending of your case, besides portlet.xml
config, you need to implement the doView
, doEdit
and processAction
methods in your class that can extend MVCPortlet
. "Liferay in Action" book has a good example.
Or you can do all the logic within jsp files and taglibs of Liferay. Edit mode is available clicking in Preferences.
Upvotes: 0
Reputation: 3865
You have to create class that implements
com.liferay.portal.kernel.portlet.ConfigurationAction
and you must register it in liferay-portlet.xml
in the portlet node.
<portlet>
<portlet-name>MyPortlet</portlet-name>
<configuration-action-class>com.mydomain.MyConfigurationAction</configuration-action-class>
</portlet>
Upvotes: 1
Reputation: 5088
Have you added the Edit mode in the portlet.xml
? like this ?
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
<portlet-mode>help</portlet-mode>
</supports>
All modes used by the portlet must be explicit set in this part of the config of portlet.xml
and you have to do this to all portlets you want more than view mode.
Also you could write a mode handler like this in your class, just implement PortletListener
it could be useful for debugging at least.
public void handleResourceRequest(ResourceRequest request,
ResourceResponse response,
Window window) {
// Switch the view according to the portlet mode
if (request.getPortletMode() == PortletMode.EDIT){
this.addWindow(editWindow);
}else if (request.getPortletMode() == PortletMode.VIEW){
window.setContent(viewContent);
}else if (request.getPortletMode() == PortletMode.HELP)
window.setContent(helpContent);
}
Also check the portlet permissions, did you try as an admin ? they should see it no matter what. regular users on the other hand should have permissions to set preferences of a specific portlet.
Cheers
Upvotes: 2
Reputation: 1402
If you create custom portlets with an edit mode, this mode will not appear under a tab underneath the Configuration icon like Liferay's default portlets. Instead, your edit mode's JSP will be accessible via a new icon, which is called Preferences.
The portlet spec only defines VIEW, EDIT and HELP modes, but allows custom portlet modes to be added to the list. This is exactly what Liferay did for its default portlets. They use the CONFIG custom portlet mode. For an example of how to implement this, check this thread's last post.
Upvotes: 2
Reputation: 21
I think the portlet Edit mode in Liferay is called "Preference"
Upvotes: 2