Liferay Portal CE 6.2 Portlet 配置(Configuration) 開發

Portlet配置(Configuration)開發

應用場景:比如左側菜單樹,每個一級會有一個節點圖標,我們通過配置,可以隨時更新圖標。所以圖票取自文檔庫。

 

Portlet.xml配置

<portlet>

<portlet-name>leftmenuv2</portlet-name>

<display-name>leftmenuv2</display-name>

<portlet-class>com.yixin.LeftMenuv2.LeftMenuV2</portlet-class>

<init-param>

<name>view-template</name>

<value>/html/leftmenuv2/view.jsp</value>

</init-param>

<init-param>

<name>config-template</name>

<value>/html/leftmenuv2/configuration.jsp</value>

</init-param>

 

Liferay-portlet.xml配置文件

<portlet>

<portlet-name>leftmenuv2</portlet-name>

<icon>/icon.png</icon>

<struts-path>leftmenuv2</struts-path>

<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>

 

 

Configuration.jsp

注: lable是中文名字,配置一下國際化。

Input name要以preferences--開頭

<%@include file="/html/init.jsp" %>

<%

StringimageURLFromDocumentlibrary =portletPreferences.getValue("imageURLFromDocumentlibrary",String.valueOf("imageURLFromDocumentlibrary"));        

%>

<liferay-portlet:actionURLportletConfiguration="true" var="configurationActionURL"/>

 

<liferay-portlet:renderURLportletConfiguration="true" var="configurationRenderURL"/>

 

<aui:formaction="<%= configurationActionURL %>" method="post"name="fm">

<aui:inputname="<%= Constants.CMD %>" type="hidden"value="<%= Constants.UPDATE %>" />

<aui:inputname="redirect" type="hidden" value="<%=configurationRenderURL %>" />

 

<aui:fieldset>

<aui:inputname="preferences--imageURLFromDocumentlibrary--"label="imageURLFromDocumentlibrary"type="text" value="<%= imageURLFromDocumentlibrary%>" />

</aui:fieldset>

 

 

<aui:button-row>

<aui:buttontype="submit" />

</aui:button-row>

</aui:form>

 

 

View.jsp中讀取

<%

StringimageURLFromDocumentlibrary =portletPreferences.getValue("imageURLFromDocumentlibrary",String.valueOf("imageURLFromDocumentlibrary"));        

%>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章