一. 在搭建好的开发环境生运行,点击clean,点start,点击build-ext 生成 ext的Java项目 .
二.导入ext,格式如下
三.在根目录下创建 app.server.计算机名.proerties(我已经创建了 app.server.Terry.properites)
把app.server.porperites文件内容全部复制过来,修改app.server.parent.dir(tomact所在的根目录),
如我的在E盘:app.server.parent.dir=E:\,修改 app.server.tomcat.dir=${app.server.parent.dir}/
我的tomcat为(liferayportal):app.server.tomcat.dir=${app.server.parent.dir}/liferayportal
四.在 ext-impl/src 下创建 com.ext.portlet下创建成hell.action 包,并创建 HellowAction.java类
package com.ext.portlet.hello.action;
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.liferay.portal.struts.PortletAction;
public class HelloAction extends PortletAction{
public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig config, RenderRequest req, RenderResponse res) throws Exception {
return mapping.findForward("ext.hello.view");
}
}
五.在ext-web/docroot/WEB-INF下,把struts-config.xml改成struts-config-ext.xml,添加
<action path="/ext/hello/view" type="com.ext.portlet.hello.action.HelloAction">
<forward name="ext.hello.view" path="ext.hello.view"/>
</action>
六.在ext-web/docrott/WEB-INF下,liferay-portlet-ext.xml
添加:
<portlet>
<portlet-name>Hello_World</portlet-name>
<struts-path>ext/hello</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<use-default-template>false</use-default-template>
<restore-current-view>fasle</restore-current-view>
<instanceable>true</instanceable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>0</render-weight>
</portlet>
六.在ext-web/docroot/WEB-INF下,portlet-ext.xml中添加:
<portlet>
<portlet-name>Hello_World</portlet-name>
<display-name>Hello_World</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/ext/hello/view</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
七.在 ext-web/docroot/WEB-INF下,在liferay-diaplay.xml中添加:
<category name="category.sample">
<portlet id="Hello_World"/>
</category>
八.在 ext-web/docroot/WEB-INF下,在titles-defs.xml修改成titles-defs-ext.xml
<definition name="ext.hello.view" extends="portlet">
<put name="portlet_content" value="/portlet/ext/hello/view.jsp"/>
</definition>
九 .运行build.xml下的deploy既可以发部布署
然后运行tomact看看效果 嘿嘿 最简单的例子 ~~~~~~~~~~~