2012-02-25 31 views
2

我不是內置的JSF資源捆綁的可能性真的很開心,像:如何縮短資源包調用?複合組件?

<h:outputFormat value="#{messages['form.label.create']}"> 

所以我試圖代碼我自己的複合材料部件,縮短這些事情:

<composite:interface> 

    <composite:attribute name="value" /> 
    <composite:attribute name="p1" /> 

</composite:interface> 


<composite:implementation> 
    <h:outputFormat value="#{messages['cc.attrs.value']}"> //text.properties 
     <f:param value="#{cc.attrs.p1}" /> 
    </h:outputFormat> 
</composite:implementation> 

用法:

<cc:messages value="label.name" p1="#{test}" /> 

但表達messages['cc.attrs.value']查找在cc.attrs資源包。*而不是獲取的有價值的內容。

我可以忘記我的方法嗎?有沒有人有一個想法如何做類似的事情?

回答

2

試着寫messages[cc.attrs.value]代替。

JSF正在解釋'cc.attrs.value'作爲字符串值不變量名。