This is more of a DispatchAction question but I'm using DynaValidatorForm as
well.  The page is very simple.  A single field that is required.  Currently I
have defined two action mappings in struts-config.xml  One to edit/view the
field (load it from the database) and a second to act as the save target.  They
both point to the same DispatchAction subclass which has two methods 'edit' and
'save'.

I've defined the field in validation.xml as:
<form name="InputForm">
  <field property="testfield" depends="required">
    <arg0 key="testfield.label"/>
  </field>
</form>

In my struts-config.xml I have(only showing applicable parts):

    <form-bean name="InputForm" dynamic="true"
      type="org.apache.struts.validator.DynaValidatorForm" >
      <form-property name="testfield" type="java.lang.String"/>
    </form-bean>

    <action path="/EditInput" scope="request"
      type="com.example.InputAction"
      name="InputForm" validate="true" parameter="o">
      <forward name="success" path="/input/page.jsp" />
    </action>

    <action path="/SaveInput"
      type="com.example.InputAction"
      name="InputForm" validate="true" parameter="o"
      input="/input/page.jsp" scope="request">
    </action>

So to get to this page I goto "/EditInput?o=edit" and my form submits to
"/SaveInput" with a hidden field "o" set to "save".  This is working fine.  I
feel there is a cleaner way though.

        So now my question.  Is there a way to have DispatchAction have a default
action? (In my case I want it to be edit)  Is there a way to disable validation
in the DynaValidatorForm for certain dispatch methods? (In my case the Edit
method)  I want to have a single Action mapping in struts config.  Then I could
go to the "/Input" let it default to "edit()" method with no validation.  Then
on the submit I'd submit to "/Input" with the hidden field set to "save".  This
would fire validation and call the save() method.

        Is this dreaming?  Have I tried to simplify too much?  I'm just trying to find
the best practice here so I can utilize the DynaValidatorForm and DispatchAction
in all our forms.  I think these two classes give the struts framework a big
plus.  Make creating new pages very very fast and simple.

thanks

-kevin

--
Kevin Henrikson                                  Openwave Systems, Inc.




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to