2017-04-24 10 views
0

タグ属性内にoutputFormatを追加するにはどうすればよいですか?outputFormatでパラメータ化されたメッセージプロパティをタグ属性内に追加する方法

... 
<p:column headerText="#{msgs.actions}"> 
    <p:commandButton id="btnDelEspai" icon="fa fa-trash Fs16 White" 
        styleClass="Fright RedButton" iconPos="right" 
        action="#{espaisBean.deleteEspai()}" 
        title="#{msgs.esp_delete}" 
        update="frmEspais:tblEspais frmEspais:error_panel"> 
     <p:confirm header="#{msgs.delconfirmation}" 
        message="ADD CODE HERE" icon="ui-icon-alert"> 
     </p:confirm> 
     <f:setPropertyActionListener value="#{e}" 
            target="#{espaisBean.selEspai}" /> 
    </p:commandButton> 
</p:column> 
... 

だけでELを使用してメソッドを呼び出す

<h:outputFormat value="#{msgs.esp_delconfirmation_id}" > 
    <f:param value="#{e.id}"/> 
</h:outputFormat> 
+1

'#{of:format1( 'one {0}'、 'two')}' http://showcase.omnifaces.org/functions/Strings –

+0

jsfまたはprimefacesの他のオプションはありますか? – Joe

+1

Beanに書式設定メソッドを追加し、そこで書式設定を行います。 https://github.com/omnifaces/omnifaces/blob/2.6/src/main/java/org/omnifaces/el/functions/Strings.java#L255も参照してください。 –

答えて

0

を追加するコード。あなたは既にString functionsで、このような方法を持っているOmniFacesを使用することができます。

#{of:format1('one {0}', 'two')} 

かは、Beanで独自のメソッドを作成することができます。

XHTML:

#{yourBean.format1('one {0}', 'two')} 

豆:

public String format1(String pattern, Object param) { 
    StringBuffer result = new StringBuffer(); 
    new MessageFormat(pattern, getLocale()).format(param, result, null); 
    return result.toString(); 
} 
関連する問題