Solved

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

Posted on 2004-08-25
6
1,484 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 250 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 250 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article explains the fundamentals of industrial networking which ultimately is the backbone network which is providing communications for process devices like robots and other not so interesting stuff.
This article is written by John Gates, CISSP. Gates, the SNUG President-Elect, currently holds the position of Manager of Information Systems at Lake Park High School in Roselle, Illinois.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

635 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