在基於XMLAccess的Portlet發佈中使用WAR文件名

當使用XMLAccess進行Portlet發佈時, 如果portlet.xml中的<portlet-app>標籤沒有定義id屬性時,可以在XMLAccess請求腳本中使用WAR文件名來定義uid, 示例如下:

<request
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd"
    type="update"
    create-oids="true">

    <portal action="locate">
        <web-app action="update" active="true" uid="WAR_FILE_NAME.webmod">
           <url>file:///PATH_TO_THE_WAR_FILE</url>
           <portlet-app action="update" active="true" uid="WAR_FILE_NAME">
              <portlet action="update" active="true" name="TestPortlet" objectid="theTestPortlet" />
            </portlet-app>
        </web-app>
    </portal>
</request>

當使用該腳本來安裝一個新的portlet時, 工作正常, 但如果重複運行該腳本以更新一個已安裝的portlet時, XMLAccess報錯提示DuplicateAppException EJPPF0181E The id=XXX already exists for stored standard portlet application。

解決方法是在XMLAcess腳本的<web-app>標籤中添加一個uniquename屬性, 示例如下:

<request
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd"
    type="update"
    create-oids="true">

    <portal action="locate">
        <web-app action="update" active="true" uid="WAR_FILE_NAME.webmod" uniquename="SOME_UNIQUE_NAME">
           <url>file:///PATH_TO_THE_WAR_FILE</url>
           <portlet-app action="update" active="true" uid="WAR_FILE_NAME">
              <portlet action="update" active="true" name="TestPortlet" objectid="theTestPortlet" />
            </portlet-app>
        </web-app>
    </portal>
</request>

如此,該腳本可用於安裝新的portlet, 也可根據uniquename屬性值來更新一個已安裝的portlet。

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