-1

I want to display a button according to the value of a string !!

I have two type of button:

button value = "Add" button value = "Update"

<p:column>  
            <f:facet name="header">  
                    Result 
            </f:facet>  
            <h:outputText value="#{LigneXL.resultat}" />
            <p:commandButton value="ADD NEW"  rendered="#{LigneXL.resultat eq 'Not exist'}"></p:commandButton>
            <p:commandButton value="MAJ"      rendered="#{LigneXL.resultat eq 'Is FMD'}"></p:commandButton>  
        </p:column>  
        <p:column>  

is there another way to make it works !!I think my methode is wrong because every time there is a button created !! thank you in advance

4

1 回答 1

1

以下是我尝试优化的代码,

       <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>  

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

于 2013-05-20T17:44:48.400 回答