<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Terry.Li-彬

    虛其心,可解天下之問;專其心,可治天下之學;靜其心,可悟天下之理;恒其心,可成天下之業(yè)。

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      143 隨筆 :: 344 文章 :: 130 評論 :: 0 Trackbacks
     

    談了這么多,還沒說怎么自己往Liferay中創(chuàng)建和加入一個portlet,Liferay中定義了幾種類型的portlet,如JSPPortlet,StrutsPortlet,和VelocityPortlet。先以JSPPortlet為例說明吧。

    1. 定義新的JSP Portlet

    a) 首先到 ...\portlet\ext中去加入自己要創(chuàng)建的portlet文件夾,例如myappletportlet,在文件夾中創(chuàng)建一個view.jsp,其中的內(nèi)容可最簡單為:

    Hello JSPPortlet world!

    最好的起始學習方法應(yīng)該是照葫蘆畫瓢吧,找一個已有的portlet,看它的結(jié)構(gòu)和代碼。

    b) 到 ...\WEB-INF\portlet-ext.xml 中加入
    <portlet>
     <portlet-name>EXT_2</portlet-name>
     <!-- portlet 的最關(guān)鍵ID -->

     <display-name>My AppletPortlet</display-name>

     <portlet-class>com.liferay.portlet.JSPPortlet</portlet-class>
     <!-- portlet 所屬的類 -->

     <init-param>
      <name>view-jsp</name>
      <value>/portlet/ext/myappletportlet/view.jsp</value>
      <!-- MVC中會直接傳遞到view.jsp -->
     </init-param>
     <expiration-cache>300</expiration-cache>
     <supports>
      <mime-type>text/html</mime-type>
     </supports>
     <portlet-info>
      <title>PENG Portlet</title>
      <!-- Portlet上顯示的名字 -->
     </portlet-info>
     <security-role-ref>
      <role-name>Power User</role-name>
     </security-role-ref>
     <security-role-ref>
      <role-name>User</role-name>
     </security-role-ref>
    </portlet>

    c) 到 ...\WEB-INF\liferay-portlet-ext.xml 中加入

    <portlet>
     <portlet-name>EXT_2</portlet-name>
    </portlet>

    d) 到...\WEB-INF\liferay-display.xml 中加入以下代碼,以將EXT_2加入sample分類,到時候在Add Content時可以在這個sample組找到,否則在undefined中找。

    <category name="category.sample">
     <portlet id="47"/>
     ......
     <portlet id="EXT_2"/>
    </category>

    e) 測試。如果上述的修改是直接在tomcat目錄中進行的話,重新啟動tomcat。如果是在前面提到的自己創(chuàng)建的EXT環(huán)境下進行的話,先用ant一下,再啟動tomcat。然后http://localhost:8080/,用test@liferay.com/test進去,選擇Add Content,應(yīng)該可以在sample目錄下找到前面創(chuàng)建的那個portlet了:PENG Portlet。


    2. 定義新的StrutsPortlet。過程要略微復(fù)雜一些,誰叫我們要用傳說中的MVC呢。先列出幾個關(guān)鍵的配置文件:
    portlet-ext.xml: 定義portlet(JSR-168 attributes)
    liferay-portlet-ext.xml: 注冊portlet(Liferay attributes)
    struts-config.xml: 定義 page-flow (action mapping)
    tiles-defs.xml: 定義 the page layout
    更詳細的信息可從Liferay的官方網(wǎng)站上獲得。

    a) 在ext中增加一個叫做Tiles的portlet文件夾,在其中創(chuàng)建一個view.jsp。內(nèi)容可以簡單為:

    Hello StrutsPortlet world!

    b) Portlet-ext.xml 中加入
    <portlet>
     <portlet-name>EXT_3</portlet-name>
     <display-name>Tiles</display-name>
     <portlet-class>
      com.liferay.portlet.StrutsPortlet
      <!—實現(xiàn)JSR-168規(guī)范的類 -->
     </portlet-class>

     <init-param>
      <name>view-action</name>
      <value>/ext/tiles/view</value>
       <!-- portal會到struts-config.xml中去尋找/ext/tiles/view -->
     </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>user</role-name>
     </security-role-ref>
    </portlet>


    c) liferay-portlet-ext.xml中加入

    <portlet>
     <portlet-name>EXT_3</portlet-name>
     <struts-path>ext/tiles</struts-path>
     <!-- 告訴portal所有帶有ext/tiles/*路徑的請求可以認為是這個portlet的范圍 -->
     <use-default-template>false</use-default-template>
     <!-- 因為將采用別的template,所以設(shè)置為false。將要使用的template在tiles-defs.xml中定義。-->
    </portlet>


    d) struts-config-ext.xml中加入

    <action path="/ext/tiles/view"
     forward="portlet.ext.tiles.view" />
    <!-- Struts 將會在 tiles-defs.xml 中尋找 portlet.ext.tiles.view -->

    e) 在tiles-defs-ext.xml 中加入

    <definition name="portlet.ext.tiles.view" extends="portlet">
    <!-- 定義了哪個 template 將被使用,這里是portlet template。這個template 定義了portlet的borders和buttons(例如minimize, maximize, close 等等)。 -->

    <put name="portlet_content" value="/portlet/ext/tiles/view.jsp" />
     <!-- portlet_content 是一個liferay的變量,portal可以使用這個變量來決定在portlet中會呈現(xiàn)什么內(nèi)容。這里portlet的內(nèi)容就是view.jsp。 -->
    </definition>

    f) 測試。

     

    Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=2177436

    posted on 2008-03-14 14:15 禮物 閱讀(1531) 評論(2)  編輯  收藏 所屬分類: Liferay

    評論

    # re: 深入淺出Liferay Portal (12) 2009-03-30 14:59 小雨
    你好,
    寫得很好,受益匪淺,在下有兩個問題,請仁兄賜教:
    1. 本人想在 theme vm 中使用 iframe 讓portal 內(nèi)容部分 布局成左右兩邊,結(jié)果頁面無法顯示,該如何處理?

    2.目前 portal內(nèi)容/菜單都是同時刷新,是否可以實現(xiàn) 僅內(nèi)容頁面刷新,菜單/頭部不刷新?
    比如portal:/web/guest/aa 如果在portal_normal.vm中使用iframe a, a.src = "/web/guest/aa", 這樣的話整個頁面都加到了 a中,如何實現(xiàn)只加載portal 內(nèi)容部分

    謝謝!   回復(fù)  更多評論
      

    # re: 深入淺出Liferay Portal (12) 2009-09-28 11:37 liferay
    歡迎加群49588979一起討論學習liferay  回復(fù)  更多評論
      

    主站蜘蛛池模板: 人妻视频一区二区三区免费| 久久亚洲精品无码AV红樱桃| 免费人成在线观看69式小视频| 污网站在线免费观看| 亚洲人成网站看在线播放| 亚洲福利视频一区| 亚洲日韩精品一区二区三区无码| 色播在线永久免费视频| 男女免费观看在线爽爽爽视频| 国内精品免费视频精选在线观看| 一区二区在线视频免费观看| 亚洲AV无码成人网站在线观看| 激情内射亚洲一区二区三区爱妻| 亚洲免费视频网站| 亚洲av无码精品网站| 亚洲真人无码永久在线| 亚洲精品成人a在线观看| 免费永久在线观看黄网站| 日韩一区二区a片免费观看| 久久精品私人影院免费看| 国产性生大片免费观看性 | 久久国产精品免费观看| 毛片基地看看成人免费| 国产成人无码精品久久久久免费| 色偷偷亚洲第一综合| 亚洲成在人线在线播放无码| 亚洲综合无码一区二区痴汉| 亚洲综合色一区二区三区| 亚洲一久久久久久久久| 亚洲人成小说网站色| 日本亚洲色大成网站www久久 | 四虎在线最新永久免费| 8x成人永久免费视频| 18禁黄网站禁片免费观看不卡| 24小时免费看片| 国产免费丝袜调教视频| 毛片免费观看网站| 国产免费黄色大片| 国产成人精品曰本亚洲79ren| 国产亚洲美女精品久久久2020| 亚洲婷婷五月综合狠狠爱|