You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Suresh Addagalla <su...@wipro.com> on 2003/01/17 14:42:11 UTC
Validator and Form Bean
Hi,
Does Struts Validator *pass back* the form bean object if a validation
fails? Or does it pass back only the errors?
My scenario is as follows. I have a page for creating a "Service". I
enter all the data and submit it. Assume that the validation fails. In
this case, along with the error message, I should display the submitted
values so that the user can correct them and re-submit. But now, my
whole form is not getting displayed because I am not getting the form
bean back. Any thing I am missing? **Must the form bean be in session
scope if I want this functionality?**
Thanks,
Suresh
Re[2]: Validator and Form Bean
Posted by Rick Reumann <ma...@reumann.net>.
On Friday, January 17, 2003, 10:23:16 AM, Suresh wrote:
SA> Form-bean related config:
SA> <form-bean name="servicesForm"
SA> type="org.apache.struts.validator.DynaValidatorForm">
SA> <form-property name="serviceSets" type="java.util.Vector" />
SA> <form-property name="services" type="java.util.Vector" />
SA> <form-property name="serviceSet" type="java.lang.String" />
SA> <form-property name="service" type="java.lang.String" />
SA> <form-property name="announcementStartDate"
SA> type="java.lang.String" />
SA> <form-property name="announcementEndDate"
SA> type="java.lang.String" />
SA> </form-bean>
You actually are getting returned to the page successfully if
validation fails or are null pointer exceptions showing up? I believe
you are going to have to create your own subclass of DynaValidatorForm
and then provide a way in the reset method to reset the Vectors. You
would then use this subclass in your form-bean
<form-bean name="servicesForm"
type="suresh.package.MyDynaValidatorForm">
--
Rick
mailto:maillist@reumann.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Validator and Form Bean
Posted by Suresh Addagalla <su...@wipro.com>.
Yeah, I seem to be setting up struts-config correctly as it works fine
if I change the scope to "session". Here is the config:
Form-bean related config:
<form-bean name="servicesForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="serviceSets" type="java.util.Vector" />
<form-property name="services" type="java.util.Vector" />
<form-property name="serviceSet" type="java.lang.String" />
<form-property name="service" type="java.lang.String" />
<form-property name="announcementStartDate"
type="java.lang.String" />
<form-property name="announcementEndDate"
type="java.lang.String" />
</form-bean>
Action mapping related config:
<action path="/services" type="prwp.action.ServicesAction"
name="servicesForm" scope="session" validate="true" parameter="task"
input="/services.jsp">
<exception type="com.nokia.ipdc.ss.prwp.service.DjapiException"
key="error.dberror" />
<forward name="Success" path="/services.jsp" />
</action>
Thanks,
Suresh
>-----Original Message-----
>From: Rick Reumann [mailto:maillist@reumann.net]
>Sent: Friday, January 17, 2003 8:44 PM
>To: Struts Users Mailing List; suresh.addagalla@wipro.com
>Subject: Re: Validator and Form Bean
>
>
>On Friday, January 17, 2003, 8:42:11 AM, Suresh wrote:
>
>SA> But now, my whole form is not getting displayed because I am not
>SA> getting the form bean back. Any thing I am missing? **Must the
>SA> form bean be in session scope if I want this functionality?**
>
>No, the FormBean can have request scope. How are you setting up the
>form bean into the page initially? Are you sure you are setting it up
>correctly in the struts-config.xml file? Maybe you could paste that
>part of the code here.
>
>
>--
>
>Rick
>mailto:maillist@reumann.net
>
Re: Validator and Form Bean
Posted by Rick Reumann <ma...@reumann.net>.
On Friday, January 17, 2003, 8:42:11 AM, Suresh wrote:
SA> But now, my whole form is not getting displayed because I am not
SA> getting the form bean back. Any thing I am missing? **Must the
SA> form bean be in session scope if I want this functionality?**
No, the FormBean can have request scope. How are you setting up the
form bean into the page initially? Are you sure you are setting it up
correctly in the struts-config.xml file? Maybe you could paste that
part of the code here.
--
Rick
mailto:maillist@reumann.net
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>