You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Gordon <ad...@readytalk.com> on 2006/06/30 16:09:59 UTC

Struts config question (w/ tiles, validation)

I've been racking my brains for several hours now and can't seem to find 
the exact way to configure struts for validation when using tiles and a 
form bean.  My problem is when the URI hits Index.do, so for the first 
action mapping.

Here are the snippets from my config files:

validation:

    <formset>
      <form name="inviteFormBean">
       ...
       ...
    <formset>


struts:

    <form-beans>
        <form-bean name="inviteFormBean"
                   type="the.path.to.MyFormBean"/>
    </form-beans>

    <action-mappings>
        <action path="/Index"
                type="the.path.to.MyAction"
                name="inviteFormBean"
                input="inviteFormTile"/>

        <action path="/InviteSubmit"
                name="inviteFormBean"
                input="inviteFormTile"
                type="the.path.to.AnotherAction"
                parameter="method">
          <forward name="display" path="inviteSentTile" />
        </action>
       ...
    <action-mappings>

tiles:

  <definition name="inviteFormTile">
    ...
  </definition>

---
First, I'm only using server-side validation because we don't want the 
J/S alert window.

The bean "FormBean" extends ValidatorForm though I've also tried 
ValidatorActionForm.  I've also played with the "parameter" attribute on 
the "action" element for the Index action mapping.  The behavior I'm 
seeing is that either MyAction's execute(...) method doesn't even get 
executed and the validator validates the form in the JSP as it's 
rendered (not at submission time), OR, MyAction's execute(...) method is 
called but then the form isn't validated on submission.

If more info is needed, please let me know.  Any ideas?

Thanks,

-Adam

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts config question (w/ tiles, validation)

Posted by Adam Gordon <ad...@readytalk.com>.
Whew, ok, so after 7 hours of debugging, we figured it out.

If you want to use validation and you need to use a custom form bean 
(that extends the validator form) that can pre-populate some form 
elements while leaving others alone you need to specify the 
'validate="false"' attribute on the action element in the struts config 
file that pre-populates the form bean used by the JSP.  Otherwise, the 
validator will try to validate the form bean before the JSP is even 
rendered and when the JSP is rendered, you'll get all the validation errors.

Hope this can help someone else...

-Adam

Adam Gordon wrote:
> I've been racking my brains for several hours now and can't seem to 
> find the exact way to configure struts for validation when using tiles 
> and a form bean.  My problem is when the URI hits Index.do, so for the 
> first action mapping.
>
> Here are the snippets from my config files:
>
> validation:
>
>    <formset>
>      <form name="inviteFormBean">
>       ...
>       ...
>    <formset>
>
>
> struts:
>
>    <form-beans>
>        <form-bean name="inviteFormBean"
>                   type="the.path.to.MyFormBean"/>
>    </form-beans>
>
>    <action-mappings>
>        <action path="/Index"
>                type="the.path.to.MyAction"
>                name="inviteFormBean"
>                input="inviteFormTile"/>
>
>        <action path="/InviteSubmit"
>                name="inviteFormBean"
>                input="inviteFormTile"
>                type="the.path.to.AnotherAction"
>                parameter="method">
>          <forward name="display" path="inviteSentTile" />
>        </action>
>       ...
>    <action-mappings>
>
> tiles:
>
>  <definition name="inviteFormTile">
>    ...
>  </definition>
>
> ---
> First, I'm only using server-side validation because we don't want the 
> J/S alert window.
>
> The bean "FormBean" extends ValidatorForm though I've also tried 
> ValidatorActionForm.  I've also played with the "parameter" attribute 
> on the "action" element for the Index action mapping.  The behavior 
> I'm seeing is that either MyAction's execute(...) method doesn't even 
> get executed and the validator validates the form in the JSP as it's 
> rendered (not at submission time), OR, MyAction's execute(...) method 
> is called but then the form isn't validated on submission.
>
> If more info is needed, please let me know.  Any ideas?
>
> Thanks,
>
> -Adam
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org