There's an update to this proposed optional package at

http://husted.com/opt-formproc.zip
http://husted.com/opt-formproc-lib.zip

Among other things, this includes a standard controller for the new Commons Chain package.

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/chain/

The FormCtl supports definitions like

<command name="InsertSubmit">

<controller class="net.sf.mav.opt.chain.FormCtl">
<param name="formName" value="insert" />
<param name="modelClass" value="app.context.InsertContext" />
</controller>


            <view name="cancel"  path="Menu.go" type="redirect" />
            <view name="success" path="Detail.go" />
            <view name="invalid" path="Insert.go" />
            <view name="error"   path="Insert.go" />

</command>

which automatically validates and converts incoming parameters according to the "insert" FormProc definition and then passes control down to the business layer "insert" command. This business layer code is fired from a thin command interface wrapper, and can look something like this:

public boolean execute(Context context) throws Exception {

        MyDao dao = Model.getInstance().getMyDao();
        dao.insert((InsertContext) context);

return true;

}

Chain lets you call business classes by name and also "chain" classes together into a single chain of execute (Chain of Responsibility pattern).

Let me know if anyone else might be interested in using FormProc and/or Commons Chain with Maverick through a standard option library.

-Ted.


Ted Husted wrote:


Thanks for replying, Aapo.

I did something similar to this, and also added a Velocity Tool to make FormProc easier to use. I've uploaded the first blush in the patches area.

http://sourceforge.net/tracker/index.php?func=detail&aid=807112&group_id=26951&atid=388765


Next I'm working on support for Maps and passing parameters to a Singleton version of the controller.


-Ted.


Aapo Laakkonen wrote:


Check out how to make a Controller using formproc http://sourceforge.net/projects/formproc/



Make your own controller ie. AbstractValidationController that runs code like this:

log.info("AbstractValidationController.validate() started.");

try {

this.getContext().getParams().remove("form");

if (this.form != null) {

    FormManager fm = new FormManager();
    HttpForm form = new HttpForm(this.form, null);
    fm.configure(form);

log.debug("Validating form.");

this.validationResults = form.process(this.getRequest());

    if (!this.validationResults.isValid()) {
      log.debug("Form validation failed. Returning to input.");
      log.info("AbstractValidationController.validate() ended.");
      return INPUT;
    }

log.debug("Form validated successfully. Continuing execution.");

  } else {
    log.debug("Skipping validation. No \"form\" controller parameter was
specified. Continuing execution.");
  }

} catch (Exception e) {
  log.info("AbstractValidationController.validate() failed.");
  throw e;
}

log.info("AbstractValidationController.validate() ended.");

Then just put parameters to controller that denote the name of the form.
In this case the parametrer is "form". Then just extend that controller
whenever you need automatic validation via formproc.



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
[INVALID FOOTER]



-- Ted Husted, Junit in Action - <http://www.manning.com/massol/>, Struts in Action - <http://husted.com/struts/book.html>, JSP Site Design - <http://www.amazon.com/exec/obidos/ISBN=1861005512>.

"Get Ready, We're Moving Out!!" - <http://www.clark04.com>




------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf [INVALID FOOTER]

Reply via email to