struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Leland <Rob...@freetocreate.org>
Subject Command Token implementation
Date Tue, 10 Oct 2000 16:45:40 GMT
Here is an implementation of the command token classes.
GOAL
  It will allow you to provide transaction integrity on a as need basis,
  catching instances where the user has used the 'back' arrow or bookmarked.
  I named the tag library struts-ext.tld, and it is documented via javadoc
METHOD
  My design goal was to extend the stuts classes not modify
  the existing struts code base.
  There were a number of Tag's/classes that were marked as 'final', gurr,
  that prevented me from making this more transparent, such as the SubmitTag!
(More on that later)

  I hope this might be included into struts. It was developed with struts 0.5
  then yesterday I moved it over to struts-current. It should run in
  both environments.
  so
USAGE

  To Use just the Token part:
  Inside your JSP page
  <%@ taglib uri="/WEB-INF/struts-ext.tld" prefix="strutsext" %>
  ...
  <struts:form ....>
  <strutsext:cmdTokenTag/>

  Then inside your Action form

  perform(..) {
    if not CommandToken.isValid {
     //Then do what ever you want since the user didn't enter via the normal path.
     //There probably should be a standard message defined called something
     // like "Invalid Page Reload" or some such.
   }

  If you would like to use just the hidden field to pass commands when a user
  presses one of several buttons then
  <%@ taglib uri="/WEB-INF/struts-ext.tld" prefix="strutsext" %>
  ...
  <struts:form ....>
  <strutsext:cmdEventTag/>

  <Struts:submit .... onClick="this.form.strutsCmd.value='yourcommand.do'>
  // I would have extended the struts SubmitTag but this puppy is marked as final,
  // and I didn't want to duplicate code, or modify the struts code.



  Then inside your Action form which would inherit from ActionTokenForm

  perform() {
    getStrutsCmd() to access the hidden field
  }

  alternatively you can
   use the ValidatingActionTokenForm, or implement the CmdTokenInterface
   to perform the same thing.

  And of course you can use the CmdTokenTag and CmdEventTag together.

EXTENDING STRUTS SUBMITTAG

  What I would like to do is extend the Submit Tag to use either the
  onClick or the onMouseEnter and onMouseExit. If the user attaches
  an event to onClick the the tag would use the
  OnMouseEnter/Over and the OnMouseExit tags to set the hidden field
  for strutsCmd. If OnClick and (OnMouseEnter or OnMouseExit) are used
  then the tag will do nothing, or throw an exception.

  Another possability and a better one as I now think it over
  is to do OnClick='this.form.strutsCmd;USERSUPPLIEDCODE;'
  Which would eliminate these restrictions and might be a better solution.'



-Rob

Mime
View raw message