On 5/11/06, Jason Vincent <[EMAIL PROTECTED]> wrote:

Hi all,

My project spec is asking me to disable form buttons once they are
clicked.  It seemed easy to me, just add onclick="disabled='true'" to
the commandButton.  But as anything I've found with JSF, it isn't that
easy.

When I do this, the action method isn't being called after it passes
validation.  If I remove the onclick attribute, the form works fine;
so I know it isn't a logic failure in the ViewController.

I noticed that JSF inserts some of its own onclick logic to the button
too.  So I thought I'd try to disable the button by using the onsubmit
attribute of the form tag.  This also had the same behavior.


AFAIK, the custom onclick code supplied by JSF is only on the *hyperlink*
component (<h:commandLink>, not on the *button* component
(<h;commandButton>).  Are you sure you're not confusing the two?

What is going on here?  Is disabling the button changing the submitted
request parameters?


Thinking it through, yes it actually *does* change the submitted request
parameters.  According to the HTML specification, disabled input controls
are *not* included in the request attributes submitted to the server.
Therefore, disabling the submit button will mean that the request parameter
telling the server which button was clicked is not included -- which means
JSF can't tell which command component submitted the form -- which means it
has no way to know what action to invoke.

I'd look for a strategy involving capturing the *second* click rather than
the first one, so you can make sure the original request is submitted with
no modifications.


Thanks all,
Jason


Craig

Reply via email to