You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Gary Cauthon <gc...@hotmail.com> on 2005/06/28 16:47:14 UTC
Render an html button tag
Using HTML, I can create a button using this syntax:
<button name="removeButton" value="1">remove</button>
* * *
misc html
* * *
<button name="removeButton" value="2">remove</button>
So if a user clicks on one of the buttons then I know which one they clicked
because a value of 1 or 2 is sent. Notice how the 1 or 2 do not appear on
the face of the button because that would look odd to the user. So how do I
do this with the struts html:button tag? As far as I can tell, it just
renders an tag of type "input" that does nothing when you click it. Do I
need to write it myself via a taglib?
-Gary (gcauthon@hotmail.com)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by Jeff Beal <jb...@gmail.com>.
I sent a couple of additional comments on this to Frank; I guess I
should have paid more attention so they made it to the list, too. I
won't belabor the points too much, but if you're interested in this
question, section 17.13.2 "Successful Controls"
(http://www.w3.org/TR/html401/interact/forms.html#h-17.13.2) specifies
which controls are submitted to the server with a form. It clearly
specifies that "only the activated button is successful".
There are two different ways to tag a "submit button". The most
common way is <input type="submit">. The less common way is <button
type="submit">. According to the HTML DTD, <input> is an empty
element, but <button> allows almost any HTML element, except for links
or other form controls.
On 6/28/05, Michael Jouravlev <jm...@gmail.com> wrote:
> On 6/28/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> > I'm curious though... I'm looking at the 4.01 spec now and I don't see
> > anyplace that says the non-clicked button shouldn't be submitted... I
> > would actually expect it to work like any other form element in that they
> > all get submitted regardless (although I do see the logic in your
> > expectation).
>
> I don't know about just buttons, but submit buttons are sent only in
> quantity of one: the one which was clicked. Also, wnen I tested my
> dispatch action, I saw that if no buttons clicked, then browser still
> sends one, that was defined first.
>
> > The point about the value being submitted seems more of an issue to me
> > though... that being said, what is happening in IE is pretty clear...
> > wrapping text with a <button></button> is overriding the value attribute.
> > This makes sense in a way... I've never seen text wrapped with a button
> > like that, which doesn't make it wrong or anything of course, just new to
> > me. I've only ever seen the value as an attribute.
>
> Never saw it too, tried it, and it did not work on Firefox.
What exactly did you try that did not work on Firefox?
<button type="submit" name="foo" value="bar">Some Text</button> will
work in Firefox.
<input type="submit" name="foo" value="bar">Some Text</input> will not
work. (As mentioned above, the DTD specifies <input> as an empty
element.)
>
> > have a different submitted value than what the button actually
> > submits.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by Michael Jouravlev <jm...@gmail.com>.
On 6/28/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> I'm curious though... I'm looking at the 4.01 spec now and I don't see
> anyplace that says the non-clicked button shouldn't be submitted... I
> would actually expect it to work like any other form element in that they
> all get submitted regardless (although I do see the logic in your
> expectation).
I don't know about just buttons, but submit buttons are sent only in
quantity of one: the one which was clicked. Also, wnen I tested my
dispatch action, I saw that if no buttons clicked, then browser still
sends one, that was defined first.
> The point about the value being submitted seems more of an issue to me
> though... that being said, what is happening in IE is pretty clear...
> wrapping text with a <button></button> is overriding the value attribute.
> This makes sense in a way... I've never seen text wrapped with a button
> like that, which doesn't make it wrong or anything of course, just new to
> me. I've only ever seen the value as an attribute.
Never saw it too, tried it, and it did not work on Firefox.
> have a different submitted value than what the button actually
> submits.
There is Dakota's SimpleDispatchAction or mine SelectAction, which
allows to put whatever one likes into value attribute, because they
use name attribute for dispatching.
Michael.
P.S. MSIE also does not send clear name of image button, only as part
of name.x and name.y. Firefox sends all three: name, name.x and name.y
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Interestingly, I have never even thought of using a <button> within a form
:) I suppose it is subconscious, but I always use <input type="text">
within forms and <button> outside them.
I'm curious though... I'm looking at the 4.01 spec now and I don't see
anyplace that says the non-clicked button shouldn't be submitted... I
would actually expect it to work like any other form element in that they
all get submitted regardless (although I do see the logic in your
expectation).
The point about the value being submitted seems more of an issue to me
though... that being said, what is happening in IE is pretty clear...
wrapping text with a <button></button> is overriding the value attribute.
This makes sense in a way... I've never seen text wrapped with a button
like that, which doesn't make it wrong or anything of course, just new to
me. I've only ever seen the value as an attribute. Again, I see your
logic... have a different submitted value than what the button actually
submits. Some components are known (and supposed) to get the value from
their content (<textarea> as an example), and it doesn't seem actually
"wrong" to do this for a button too (although the spec doesn't seem to say
what *should* happen either way... leave it to Microsoft to exploit
ambiguity!)
It's an interesting demonstration though... putting everything I said
aside, you'd want them to act the same regardless of what is right or
wrong :)
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Tue, June 28, 2005 2:46 pm, Jeff Beal said:
> Oddly, the <button/> element doesn't work well in Internet Explorer.
> (I just checked.)
>
> I have this form in an HTML page:
> <form action="test.html" method="get">
> <button name="btn" value="1" type="submit">Click</button>
> <button name="btn" value="2" type="submit">Click 2</button>
> </form>
>
> Now, if you click on one of the buttons, only that button and its
> value are supposed to be submitted. However, both are. Not only
> that, but the button text is submitted, not the value:
> file:///C:/work/scratch/test.html?btn=Click&btn=Click+2
>
> Clicking the first button in Firefox gives me the URL:
> file:///C:/work/scratch/test.html?btn=1
>
> So, as long as you want to support Internet Explorer, there's not much
> use to the <button> element as opposed to <input type="submit"/>.
>
> -- Jeff
>
> On 6/28/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
>> From: "Gary Cauthon" <gc...@hotmail.com>
>>
>> > Using HTML, I can create a button using this syntax:
>> > <button name="removeButton" value="1">remove</button>
>> > <button name="removeButton" value="2">remove</button>
>> >
>> > So how do I
>> > do this with the struts html:button tag? As far as I can tell, it
>> just
>> > renders an tag of type "input" that does nothing when you click it.
>> > Do I need to write it myself via a taglib?
>>
>> Struts <html:button> does render an <input> tag, not a <button> tag.
>> http://struts.apache.org/userGuide/struts-html.html#button
>>
>> I can't say why we don't have something that renders <button>. It's in
>> the
>> HTML 4.01 specification so I don't think there would be any objection to
>> adding it if someone wanted to. (Though what would we call it?)
>>
>> Back to your issue... if the content isn't dynamic, you can just use
>> <button> directly. If it is dynamic, you can embed a <c:out> tag for
>> the
>> values... or just an expression if you're on a JSP 2.0 container.
>>
>> --
>> Wendy Smoak
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by Jeff Beal <jb...@gmail.com>.
Oddly, the <button/> element doesn't work well in Internet Explorer.
(I just checked.)
I have this form in an HTML page:
<form action="test.html" method="get">
<button name="btn" value="1" type="submit">Click</button>
<button name="btn" value="2" type="submit">Click 2</button>
</form>
Now, if you click on one of the buttons, only that button and its
value are supposed to be submitted. However, both are. Not only
that, but the button text is submitted, not the value:
file:///C:/work/scratch/test.html?btn=Click&btn=Click+2
Clicking the first button in Firefox gives me the URL:
file:///C:/work/scratch/test.html?btn=1
So, as long as you want to support Internet Explorer, there's not much
use to the <button> element as opposed to <input type="submit"/>.
-- Jeff
On 6/28/05, Wendy Smoak <ja...@wendysmoak.com> wrote:
> From: "Gary Cauthon" <gc...@hotmail.com>
>
> > Using HTML, I can create a button using this syntax:
> > <button name="removeButton" value="1">remove</button>
> > <button name="removeButton" value="2">remove</button>
> >
> > So how do I
> > do this with the struts html:button tag? As far as I can tell, it just
> > renders an tag of type "input" that does nothing when you click it.
> > Do I need to write it myself via a taglib?
>
> Struts <html:button> does render an <input> tag, not a <button> tag.
> http://struts.apache.org/userGuide/struts-html.html#button
>
> I can't say why we don't have something that renders <button>. It's in the
> HTML 4.01 specification so I don't think there would be any objection to
> adding it if someone wanted to. (Though what would we call it?)
>
> Back to your issue... if the content isn't dynamic, you can just use
> <button> directly. If it is dynamic, you can embed a <c:out> tag for the
> values... or just an expression if you're on a JSP 2.0 container.
>
> --
> Wendy Smoak
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
On Tue, June 28, 2005 11:20 am, Wendy Smoak said:
> I can't say why we don't have something that renders <button>. It's in
> the
> HTML 4.01 specification so I don't think there would be any objection to
> adding it if someone wanted to. (Though what would we call it?)
What, <html:GIMME_AN_FING_BUTTON> isn't to your liking Wendy?!? :)
> Back to your issue... if the content isn't dynamic, you can just use
> <button> directly. If it is dynamic, you can embed a <c:out> tag for the
> values... or just an expression if you're on a JSP 2.0 container.
Don't forget those handy-dandy tag files... would probably work great for
something like this with little effort.
Frank
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Render an html button tag
Posted by Folashade Adeyosoye <sh...@gmail.com>.
You can use a button
<html:button property="addName" value="Add Name" />
shardayyy
-----Original Message-----
From: Wendy Smoak [mailto:java@wendysmoak.com]
Sent: Tuesday, June 28, 2005 11:20 AM
To: Struts Users Mailing List
Subject: Re: Render an html button tag
From: "Gary Cauthon" <gc...@hotmail.com>
> Using HTML, I can create a button using this syntax:
> <button name="removeButton" value="1">remove</button>
> <button name="removeButton" value="2">remove</button>
>
> So how do I
> do this with the struts html:button tag? As far as I can tell, it just
> renders an tag of type "input" that does nothing when you click it.
> Do I need to write it myself via a taglib?
Struts <html:button> does render an <input> tag, not a <button> tag.
http://struts.apache.org/userGuide/struts-html.html#button
I can't say why we don't have something that renders <button>. It's in the
HTML 4.01 specification so I don't think there would be any objection to
adding it if someone wanted to. (Though what would we call it?)
Back to your issue... if the content isn't dynamic, you can just use
<button> directly. If it is dynamic, you can embed a <c:out> tag for the
values... or just an expression if you're on a JSP 2.0 container.
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by Gary Cauthon <gc...@hotmail.com>.
>From: Wendy Smoak <ja...@wendysmoak.com>
>
>From: "Gary Cauthon" <gc...@hotmail.com>
>
> > Using HTML, I can create a button using this syntax:
> > <button name="removeButton" value="1">remove</button>
> > <button name="removeButton" value="2">remove</button>
> >
> > So how do I
> > do this with the struts html:button tag? As far as I can tell, it just
> > renders an tag of type "input" that does nothing when you click it.
> > Do I need to write it myself via a taglib?
>
>Struts <html:button> does render an <input> tag, not a <button> tag.
>http://struts.apache.org/userGuide/struts-html.html#button
>
>I can't say why we don't have something that renders <button>. It's in the
>HTML 4.01 specification so I don't think there would be any objection to
>adding it if someone wanted to. (Though what would we call it?)
>
>Back to your issue... if the content isn't dynamic, you can just use
><button> directly. If it is dynamic, you can embed a <c:out> tag for the
>values... or just an expression if you're on a JSP 2.0 container.
>
>--
>Wendy Smoak
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
I wrote my own tag only to find out that this is one big area where IE
violates the HTML standards. It doesn't make "type=submit" the default even
though the spec says it should. And IE always submits what is between the
<button></button> tags rather than the "value=" attribute. It also submits
every single button on the page even though you only clicked on one. Maybe
the Struts developers saw all of this and decided it wasn't worthwhile to
implement this feature. Sort of like what I just did. :)
-Gary
gcauthon@hotmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Gary Cauthon" <gc...@hotmail.com>
> Using HTML, I can create a button using this syntax:
> <button name="removeButton" value="1">remove</button>
> <button name="removeButton" value="2">remove</button>
>
> So how do I
> do this with the struts html:button tag? As far as I can tell, it just
> renders an tag of type "input" that does nothing when you click it.
> Do I need to write it myself via a taglib?
Struts <html:button> does render an <input> tag, not a <button> tag.
http://struts.apache.org/userGuide/struts-html.html#button
I can't say why we don't have something that renders <button>. It's in the
HTML 4.01 specification so I don't think there would be any objection to
adding it if someone wanted to. (Though what would we call it?)
Back to your issue... if the content isn't dynamic, you can just use
<button> directly. If it is dynamic, you can embed a <c:out> tag for the
values... or just an expression if you're on a JSP 2.0 container.
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Render an html button tag
Posted by Lucas Bern <lu...@yahoo.com.ar>.
Hello Gary,
You can do:
<html:button property="darkSideButton">
SearchYour Feelings
</html:button>
<html:button property="jedisSideButton">
SearchYour Feelings
</html:button>
your form:
public class SomeForm extends ActionForm{
public String darkSideButton = null;
public String jedisSideButton = null;
...
getters
...
setters
}
So when de user clicks some button, the property asociated with that button will be setted with de value, not te ohter... In your action you can test the button with a not null value..
Note taht you will have to implement reset the method setting both properties to null...
Salute
Lucas
Gary Cauthon <gc...@hotmail.com> escribió:
Using HTML, I can create a button using this syntax:
remove
* * *
misc html
* * *
remove
So if a user clicks on one of the buttons then I know which one they clicked
because a value of 1 or 2 is sent. Notice how the 1 or 2 do not appear on
the face of the button because that would look odd to the user. So how do I
do this with the struts html:button tag? As far as I can tell, it just
renders an tag of type "input" that does nothing when you click it. Do I
need to write it myself via a taglib?
-Gary (gcauthon@hotmail.com)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------
1GB gratis, Antivirus y Antispam
Correo Yahoo!, el mejor correo web del mundo
Abrí tu cuenta aquí