1.本文以”我的账户” portlet为例解说。
2.设置页面为面板类型(这步可以不做,本文作者我是因为要实现个类似控制面板样的东西,所以这么做).
3.站点的控制面板中 公开页面/高级选项 合并主页站点的公共页面(这步可以不做,本文作者我是因为要实现个类似控制面板样的东西,所以这么做).
4.在ext项目中 liferay-portlet-ext.xml中加入
<portlet> <portlet-name>2</portlet-name> <icon>/html/icons/my_account.png</icon> <struts-path>my_account</struts-path> <portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class> <control-panel-entry-category>my</control-panel-entry-category> <control-panel-entry-weight>1.0</control-panel-entry-weight> <control-panel-entry-class>com.liferay.portlet.myaccount.MyAccountControlPanelEntry</control-panel-entry-class> <preferences-owned-by-group>true</preferences-owned-by-group> <use-default-template>false</use-default-template> <private-request-attributes>false</private-request-attributes> <private-session-attributes>false</private-session-attributes> <render-weight>50</render-weight> <header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css> <footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript> <css-class-wrapper>portlet-users-admin</css-class-wrapper> <add-default-resource>true</add-default-resource> <system>false</system> </portlet>
主要是为了将system标签的值设置为false否则无法在控制面板以外的画面中使用
5.在ext项目中的docroot/WEB-INF/ext-impl/src下 加入文件夹 resource-actions 将源码中的portal.xml粘贴过来
修改
<portlet-resource> <portlet-name>2</portlet-name> <permissions> <supports> <action-key>ACCESS_IN_CONTROL_PANEL</action-key> <action-key>CONFIGURATION</action-key> <action-key>VIEW</action-key> </supports> <site-member-defaults /> <guest-defaults /> <guest-unsupported> <action-key>ACCESS_IN_CONTROL_PANEL</action-key> <action-key>CONFIGURATION</action-key> <action-key>VIEW</action-key> </guest-unsupported> </permissions> </portlet-resource>
为
<portlet-resource> <portlet-name>2</portlet-name> <permissions> <supports> <action-key>ADD_TO_PAGE</action-key> <action-key>ACCESS_IN_CONTROL_PANEL</action-key> <action-key>CONFIGURATION</action-key> <action-key>VIEW</action-key> </supports> <site-member-defaults /> <guest-defaults /> <guest-unsupported> <action-key>ACCESS_IN_CONTROL_PANEL</action-key> <action-key>CONFIGURATION</action-key> <action-key>VIEW</action-key> </guest-unsupported> </permissions> </portlet-resource>
这部是为了让这个portlet可以添加到画面中去。
6.添加到画面,问题解决。