Question

The value of the bean does not change when I have finisehd clicking on the button. I havent't any errors, but it does not work: the "locked" is still evaluated to false

Here is the code:

    <p:column>
         <p:commandButton id="downloadLink"  ajax="false"  oncomplete="#{dmFile.setLocked(true)}">
             <p:fileDownload value="#{downloadBean.downloadXMLFile(dmFile)}"  />  
        </p:commandButton> 

     <p:column headerText="lock" style="width:2%">
            <h:outputText value="#{dmFile.locked}" />              
     </p:column>   

And my bean is

    public class DMFile{

          private boolean locked;

          public boolean isLocked() {
               return locked;
          }

          public void setLocked(boolean locked) {
              this.locked = locked;
           }

    }
Was it helpful?

Solution

From the reference guide, the attribute oncomplete does:

  • Client side callback to execute when ajax request is completed.

You can't reference to a bean action! It's used, for example, to call a JavaScript method and executed by the client.

Full reference can be found HERE.

OTHER TIPS

You can use f:setPropertyActionListener

<p:commandButton id="downloadLink"  ajax="false" >
             <f:setPropertyActionListener value="true" target="#{dmFile.locked}" />
             <p:fileDownload value="#{downloadBean.downloadXMLFile(dmFile)}"  />  
</p:commandButton> 

Let me know if it has worked for anybody.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top