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

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

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

    posts - 12, comments - 19, trackbacks - 0, articles - 23
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    Portlet應用開發 (JSR168)(三)

    Posted on 2006-08-10 20:26 毛里求斯的化石 閱讀(614) 評論(0)  編輯  收藏 所屬分類: portal相關

    By Terry.lee

    SpiritSeekerS@sqatester.com

    ?

    ?

    ???????? 本部份將講述 PortletConfig 對象及其 PortletContext 對象的概念及應用 .

    ?

    • PortletConfig 對象
      ServletConfig 對象類似 , PortletConfig 對象提供 Portlet 初始的所需的參數及其對 PortletContext 對象存取提供相關方法 .
      ServletConfig 不同處在于 , PortletConfig 對象提供對 Portlet Title Bar 資源的 I18N 支持 , 我們可以設定不同的 Resource Bundle 文件用以提供多語言的支持 , 如下 portlet.xml 文件 :

    ?

    … …

    ?????????? <portlet-info>

    ???????????????? <title>PortletConfig Example</title>

    ???????????????? <short-title>PortletConfig</short-title>

    ???????????????? <keywords>PortletConfig</keywords>

    ? </portlet-info>

    ? … …

    ?

    以上 Portlet 描述文件中的設置用于顯示 Portlet Title Bar 文字 , 同樣也可以使用 Resource Bundle 用以顯示 Title Bar 文字 , 如下 :

    ?

    ? … …

    ? <resource-bundle>

    portlets.portletconfig.portletconfigexample

    </resource-bundle>

    ?????????? … …

    ?

    ?

    • A case study

    這里我們將開發一個簡單使用 Resource Bundle Portlet. 只需要添加所須的 Resource Bundle 文件 .

    ?

    我們使用英文及其中文的 Resource Bundle, 如下 :

    ?

    3)??? Base Resource Bundle (portletconfigexample.properties)

    ?

    # English Resource Bundle

    #

    # filename: portletconfigexample.properties

    # Portlet Info resource bundle example

    javax.portlet.title=PortletConfig Example

    javax.portlet.short-title=PortletConfig

    javax.portlet.keywords=PortletConfig

    2) Chinese Resource Bundle (portletconfigexample_zh.properties)

    ?

    # Chinese Resource Bundle

    #

    # filename: portletconfigexample.properties

    # Portlet Info resource bundle example

    javax.portlet.title=Portlet配置例子

    javax.portlet.short-title=Portlet配置

    javax.portlet.keywords=Portlet配置

    ?

    ?

    3) portlet.xml

    ?

    … …

    <resource-bundle>

    portlets.portletconfig.portletconfigexample

    </resource-bundle>

    … …




    ??????

    ?

    • 源代碼及 Portlet 相關配置文件

      1) Portlet (
      PortletConfigExample .java )

    ?

    package portlets.portletconfig;

    ?

    /**

    ? * @author terry

    ? *

    ? * To change the template for this generated type comment go to

    ? * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

    ? */

    ?

    import javax.portlet.*;

    import java.io.IOException;

    import java.io.Writer;

    ?

    public class PortletConfigExample ? extends GenericPortlet{

    ?

    ? public void doView(RenderRequest request, RenderResponse response)

    ? throws PortletException, IOException

    ? {

    ? response.setContentType( "text/html" );

    ? String view = getPortletConfig().getInitParameter( "view" );

    ? Writer writer=response.getWriter();

    ? writer.write(view);

    ? }

    ?

    ? public void doEdit(RenderRequest request, RenderResponse response)

    ? throws PortletException, IOException

    ? {

    ? response.setContentType( "text/html" );

    ? String edit = getPortletConfig().getInitParameter( "edit" );

    ? Writer writer=response.getWriter();

    ? writer.write(edit);

    ? }

    ?

    }

    ?

    ?

    2)???? Portlet.xml

    ?

    … …

    ?????? <!-- PortletConfig Example -->

    ?????? <portlet>

    ????????????? <description>PortletConfig Example</description>

    ????????????? <portlet-name>PortletConfigExample</portlet-name>

    ????????????? <display-name>disPortletConfigExample</display-name>

    ????????????? <portlet-class>portlets.portletconfig.PortletConfigExample</portlet-class>

    ????????????? <init-param>

    ???????????????????? <name>view</name>

    ???????????????????? <value>Here is View Mode</value>

    ????????????? </init-param>

    ????????????? <init-param>

    ???????????????????? <name>edit</name>

    ???????????????????? <value>Here is Edit Mode</value>

    ????????????? </init-param>

    ????????????? <expiration-cache>-1</expiration-cache>

    ????????????? <supports>

    ???????????????????? <mime-type>text/html</mime-type>

    ???????????????????? <portlet-mode>VIEW</portlet-mode>

    ???????????????????? <portlet-mode>EDIT</portlet-mode>

    ????????????? </supports>

    ????????????? <supported-locale>zh</supported-locale>

    ????????????? <supported-locale>en</supported-locale>

    ????????????? <resource-bundle>portlets.portletconfig.portletconfigexample</resource-bundle>

    ? </portlet>
    … …

    ?

    3)???? pageregistry.xml

    ?

    … …

    ????????????? <!-- PortletConfig Example Page -->

    ??? <fragment name="portletconfigpage" type="page">

    ??????? <navigation>

    ??????????? <title>PortletConfig Example Page</title>

    ??????????? <description>PortletConfig Example Page</description>

    ??????? </navigation>

    ??????? <fragment name="row1" type="row">

    ??????????? <fragment name="col1" type="column">

    ??????????????? <fragment name="p1" type="portlet">

    ??????????????????? <property name="portlet" value="10.20"/>

    ??????????????? </fragment>

    ??????????? </fragment>

    ??????? </fragment>

    ??? </fragment>
    … …

    ?

    4)???? PortletRegistry.xml

    ?

    … …

    ???? ?????? ????????<portlet id="20">

    ??????????? ?? <definition-id>portlets.PortletConfigExample</definition-id>

    ??????? </portlet>
    … …

    ?

    將以上源代碼編譯后 , 再通過 Eclipse 生成 / 更新 Portlet web.xml ,? 將所有配置及相關文件部署后 , 啟動 Tomcat.

    ?

    ?

    ?

    Browser 中加載如下頁面 : Http://localhost:8080/pluto/portal , 可以看到如下的頁面 ( :3-1)

    ?

    如果機器的 Locale 及語言設定是以中文簡體為缺省 , 則單擊 PortletConfig Example Page 后可以看到如下 Portlet 頁面 ( 3-1):

    ?

    ???? ????? 3-1

    ?

    : 因為現在 Pluto 的開發中沒有做 I18N 的處理 , 這里如果你的機器的 Locale 是中文的話 , 顯示是亂碼 , 請將 IE encoding 設定為 GB2312(View -> Encoding -> Chinese Simplified), 如圖 3-1.

    ?

    ?

    如果機器的 Locale 及語言設定是英文的話 , 將看到如下 Portlet 頁面 ( 3-2):

    ?

    3-2

    ?

    ?

    ?

    資源 :

    ·???????? Pluto
    http://jakarta.apache.org/pluto

    ·???????? Pluto Mail List
    http://news.gmane.org/gmane.comp.jakarta.pluto.user

    ·???????? WSRP Spec1.0
    http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=wsrp

    ·???????? Apache WSRP 實現
    http://ws.apache.org/wsrp4j/

    ·???????? Apache’s Portal, JetSpeed:
    http://jakarta.apache.org/jetspeed/site/index.html

    ·???????? JSR 168:
    http://www.jcp.org/en/jsr/detail?id=168

    · "Portlet 規范介紹 " By Stefan Hepper Stephan Hesmer

    Part 1: Get your feet wet with the specification's underlying terms and concepts (August 2003)

    Part 2: The Portlet API's reference implementation reveals its secrets (September 2003)

    主站蜘蛛池模板: 光棍天堂免费手机观看在线观看| 一级女性全黄久久生活片免费 | 你懂的免费在线观看网站| 麻豆视频免费播放| 亚洲色大成WWW亚洲女子| 国产免费爽爽视频在线观看| 成人亚洲网站www在线观看| 蜜芽亚洲av无码精品色午夜| 91青青青国产在观免费影视| 国产l精品国产亚洲区在线观看| 最近免费中文字幕大全免费| 亚洲av无码兔费综合| 国产亚洲精品国产| 日韩精品福利片午夜免费观着| 亚洲AV无码一区二区二三区软件| 中文字幕永久免费视频| 亚洲一区二区三区深夜天堂| 免费人妻无码不卡中文字幕系| 久久精品国产亚洲夜色AV网站| 最近2019中文字幕mv免费看| 亚洲国产区男人本色在线观看| JLZZJLZZ亚洲乱熟无码| 成人无码区免费A片视频WWW| 亚洲色欲色欱wwW在线| 永久亚洲成a人片777777| 成人特黄a级毛片免费视频| 亚洲系列国产精品制服丝袜第| 拍拍拍无挡视频免费观看1000| 亚洲黄色免费网站| www.av在线免费观看| 一本色道久久88—综合亚洲精品 | 一级女性全黄生活片免费看| 亚洲精品成人网站在线播放| 亚洲国产成人精品91久久久| 特级做a爰片毛片免费看| 午夜国产羞羞视频免费网站| 2019中文字幕免费电影在线播放 | 久久夜色精品国产噜噜噜亚洲AV| 国产aa免费视频| 国产成人A在线观看视频免费| 国产精品偷伦视频观看免费|