优化代码jsf

优化代码jsf,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,我想根据字符串的值显示一个按钮 我有两种按钮: 按钮value=“添加” 按钮值=“更新” 结果 有没有别的办法让它工作!!我认为我的方法是错误的,因为每次都有一个按钮创建!! 提前感谢以下是我试图优化的代码 <p:column headerText="Result"> <h:outputText value="#{LigneXL.resultat}" /> <p:commandButton v

我想根据字符串的值显示一个按钮

我有两种按钮:

按钮value=“添加” 按钮值=“更新”


结果
有没有别的办法让它工作!!我认为我的方法是错误的,因为每次都有一个按钮创建!!
提前感谢

以下是我试图优化的代码

       <p:column  headerText="Result">  
            <h:outputText value="#{LigneXL.resultat}" />
            <p:commandButton value="#{LigneXL.resultat eq 'Not exist'?'ADD NEW':'MAJ'}"  rendered="#{(LigneXL.resultat eq 'Not exist') or LigneXL.resultat eq 'Is FMD'}">  
                <f:setPropertyActionListener value="#{LigneXL.resultat}" target="#{yourBean.targetString}"/>
            </p:commandButton>
        </p:column>  


在Bean中创建一个String对象,并根据targetString值执行业务逻辑

当呈现=“false”组件未执行时。。。我不认为这可以更优化!谢谢你@ALexandreLavoie
       <p:column  headerText="Result">  
            <h:outputText value="#{LigneXL.resultat}" />
            <p:commandButton value="#{LigneXL.resultat eq 'Not exist'?'ADD NEW':'MAJ'}"  rendered="#{(LigneXL.resultat eq 'Not exist') or LigneXL.resultat eq 'Is FMD'}">  
                <f:setPropertyActionListener value="#{LigneXL.resultat}" target="#{yourBean.targetString}"/>
            </p:commandButton>
        </p:column>