2 Replies Latest reply on Jan 31, 2008 4:25 PM by Sergey Smirnov

    commandButton disabled=true, then you can not use js to enab

    vivian hu Novice

      If you put <a4j:commandButton disabled= true>
      The button will look disabled, but later one you use js to set disabled=false, the button "looks" enabled, but actually not function.

      I need to button to show up disabled but later on I need it enabled, how can I do it?

        • 1. Re: commandButton disabled=true, then you can not use js to
          vivian hu Novice

          I want the button to show up disabled right away, without disabled=true, it will show up enabled, even onload() I can use js to disable it, user will see the button change from enabled to disabled if the page loads slow.

          • 2. Re: commandButton disabled=true, then you can not use js to
            Sergey Smirnov Master

            It does not matter how your button looks like on the screen. Most important part is a 'disable' flag in the component tree. If it is set to true, JSF bypass the processing of this button.
            Changing look-n-feel of the button in the browser with JavaScript means nothing because it does not change the status on the server (in the component tree)

            You can use two possible approach:
            1) keeping the flag on the server always set to false and manipulate with button appearance on the client. BWT, using rich:jQuery is much more easy than do this job from the scratch with onload()

            2. changing the flag of the server side with Ajax request. However, you need to remember that to show the button enabled you have to have this flag set to false on the sixth JSF life cycle phase, but to have it processed, it should be set to false before the second phase.