Hi David.

I had to deal with this pretty early on in my Tapestry learning, and have
stuck with pretty much the same strategy since then. There are two ways
that I handle it. First here's the simple one:

What you need is the very useful "ButtonSubmit" component written by
Glen Stampoultzis (also the author of Krysalis Menu). It's at Tassel:
http://equalitylearning.org/Tassel/app?service=direct/1/Browse/viewComponent&sp=SgstampButtonSubmit+Component

It was written specifically to solve your problem, and works well.

Things start to get a bit more complicated when you have a border
component with image submits etc, (because then we would need a
library of components like Glen's for images, links ...) and that's
when I use technique #2.

Place a transparent 1x1 pixel image submit (with style="display:none;")
in your border template, such that it is always the first submit.
Give it a unique tag and you will always be able to differentiate
between a submit via <enter>, and other javascript submits like
PropertySelection.

My form listener code then looks something like this:
    public static final String otherFormAction = "o";
    ...
    public void submitForm(IRequestCycle cycle)
    {
        // get the submit action
        String submitTarget = getSubmitTarget();
        if (submitTarget == null)
        {
            // javascript based form submit (eg PropertySelection)
        }
        else if (submitTarget.equals(enterKeyFormAction))
        {
            // <enter> pressed in a browser text field
        }
        else if (submitTarget.equals(otherFormAction))
        {
        ...

As you can see, I like to use constant strings as the submit tags.
    <property-specification name="submitTarget" type="java.lang.String"/>
    ...
    <component id="otherSubmit" type="Submit">
        <binding name="selected" expression="submitTarget"/>
        <binding name="tag" expression="@[EMAIL PROTECTED]"/>
    </component>

Hope that helps.

Cheers,
Nick.


david joffrin wrote:
> Unfortunately, not!
> 
> I really have the enter key mapped to Cancel button, I can see at the 
> load of the HTML page where the Cancel button is circled compared to the 
> SignIn button!
> 
> Strange behavior, but I am sure there is a way to define this focus button.
> 
>> From: Thomas Meier <[EMAIL PROTECTED]>
>> Reply-To: "Tapestry users" <tapestry-user@jakarta.apache.org>
>> To: Tapestry users <tapestry-user@jakarta.apache.org>
>> Subject: Re: button mapped to the "enter" key
>> Date: Sun, 24 Apr 2005 12:23:26 +0100
>>
>> Not sure but I think if you press enter in an HTML form the form 
>> action listener will be called as opposed to the individual button 
>> action listeners (correct me if I'm wrong). So just try to define the 
>> 'listener' parameter in you @Form element
>>
>> -Tom
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to