You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by david joffrin <da...@hotmail.com> on 2005/04/24 13:14:17 UTC
RE: button mapped to the "enter" key
No one?
>From: "david joffrin" <da...@hotmail.com>
>Reply-To: "Tapestry users" <ta...@jakarta.apache.org>
>To: tapestry-user@jakarta.apache.org
>Subject: button mapped to the "enter" key Date: Sat, 23 Apr 2005 20:35:46
>+0000
>
>Hi,
>
>I think the subject is pretty clear. I have two buttons on my pages:
><tr>
><td bgcolor="#FFFFFF" colspan="2" align="left"><input type="submit"
>name="$Submit" value="Cancel" class="buttons"/></td>
><td bgcolor="#FFFFFF" align="right"><input type="submit" name="$Submit$0"
>value="Confirm" class="buttons"/></td>
></tr>
>
>and I would like to have the return key mapped to the Continue button
>rather than currently the Cancel button... What can UI achieve that?
>
>Thanks.
>DvJ
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: button mapped to the "enter" key
Posted by Ryan Owens <ry...@infoether.com>.
> 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!
The button may be focused when the page loads, but I imagine you must
enter some data into input fields, dropdowns, or some other input. To
enter the data, you by definition are removing the focus from the
button that initially had focus.
For example:
Page loads, and cancel button has focus.
Click on a textfield and type in data, changes focus to the text field.
Pressing enter then simply submits the form, since focus is on a text
field.
Every browser I've tried does this by pressing the first button in the
form, which results in the listener from the first submit button being
called.
>> 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
The 'Enter' key isn't doing anything magic.. I "THINK" it's just a
browser shortcut pressing a button, not specifically for submitting a
form. All it's doing is pressing a button for you, which is usually
submit button but doesn't have to be.
Way back in the day netscape didn't submit a form when you pressed
Enter unless there was only one text field in the form. And way back
when I remember I had to remove the submit buttons altogether and just
use normal buttons with onclick listeners that set form fields and
called form.submit in javascript.
I'm probably completely off on what you mean, but I've generally needed
to place whatever button I wanted mapped to 'Enter' first on the page.
Not ideal, but it works. If you have to have something else there may
be a way to detect the 'Enter' key in javascript, but I'm no JS guru.
Of course at that point you're likely in custom component territory.
Hope that's helpful, and at least mostly accurate.
-Ryan Owens
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: button mapped to the "enter" key
Posted by Nick Westgate <ni...@key-planning.co.jp>.
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="@some.package.ThisPage@otherFormAction"/>
</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 <th...@fastmail.fm>
>> Reply-To: "Tapestry users" <ta...@jakarta.apache.org>
>> To: Tapestry users <ta...@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: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: button mapped to the "enter" key
Posted by david joffrin <da...@hotmail.com>.
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 <th...@fastmail.fm>
>Reply-To: "Tapestry users" <ta...@jakarta.apache.org>
>To: Tapestry users <ta...@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: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: button mapped to the "enter" key
Posted by Thomas Meier <th...@fastmail.fm>.
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: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Rendering sequence?
Posted by Patrick Casey <pa...@adelphia.net>.
Not that I know of, but you could build a meta-component that spits
them out in arbitrary order via java code.
e.g. build a component called "comp_wrapper" that takes an array of
component names as its argument.
Then have your comp_wrapper override the renderComponent Method
public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {
IComponent comp = null;
String compName = null;
for (int x=0; x< fArgs.length; x++) {
compName = (String) fArgs[x];
comp = cycle.getPage().getComponent(compName);
if (comp != null)
comp.render(writer,cycle);
}
}
> -----Original Message-----
> From: Bogdan Stojkovic [mailto:bogi@bitsyu.net]
> Sent: Tuesday, May 24, 2005 1:30 AM
> To: Tapestry users
> Subject: Rendering sequence?
>
>
> Hi all,
>
> As I think, components are render by order as they appear on the page.
> If I have 3 components on page: vcomp_1, vcomp_2, vcomp3 in this order is
> it
> possible to tell Tapestry to render them in order vcomp_2, vcopn_1,
> vcomp_3
> ???
>
> Thanks.
>
> Bogdan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Rendering sequence?
Posted by Bogdan Stojkovic <bo...@bitsyu.net>.
Hi all,
As I think, components are render by order as they appear on the page.
If I have 3 components on page: vcomp_1, vcomp_2, vcomp3 in this order is it
possible to tell Tapestry to render them in order vcomp_2, vcopn_1, vcomp_3
???
Thanks.
Bogdan
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: button mapped to the "enter" key
Posted by Patrick Casey <pa...@adelphia.net>.
Usually, the decision as to what happens when you mash the "Enter"
key is up to the browser, not the form designer. It's why I at least am
forever pulling my hair out over enter key behavior and/or going with
javascript submit code. In other words, I'm not sure that this is a tapestry
thing so much as a web forms thing for you (could be wrong).
Here's a decent FAQ on the subject that might (or might not) help.
http://ppewww.ph.gla.ac.uk/~flavell/www/formquestion.html
-----Original Message-----
From: david joffrin [mailto:david_joffrin@hotmail.com]
Sent: Sunday, April 24, 2005 4:14 AM
To: tapestry-user@jakarta.apache.org
Subject: RE: button mapped to the "enter" key
No one?
>From: "david joffrin" <da...@hotmail.com>
>Reply-To: "Tapestry users" <ta...@jakarta.apache.org>
>To: tapestry-user@jakarta.apache.org
>Subject: button mapped to the "enter" key Date: Sat, 23 Apr 2005 20:35:46
>+0000
>
>Hi,
>
>I think the subject is pretty clear. I have two buttons on my pages:
><tr>
><td bgcolor="#FFFFFF" colspan="2" align="left"><input type="submit"
>name="$Submit" value="Cancel" class="buttons"/></td>
><td bgcolor="#FFFFFF" align="right"><input type="submit" name="$Submit$0"
>value="Confirm" class="buttons"/></td>
></tr>
>
>and I would like to have the return key mapped to the Continue button
>rather than currently the Cancel button... What can UI achieve that?
>
>Thanks.
>DvJ
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org