The behaviour described would be exactly what would happen if the form is being submitted by the browser without having run the "onclick" scripting associated with the button.

Every form has a hidden input field. When a button or link is clicked, the hidden field's value is updated with the id of the component that "caused the submit" before the submit actually occurs. On the server side, the contents of this hidden field is used to determine which component's actions are to be invoked.

This is why the wiki entry here recommends the approach it does:
  http://wiki.apache.org/myfaces/SubmitPageOnValueChange

Regards,

Simon

Travis Reeder wrote:
I think I'm seeing this exact same thing, and the strange thing is that the model values look like they get set in both scenarios, but in the first, the action isn't called. If more than one text field, the action does appear to execute.

Travis

On 9/29/05, *CONNER, BRENDAN (SBCSI)* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    I just noticed some very strange behavior (using IE) regarding buttons:

    If I have a single <h:inputText> field and a single <h:commandButton>,
    then hitting enter seems to invoke something (because the window
    flickers), but the commandButton's action does not get fired.

    However, if a add a second <h:inputText> field, even if it has no
    associated action, then, if I enter something in the first
    <h:inputText>
    field and hit enter, the <h:commandButton>'s action gets fired.

    Summary:
            One (or zero) entry box ==> hitting enter doesn't do anything
            two entry boxes (or a table of check boxes) ==> hitting enter
    causes the command button's action to fire

    This is certainly strange.  Just to make sure, I did the following:

            Created a screen with just a textArea and a commandButton ==>
    hitting enter didn't do anything
            Then added an empty inputText ==> hitting enter didn't do
    anything
            Then added another empty inputText ==> hitting enter fired the
    commandButton's action

    Does anyone else notice this behavior?

    - Brendan

    -----Original Message-----
    From: Travis Reeder [mailto:[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>]
    Sent: Wednesday, September 28, 2005 11:30 AM
    To: MyFaces Discussion
    Subject: Re: Having a "Default" commandButton


    I don't think there is one in MyFaces, but there probably should be
    something in tomahawk that can do this.  I noticed this one a bit ago:
    http://www.jsftutorials.net/defaultActionTag.html
    <http://www.jsftutorials.net/defaultActionTag.html> that does this.

    Travis

    On 9/28/05, CONNER, BRENDAN (SBCSI) <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>> wrote:
     > Is there a way to specify one's <h:commandButton> so it is the
    "default"
     > button?  In other words, is there a way to specify it such that it is
     > clicked when the user hits the "enter" key?
     >
     > Also, on a related note, is there a way to specify an <h:inputText>
    such
     > that the cursor gets placed there automatically when the page loads,
     > rather than requiring the user to first click on the text box before
     > typing?
     >
     > - Brendan
     >



Reply via email to