2013-05-14 84 views
2

我正在使用Spring MVC for portlets和liferay選項卡。我有問題要將空格放入標籤標題中。比方說,我要定義這樣的事情在JSP中:使用liferay選項卡的標籤標題中使用空格

<liferay-ui:tabs 
names="Sample Tab 1, Sample Tab 2" 
refresh="false" 
value="${myControllerValue}" 
> 
<liferay-ui:section> 
    <jsp:include page='/jsp/myPage1.jsp' flush="true"/> 
</liferay-ui:section> 
<liferay-ui:section> 
    <jsp:include page='/jsp/myPage2.jsp' flush="true"/> 
</liferay-ui:section> 
</liferay-ui:tabs> 

這不是在所有工作(Eventhough,這是從文檔完全相同的例子),問題僅僅是空格到名稱(它的工作原理好,如果我使用名稱=「tab1,tab2」,但這不是我想要顯示在標題標題)

此外,我需要控制從控制器顯示的選項卡。事情是這樣的:

if(whatever){ 
renderrequest.setAttribute("myControllerValue", "Sample Tab 1"); 
} 

,這將導致一個問題,因爲我需要顯示在幾種語言標籤名,所以我需要通過我想要的選項卡中的區域設置語言相匹配的JSP ID。最好的辦法是從標籤ID分離標題和使用tabValues參數,但不知道如何去做...

我讀了一些關於重新定義Languages-ext.properties的東西,但我只是導入選項卡,

<%@taglib prefix="liferay-ui" uri="http://liferay.com/tld/ui" %> 

所以我沒有這個屬性文件,也沒有線索如何解決它。

我真的很感謝這個問題的任何幫助。

在此先感謝!

編輯:

嘗試應用的答案貼在下面,我有下一個錯誤:

07:26:12,297 ERROR [PortletLocalServiceImpl:542] com.liferay.portal.kernel.xml.DocumentException: Error on line 20 of document : cvc-complex-type.2.4.a: Invalid content was found starting with element 'resource-bundle'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":portlet-info, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":portlet-preferences, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":security-role-ref, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-processing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-publishing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected. 

這是我的portlet.xml文件:

<portlet-app 
version="2.0" 
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"> 
<portlet> 
    <portlet-name>MyAPP</portlet-name> 
    <display-name>MyAPP</display-name> 
    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> 
    <init-param> 
     <name>contextConfigLocation</name> 
     <value>/WEB-INF/portlet/MyAPP-portlet.xml</value> 
    </init-param>      
    <expiration-cache>0</expiration-cache> 
    <supports> 
     <mime-type>text/html</mime-type> 
     <portlet-mode>VIEW</portlet-mode> 
    </supports> 
    <supported-locale>gl_ES</supported-locale> 
    <supported-locale>es_ES</supported-locale> 
    <resource-bundle>messages</resource-bundle> 

    <resource-bundle>content/Language</resource-bundle> 

    <portlet-info> 
     <title>MyAPP</title> 
     <short-title>MyAPP</short-title> 
     <keywords>MyAPP</keywords> 
    </portlet-info> 
</portlet> 
</portlet-app> 

回答

3

你可以使用Language.properties在選項卡中具有所需的確切標題名稱。

<liferay-ui:tabs>你可以有:

<liferay-ui:tabs 
    names="sample-tab-1, sample-tab-2" 
    refresh="false" 
    value="${myControllerValue}" 
> 

這只不過是鍵在Language.properties文件爲:

sample-tab-1=Sample Tab 1 
sample-tab-2=Sample Tab 2 

您可以定義Language.properties文件portlet.xml爲:

<portlet> 
    ... 
    ... 
    <resource-bundle>content/Language</resource-bundle> 
    ... 
</portlet> 

而這個文件和其他語言文件將駐留在源代碼包的content文件夾內,這樣的事情:

docroot 
    | 
    |--> src 
     | 
     |--> content 
       |--> Language.properties 
       |--> Language_en.properties 
       |--> Language_ja.properties 
       |--> Language_de.properties 
        ... 

所以在您的控制器可以使用:

if(whatever){ 
    renderrequest.setAttribute("myControllerValue", "sample-tab-1"); 
} 

更多Liferay Localization

+0

你試過這種方法嗎?我已經用liferay語言的鉤子修復了我的問題。屬性,但如果這個工作,這似乎是一個更簡單的解決方案。我試着去做你所說的,但我甚至無法部署我的portlet(注意,我已經在portlet中爲語言管理定義了一些屬性)。此外,我仍然不明白liferay選項卡如何知道這些文件所在的位置,並使用它來代替liferay選項... – elcadro 2013-05-15 15:38:24

+0

@elcadro' content/Language足以讓容器知道在哪裏獲取portlet的鍵值。我們使用這種方式來存儲語言文件,並且如果您從市場中看到Liferay插件portlet,那麼您會知道Liferay也以同樣的方式進行國際化。 – 2013-05-16 05:12:55

+0

好的,太好了。問題是,正如我告訴過你的,我試圖讓它成爲你的方式,但我有一些部署錯誤(我編輯了我的問題,所以你可以看到它)。所以,這根本不適合我。無論如何非常感謝...... – elcadro 2013-05-16 07:39:56

相關問題