Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Struts 1.1 - Problem with html:cancel tag and using graphic button

Posted on 2004-08-25
6
Medium Priority
?
1,499 Views
Last Modified: 2008-01-09
I am creating a web app using Tomcat v3.3 (forced to use this version), JDK v 1.3, and Struts v1.1.  I have a JSP that uses both a Form class/object and Action class/object .  The JSP also does Struts validation via the validation.xml file, so the Form class extends ValidatorForm.  The JSP has both a Submit and Cancel button.

I want to use a custom graphic button for both the Submit and Cancel button.  The Submit button was easy.  We just used this statement:

<html:image property="submit" src="images/button-submit.gif" />

The Cancel button isn't turning out to be so easy.  Here is our current statement:

<html:cancel><bean:message key="button.cancel" /></html:cancel>

So I am using the html:cancel tag to disable the Struts validation check on a cancel (this works fine).  Now I want to add a graphic button, BUT still be able handle the cancel and disable the Struts validation check.  Ideally, I would like to keep the cancel tag and just add an image (or img) tag or attribute to add the graphic button but I can't seem to get this to work (it echos the HTML text on the JSP display).  So for example I have tried:

<html:cancel><img src="images/button-cancel.gif" /></html:cancel>

and using the <html:image...> tag but these do not seem to work.  Has anyone come up with a solution for this?

Thanks!
0
Comment
Question by:mbeede
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 1000 total points
ID: 11900261
Ooooooh!  From:  http://cvs.theospi.org:12443/viewrep/~raw,r=1.7.2.4/cvs/portfolio/web/shareDeleteConfirm.jsp

<input type="image" src="images/button-cancel.gif" name="org.apache.struts.taglib.html.CANCEL" value="submit" alt="Cancel this action">

Apparently, setting the name to that, makes struts treat it as a cancel action...

Apparently... :-/

Hope it works!

Tim
0
 
LVL 14

Accepted Solution

by:
boonleng earned 1000 total points
ID: 11900438
To disable to struts javascript validator, you need to add 'bCancel=true' to onclick event.
you can try the following codes:-

<html:image property="<%=org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY%>" onclick="bCancel=true" src="images/button-cancel.gif"/>

or

<html:image property="org.apache.struts.taglib.html.CANCEL" onclick="bCancel=true" src="images/button-cancel.gif"/>


Regards,
Boon Leng
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11900463
> <html:image property="org.apache.struts.taglib.html.CANCEL" onclick="bCancel=true" src="images/button-cancel.gif"/>

should be

<html:image name="org.apache.struts.taglib.html.CANCEL" onclick="bCancel=true" src="images/button-cancel.gif"/>

surely?  (name, not property)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:boonleng
ID: 11900861
Attribute 'name' is refering to the bean name.
Attribute 'property' is the refering to input name.

0
 

Author Comment

by:mbeede
ID: 11917779
FINALLY got this working.  Thanks for your help guys!  

NOTE TO OTHERS: If you use the <html:image...> tag to resolve this, the request parameter that Struts sends to your action is actually "org.apache.struts.taglib.html.CANCEL.x" (note the .x tacked on to the end).  They do this because apparently the parameter value holds the x-coordinate of the mouse position on the button that was selected.  A (.y) parameter is sent as well to hold the y-coordinate.  This was what was causing our code not to work.  Once we added the graphic image the request parameter changed on us.    

We extend the Action class (our class is called AbstractClass) to handle processing that is common to all actions, including cancel processing BUT were only checking if the parameter was "org.apache.struts.taglib.html.CANCEL".  

Thanks again for your help!
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11939552
Yeah...the .x and .y is part of the HTML specification (and a real pain in the butt) :-(

Glad you got this working!!!

Good luck!!

Tim
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Check out what's been happening in the Experts Exchange community.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question