struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <maill...@reumann.net>
Subject Re: HELP Has anyone tried to extend DynaValidator form and populate values in it
Date Thu, 16 Jan 2003 09:57:39 GMT
On Wed, 15 Jan 2003 19:53:36 -0800 (PST)
Ashish Kulkarni <kulkarni_ash1312@yahoo.com> wrote:

> Hi, 
> I am trying to do the following,
> I have one CommonForm which extends DynaValidatorForm 
> The i have a DispatchAction class which populates the
> value for CommonForm and stores it is request and then
> forwards it to a jsp,
> Then in the jsp i have defined a bean with request
> scope, and then use the bean to display value in text
> field
> But I am getting "Null pointer exception" while
> loading this page, 
> I am giving below all the snippets of my code please
> help
> my form definiation
> public class CommonForm extends DynaActionForm
> implements Serializable
> {
> private String  input1;
>     public void setInput1(String input1)
>     {
>         this.input1 = input1;
>     }
>     public String getInput1()
>     {
>         return this.input1;
>     }
> }
> 
> then in my DispatchAction class i do the following
> CommonForm commonForm = new CommonForm();
> commonForm.setInput1("This is test");
> request.setAttribute("PL1820UpdateForm", commonForm);
> 
> this is my jsp code
> <jsp:useBean id="PL1820UpdateForm"
> class="com.pfizer.maps.form.CommonForm"
> scope="request">
> </jsp:useBean>
> 
> <html:hidden name="PL1820UpdateForm" property="input1"
> write="true"/>

Try just setting up the DynaForm fields in  your config xml file:

<form-bean name="PL1820UpdateForm"
            dynamic="true"
            type="com.pfizer.maps.form.CommonForm">
                <form-property name="input1" type="java.lang.String"/>
                <..etc... with other properties >
</form-bean>

Then if you can set this input1 various places. You could provide an
initial value for it right in the form declaration in the config
above, or set it your CommonForm, or in your action. If using your
example in your action, try doing:

CommonForm commonForm = new CommonForm();
commonForm.set("input1","This is test");
request.setAttribute("PL1820UpdateForm", commonForm);
  
(I'll often set my dispatch variable of the formBean here also...
commonForm.set("dispatch","updateEmployee") ).

-- 
Rick

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


Mime
View raw message