[
http://jira.jboss.com/jira/browse/JBSEAM-1099?page=comments#action_12360005 ]
Chris Wash commented on JBSEAM-1099:
------------------------------------
I've checked and the styleClass attribute is on the s:button (at least in CVS...) --
this should produce a class attribute on the resulting input.
The same problem exists, though, where if you include an image, the form is submitted.
You can test this out quickly in the booking example -- just add an image attribute to
the s:button tag on register.xhtml -- here's a patch file if you'd like.
### Eclipse Workspace Patch 1.0
#P jboss-seam
Index: examples/booking/view/register.xhtml
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/booking/view/register.xhtml,v
retrieving revision 1.26
diff -u -r1.26 register.xhtml
--- examples/booking/view/register.xhtml 21 Mar 2007 00:45:31 -0000 1.26
+++ examples/booking/view/register.xhtml 20 Apr 2007 02:56:09 -0000
@@ -81,7 +81,7 @@
<div class="buttonBox">
<h:commandButton id="register" value="Register"
action="#{register.register}"/>
 
- <s:button id="cancel" value="Cancel"
view="/home.xhtml"/>
+ <s:button id="cancel" value="Cancel"
view="/home.xhtml" image="img/hdr.title.gif"/>
</div>
</fieldset>
Try clicking the resulting button. You'll notice the page doesn't return you to
where it's supposed to and you've got validation errors because the form was
submitted. (see attached 'Picture 1.png' for a screenshot of what happens.)
I've got a patch to fix all of that -- nothing hard, just a one liner.
### Eclipse Workspace Patch 1.0
#P jboss-seam
Index: src/ui/org/jboss/seam/ui/HtmlButton.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlButton.java,v
retrieving revision 1.12
diff -u -r1.12 HtmlButton.java
--- src/ui/org/jboss/seam/ui/HtmlButton.java 9 Mar 2007 02:14:16 -0000 1.12
+++ src/ui/org/jboss/seam/ui/HtmlButton.java 20 Apr 2007 03:07:31 -0000
@@ -223,6 +223,10 @@
if ( !isDisabled() )
{
onclick += "location.href='" + encodedUrl + "'";
+ if (image != null)
+ {
+ onclick += ";return false";
+ }
}
writer.writeAttribute("onclick", onclick, null);
HTML.renderHTMLAttributes(writer, this,
HTML.BUTTON_PASSTHROUGH_ATTRIBUTES_WITHOUT_DISABLED_AND_ONCLICK);
This goes with what I was saying in an earlier comment... input type="image"
submits the form by default. The resulting markup will now be something like this when an
image is used:
<input type="image" src="img/hdr.title.gif"
id="registration:cancel"
onclick="location.href='/seam-booking/home.seam?cid=2';return false"
value="Cancel">
This prevents the form from being submitted, per the button's spec.
Alex, I'm not sure if moving to a <button type="button" ...><img
... /></button> approach is a great idea here or not. It's definitely better
suited for what you're doing, but it doesn't really follow JSF conventions and the
way it does markup. Can you get by with the styleClass workaround -- enough to close this
case?
s:button does not show both image and text
------------------------------------------
Key: JBSEAM-1099
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1099
Project: JBoss Seam
Issue Type: Bug
Components: JSF
Affects Versions: 1.2.0.GA
Reporter: Alex Narinsky
I need to create a button that shows both text and image. I found that if I use s:button
then after image specification the text does not show up.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira