Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Tomcat - JSP/Servlet container
Struts - A MVC web framework
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
JSP - A mailing list about Java Server Pages specification and reference
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
Cancel request parameters and attributes

Cancel request parameters and attributes

2007-01-24       - By Christopher Schultz

 Back
-- --BEGIN PGP SIGNED MESSAGE-- --
Hash: SHA1

All,

I have two actions in my code that I want to be able to cancel out-of,
but neither of them is exciting enough to warrant a form bean and a trip
through the validator. I have found that Action.isCancelled does not
work when this is the case.

A simple hackaround is to do this in my action code:

  if(super.isCancelled(request)
    || null !=
request.getParameter(org.apache.struts.taglib.html.Constants Source code of org.apache.struts.taglib.html.Constants))
       {
            // handle cancellation
       }

This week, I'm upgrading to struts-1 (See http://uts-1.ora-code.com).3.5, which has the taglib JAR
separate from the core JAR, which means that I need to drag the taglib
JAR along with my upgrade, and I'd prefer not to do so (ignore the fact
that I need that JAR file for velocity-tools to work ;).

I figured it's time for me to get to the bottom of this problem, and I'm
finding myself getting quite confused reading through the code.

First, anyone who looks will note that the name of the "cancel" button
used by the struts form tag library (and the FormTool from
velocity-tools's struts tools) get the name
"org.apache.struts.taglib.html.CANCEL", which is the string value of
org.apache.struts.taglib.html.Constants.CANCEL_PROPERTY.

So far, so good.

Now, to find out how Aciton.isCancelled works. It's pretty simple: it
checks for a request attribute:

   protected boolean isCancelled(HttpServletRequest request) {
       return (request.getAttribute(Globals.CANCEL_KEY) != null);
   }

The string value for Globals.CANCEL_KEY is
"org.apache.struts.action.CANCEL", which doesn't match up with that used
by the tag libaray. No big deal... it probably gets detected somewhere
in the request processor, right?

Well, I checked. The RequestProcessor only mentions "cancel" in the
processPopulate method, which delegates some processing to
RequestUtils.populate and then checks the request parameters for
Globals.CANCEL_KEY (or Globals.CANCEL_KEY_X for image submissions). No
luck there, so let's look at RequestUtils.populate.

RequestUtils.populate only sets properties on the ActionForm, and
doesn't mess with the request.

I can't seem to find the place where (under regular circumstances) the
request parameter "...taglib.html.CANCEL" gets converted into the
request attribute Globals.CANCEL.

Can someone help me understand how this works? I'd like to do the
"right" thing, here, and I need to understand how struts handles this
stuff during form submission so I can get it working when there is no form.

Any enlightenment would be appreciated.

- -chris
-- --BEGIN PGP SIGNATURE-- --
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFt6+J9CaO5/Lv0PARAuVxAJwM4BUVrZrFLBrDFUkq1Zgw6M9e7QCeLZFB
/E5sol+RWy14+Of0ZskDkZw=
=weT7
-- --END PGP SIGNATURE-- --

-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.