来自 wiki(不过在这里并不感到羞耻,我花了很长时间才找到它):
将配置页面添加到插件 Portlet <- 在此处获取更多信息
liferay-portlet.xml->
<portlet>
<portlet-name>configuration-example</portlet-name>
<icon>/icon.png</icon>
<configuration-action-class>com.sample.jsp.action.ConfigurationActionImpl</configuration-action-class>
<instanceable>true</instanceable>
<header-portlet-css>/css/test.css</header-portlet-css>
<footer-portlet-javascript>/js/test.js</footer-portlet-javascript>
</portlet>
ConfigurationActionImpl.java(或你的类)->
public class ConfigurationActionImpl implements ConfigurationAction {
public void processAction(PortletConfig config, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {
String portletResource = ParamUtil.getString(actionRequest, "portletResource");
PortletPreferences prefs = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest, portletResource);
//Read, validate, and then set form parameters as portlet preferences
prefs.store();
SessionMessages.add(actionRequest, portletConfig.getPortletName() + ".doConfigure");
}
public String render(PortletConfig config, RenderRequest renderRequest, RenderResponse renderResponse) throws Exception {
return "/configuration.jsp";
}
}
配置.jsp
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<portlet:defineObjects />
<form action="<liferay-portlet:actionURL portletConfiguration="true" />" method="post" name="<portlet:namespace />fm"> <input name="<portlet:namespace /><%=Constants.CMD%>" type="hidden" value="<%=Constants.UPDATE%>" />
Type: <select name="<portlet:namespace />type"> <option value="casual">Casual</option> <option value="formal">Formal</option> </select> <br/>
<input type="button" value="Save" onClick="submitForm(document.<portlet:namespace />fm);" /> </form>
“注意 liferay-portlet:actionURL 标记中的 portletConfiguration 属性。”