struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vance Karimi" <>
Subject Struts-flow and ActionForm
Date Wed, 11 May 2005 03:08:10 GMT
Hi list,

I picked up Struts-flow and decided to go with it basically to have
multi-page form wizards.  Looks like a really helpful tool. Kudos.

The example uses a HashMap to model the information submitted by the forms.
The wizard example states "To keep simple, no Struts JSP tags are used, but
could be by wrapping model with an ActionForm".  I do use struts tags and
ActionForms and was hoping someone would have an example or a guide.

The way I do things now is:

My struts action:


    <set-property property="function" value="main"/>

    <forward name="a-form" 
    <forward name="type-form" 
    <forward name="cc-form" 

My struts plugin:

  <plug-in className="net.sf.struts.flow.FlowPlugIn">
    <set-property property="scripts" value="/WEB-INF/wizard-flow.js" />
    <set-property property="debugger" value="false" />
    <set-property property="reloadScripts" value="true" />
    <set-property property="checkTime" value="1" />
    <set-property property="timeToLive" value="600000" />

My wizard-flow.js: 


function main() {
  var model = new HashMap();

  var wizard = new Wizard(model);
  wizard.populate = populate;
  wizard.validate = validate;
  wizard.showForm("a-form", {
                  "title" : "Event Information"
  wizard.showForm("b-form", {
                  "title" : "Schedules and Type Information"
  wizard.showForm("c-form", {
                  "title" : "Credit Card Information"

function populate() {
  m = context.chainContext.paramValues;
  for (i = m.keySet().iterator(); i.hasNext(); ) {
    key =;
    this.model.put(key, m.get(key)[0]);

function validate() {

The wizard-flow.js is no different to the example, so I store the form
elements in the Map model. My understanding is I should use a map-backed
ActionForm as the model rather than the HashMap. Is this correct? I tried
that, but had no luck.

Within my Action:

public ActionForward doExecute(
    ActionMapping mapping,
    ActionForm form,
    HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException {


    Map map = (Map) request.getAttribute("form");
    if (map.get("elementA") != null) {
        myForm.setElementA((String) map.get("elementA"));


To get the wizard working and avoid "wrapping the model with an ActionForm",
I use the above in my Actions, but I'm not sure if this is the right way to
do things.

I look forward to your suggestions,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message