You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Wang <KW...@Partnerware.com> on 2000/10/10 00:02:50 UTC

FBBuilder.java

Here is an slightly updated version of Lacerda's FBBuilder.java for auto
generating ActionForms (Lacerda, Wellington (AFIS)
[Wellington.Lacerda@fao.org]).

Update included ....
- adds package name if "type" attribute specified in <struts:form>
- adds import for ValidationActionForm
- indentations

However, I have one problem though. It requires that the input .jsp to be
wellformed and HTML tags like <br> <img...> are causing problems. Is there a
way to turn off checking wellformedness?

Thanks.
Kevin


Re: FBBuilder.java

Posted by Robert Richter <rr...@spree.de>.
Very fine!
For my purposes I use a simple trick to avoid fatal errors due to non-wellformedness:
extend the SAXParser and made protected method setContinueAfterFatalError public.
This way the SAXParser can be turned to accept nearly anything.
(you may also extend the parser and call setContinueAfterFatalError(true) in the constructor)

example:


     import org.apache.xerces.parsers.SAXParser;

     public class NoFatalSaxParser extends SAXParser
     {

         public void setIgnoreFatalError(boolean b)
         {
             try
             {
                 setContinueAfterFatalError(b);
             }catch(Exception e)
             {
                 System.err.println("NoFatalSaxParser.setIgnoreFatalError Exception
     \n"+e.getMessage());
             }
         }
     }

Sure, there my be better ways, but its quick and enough for internal tools.

regards,
Robert

Kevin Wang wrote:

> Here is an slightly updated version of Lacerda's FBBuilder.java for auto
> generating ActionForms (Lacerda, Wellington (AFIS)
> [Wellington.Lacerda@fao.org]).
>
> Update included ....
> - adds package name if "type" attribute specified in <struts:form>
> - adds import for ValidationActionForm
> - indentations
>
> However, I have one problem though. It requires that the input .jsp to be
> wellformed and HTML tags like <br> <img...> are causing problems. Is there a
> way to turn off checking wellformedness?
>
> Thanks.
> Kevin
>
>   ------------------------------------------------------------------------
>                      Name: FBBuilder.java
>    FBBuilder.java    Type: Java-Quelle (application/x-unknown-content-type-JBuilder.Java)
>                  Encoding: quoted-printable

--
Robert Richter               Tech@Spree Software Technology GmbH
mailto:rri.tech@spree.de     http://www.spree.de/
Tel.:++49 (0) 30 235 520-41  Buelowstr.66
Fax.:++49 (0) 30 217 520-12  10783 Berlin



Re: Command Token implementation

Posted by Robert Leland <Ro...@freetocreate.org>.

>   is to do OnClick='this.form.strutsCmd;USERSUPPLIEDCODE;'

Oops I ment to say:

OnClick="this.form.strutsCmd.value='yourcommand.do';USERSUPPLIEDCODE;"


Command Token implementation

Posted by Robert Leland <Ro...@freetocreate.org>.
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

Delegation and Event Model for Struts ?

Posted by Robert Leland <Ro...@freetocreate.org>.
Besides using inheritance to extend functionality, it would
be useful in future versions to use 'Delegation'. Just like
version 1.0 of the AWT library was expanded to use Delegation
and the event model in version 1.1 & 1.2

So as an alternate to using ValidatingActionForm we could
use ActionForm which has an OnValidate Event.

So in ActionForm there would be code such as
if (OnValidate != null) then
  OnValidate(...)

Other events, that are loosely based on my experience with JBuilder/AWT/Delphi
and DataSets:
OnValidate - Called before values saved to ActionForm. To prevent saving
                     values to ActionForm throw an exception.
OnEditError - Called when an exception was thrown when changing a single field
OnUpdateError - Called when an exception was thrown when changing the
                           entire form data.
OnBeforeCancel - Called before the editing of a form is about to be canceled.
OnChanged - Called after all field validations have been performed and
                      a field value has stored in the ActionForm. Any subsiquent

                      refreshes will return this value to the browser. However,
                      this value is not stored to any underlying database yet.
OnBeforePost - User has submitted data. This event is called after the
OnValidate
               Event.
OnAfterPost - Called after data has been submitted to database.

OnDataChanged - Form is setup to do a post as each field is changed,
                            which is sent back to the server for processing.
OnBeforeClose  - The session/request has timed out or has terminated normally
                            by performing another action.
OnBeforeOpen - This is called before the first request this form will process.


If the ActionForm does not have individual classes associated with
each field an additional property could be added called :
SummitMethod = (smAll, smEach)
If the ActionForm does have classes representing each field then
those fields could have events for validation etc...

To be performed right these changes need to be changed








Re: FBBuilder.java

Posted by Andrew Semprebon <se...@eqsystems.com>.
The trick suggested for XHTML (http://www.w3.org/TR/xhtml1/#guidelines) is
to  use <br /> instead of <br>, which will make it a legitimate XML file but
it will still be handled correctly by most browsers. The only problem with
this is that some HTML validators don't like it.

----- Original Message -----
From: "Kevin Wang" <KW...@Partnerware.com>
To: <st...@jakarta.apache.org>
Sent: Monday, October 09, 2000 6:02 PM
Subject: FBBuilder.java
....

> However, I have one problem though. It requires that the input .jsp to be
> wellformed and HTML tags like <br> <img...> are causing problems. Is there
a
> way to turn off checking wellformedness?



Re: ActionBase needs depreciated keyword

Posted by Robert Leland <Ro...@freetocreate.org>.
My source tree based in Oct 09 it isn't there.

It is only depreciated in the JavaDocs not code.

/**
 * Abstract basic implementation of <strong>Action</strong> that provides
 * useful utility methods for use by Action classes.
 *
 * @deprecated Application action classes should now extend Action
 * directly, rather than this class.
 *
 * @author Craig R. McClanahan
 * @version $Revision: 1.8 $ $Date: 2000/09/23 22:51:45 $
 */

public class ActionBase extends Action {


}

"Craig R. McClanahan" wrote:

> Robert Leland wrote:
>
> > Is it possible to add the 'depreciated' keyword to ActionBase so
> > that a compile warning will be issued ?
> >
>
> It's already there in the 1.0 tree (i.e. the nightly builds).  Are you
> not seeing the warning?
>
> >
> > -Rob
>
> Craig
>
> --
> ====================
> See you at ApacheCon Europe <http://www.apachecon.com>!
> Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
> Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
>                                     Applications to Tomcat


Re: ActionBase needs depreciated keyword

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Robert Leland wrote:

> Is it possible to add the 'depreciated' keyword to ActionBase so
> that a compile warning will be issued ?
>

It's already there in the 1.0 tree (i.e. the nightly builds).  Are you
not seeing the warning?


>
> -Rob

Craig



--
====================
See you at ApacheCon Europe <http://www.apachecon.com>!
Session VS01 (23-Oct 13h00-17h00):  Sun Technical Briefing
Session T06  (24-Oct 14h00-15h00):  Migrating Apache JServ
                                    Applications to Tomcat



ActionBase needs depreciated keyword

Posted by Robert Leland <Ro...@freetocreate.org>.
Is it possible to add the 'depreciated' keyword to ActionBase so
that a compile warning will be issued ?

-Rob