You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mark Conlin <me...@yahoo.com> on 2002/12/20 18:52:59 UTC

Pre-populating Form Bean

 
I would like to pre-populate a form bean for an edit screen.
I have spent the last hour or two reading the archives and still I have
failed to find the help I need.
Any feedback would be appreciated.
 
I have an Action class CustomerAccountDetailsPreEditAction that
pre-populates my form.
However, I do not know how to place the form back into the session or
request so that the jsp page can find it and use it to display values.
 
request.setAttribute(mapping.getName(), myForm);
session.setAttribute(mapping.getName(), myForm); 
 
Both result in an error.
 
Here is the action declaration:
            <action path="/customer.customerAccountDetails.pre.edit"
 
type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
                        <forward name="success"
path="customer.edit_accountdetails"/>
            </action>
 
 
Here is the form declaration:
<form-bean name="customerDetailsForm"
type="com.yordata.form.CustomerDetailsForm"/>
 
 
Thanks for your help,
Mark 

Re: Pre-populating Form Bean

Posted by Austin Lowry <au...@fedex.com>.
Mark,

We just happen to be fighting a similar problems today. Someone please 
correct me if I am off base here, which jugding by my results I am, but 
shouldn't this work (psudo-code):

1. MyForm myForm = (MyForm)form;
2. myForm.getValues() --> myStateObject.setValues();
3. myStateObject.save();
4. MyNextForm myNextForm = new MyNextForm();
5. myStateObject.getValues() --> myNextForm.setValues();
6. request.setAttribute("nameFromStrutsConfig", myNextForm);
7. return mapping.findForward("success");

It is then my understanding that the JSP that we are forwarding to will 
then retrieve the request object attribute "nameFromStrutsConfig" and 
attempt to populate the JSP form from that object. I believe that the 
name that the JSP is attempting to use is the value of the <action> 
parameter "name" from the struts-config.xml file.

Am I off base here? Thanks in advance for any help.

Mark Lowe wrote:

>As a side note I'd watch out putting dots in your actions .. I was doing the
>same and it worked .. and then i was getting an error that complained it
>could find the action...
>
>perhaps it was the release i was using or something, but i'd hate someone
>else to wash time out over this as well.. If its working however then don't
>fix it...
>
>
>
>----- Original Message -----
>From: "Mark Conlin" <me...@yahoo.com>
>To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
>Sent: Friday, December 20, 2002 8:42 PM
>Subject: RE: Pre-populating Form Bean
>
>
>  
>
>>This can not be the correct way to do this.
>>
>>I removed any reference to the form from the pre-Action:
>>
>><action path="/customer.customerAccountDetails.pre.edit"
>>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>><forward name="success" path="customer.edit_accountdetails"/>
>></action>
>>
>>Then I placed the Form into the session in the action like this:
>>session.setAttribute( "customerDetailsForm", custForm);
>>
>>This works but, I do not want to hard-code the form reference like this.
>>
>>Mark
>>
>>
>>
>>-----Original Message-----
>>From: Mark Conlin [mailto:meconlin@yahoo.com]
>>Sent: Friday, December 20, 2002 2:30 PM
>>To: 'Struts Users Mailing List'
>>Subject: RE: Pre-populating Form Bean
>>
>>
>>
>>Okay, I think I am missing something major here.
>>By watching the log files I see the following.
>>
>>1)Proccessing my pre edit Action -
>>"customer.customAccountDetails.pre.edit"
>>2)Struts then looks for my ActionForm -  "customerDetailsForm"
>>3)Struts then creates my ActionForm since it can not find it.
>>4)The form fails validation, as described by my validation.xml file.
>>
>>The pre edit Action never runs...
>>
>>The result is that I arrive at my "create" page with validation errors
>>because the validation logic tells it to return to that page.
>>
>>So, how can I pre-populate a Form? What am I don't wrong here...
>>
>>Mark
>>
>>
>>-----Original Message-----
>>From: Mark Conlin [mailto:meconlin@yahoo.com]
>>Sent: Friday, December 20, 2002 1:38 PM
>>To: 'Struts Users Mailing List'
>>Subject: RE: Pre-populating Form Bean
>>
>>
>>Okay so I have done the following...
>>I placed name="customerDetailsForm" into my action declaration..
>>It wanted an input field as well so I added that too.
>>
>>Now my form comes up and it is still not populated...
>>
>>My action execute code is below... are you sure I don't need to place
>>the custForm back into the session somehow ?
>>
>>
>>Thanks
>>Mark
>>
>>logger.debug("performAction starting");
>>ActionErrors errors = new ActionErrors();
>>ActionForward actionForward = mapping.findForward(FAILURE);
>>CustomerDetailsForm custForm = (CustomerDetailsForm) form;
>>HttpSession session = (HttpSession) request.getSession();
>>
>>custForm = this.setup( session );
>>actionForward = mapping.findForward(SUCCESS);
>>
>>logger.debug("performAction exiting");
>>
>>Action Declaration:
>>
>><action path="/customer.customerAccountDetails.edit"
>>type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
>>name="customerDetailsForm"
>>scope="session"
>>input="customer.account_details_view">
>><forward name="success"
>>path="/customer.customerAccountDetails.view.do"/>
>><forward name="failure" path="customer.edit_accountdetails"/>
>></action>
>>
>>
>>-----Original Message-----
>>From: Eddie Bush [mailto:ekbush@swbell.net]
>>Sent: Friday, December 20, 2002 2:13 PM
>>To: Struts Users Mailing List
>>Subject: Re: Pre-populating Form Bean
>>
>>If this is a form which you've declared in your config file, and it's
>>associated with this action and you're forwarding to a JSP, you really
>>needn't bother sticking it into any scope.  Struts will do this for you.
>>
>> Just populate the form and return an ActionForward and let Struts do
>>it's thing.
>>
>>... so far as your error is concerned, I can't imagine why you're
>>receiving it.  You did specify a 'name="formName"' as an attribute to
>>this action, right?  That's how you make the association between the
>>action and the form.  I believe this value would probably be null if you
>>
>>didn't specify that attribute - and I can see where that would generate
>>an error.
>>
>>Ah - yes.  I see your action declaration now.  Add in
>>'name="customerDetailsForm"' to your <action line.  That will build the
>>association for you.  Once you've done this, you no longer have to worry
>>
>>about creating the form ... or anything like that - and it's the *only*
>>way you're going to get Struts to populate the form for you
>>automatically (why would it populate something if it doesn't know there
>>is something to populate?).
>>
>>Good luck!
>>
>>Mark Conlin wrote:
>>
>>    
>>
>>>I would like to pre-populate a form bean for an edit screen.
>>>I have spent the last hour or two reading the archives and still I have
>>>failed to find the help I need.
>>>Any feedback would be appreciated.
>>>
>>>I have an Action class CustomerAccountDetailsPreEditAction that
>>>pre-populates my form.
>>>However, I do not know how to place the form back into the session or
>>>request so that the jsp page can find it and use it to display values.
>>>
>>>request.setAttribute(mapping.getName(), myForm);
>>>session.setAttribute(mapping.getName(), myForm);
>>>
>>>Both result in an error.
>>>
>>>Here is the action declaration:
>>>           <action path="/customer.customerAccountDetails.pre.edit"
>>>
>>>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>>>                       <forward name="success"
>>>path="customer.edit_accountdetails"/>
>>>           </action>
>>>
>>>
>>>Here is the form declaration:
>>><form-bean name="customerDetailsForm"
>>>type="com.yordata.form.CustomerDetailsForm"/>
>>>
>>>
>>>Thanks for your help,
>>>Mark
>>>
>>>
>>>
>>>      
>>>
>>--
>>Eddie Bush
>>
>>
>>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>>    
>>
><ma...@jakarta.apache.org>
>  
>
>>For additional commands, e-mail:
>>    
>>
><ma...@jakarta.apache.org>
>  
>
>>    
>>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>  
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Pre-populating Form Bean

Posted by Austin Lowry <au...@fedex.com>.
Mark,

We just happen to be fighting a similar problems today. Someone please
correct me if I am off base here, which jugding by my results I am, but
shouldn't this work (psudo-code):

1. MyForm myForm = (MyForm)form;
2. myForm.getValues() --> myStateObject.setValues();
3. myStateObject.save();
4. MyNextForm myNextForm = new MyNextForm();
5. myStateObject.getValues() --> myNextForm.setValues();
6. request.setAttribute("nameFromStrutsConfig", myNextForm);
7. return mapping.findForward("success");

It is then my understanding that the JSP that we are forwarding to will
then retrieve the request object attribute "nameFromStrutsConfig" and
attempt to populate the JSP form from that object. I believe that the
name that the JSP is attempting to use is the value of the <action>
parameter "name" from the struts-config.xml file.

Am I off base here? Thanks in advance for any help.

Mark Lowe wrote:

>As a side note I'd watch out putting dots in your actions .. I was doing the
>same and it worked .. and then i was getting an error that complained it
>could find the action...
>
>perhaps it was the release i was using or something, but i'd hate someone
>else to wash time out over this as well.. If its working however then don't
>fix it...
>
>
>
>----- Original Message -----
>From: "Mark Conlin" <me...@yahoo.com>
>To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
>Sent: Friday, December 20, 2002 8:42 PM
>Subject: RE: Pre-populating Form Bean
>
>
>  
>
>>This can not be the correct way to do this.
>>
>>I removed any reference to the form from the pre-Action:
>>
>><action path="/customer.customerAccountDetails.pre.edit"
>>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>><forward name="success" path="customer.edit_accountdetails"/>
>></action>
>>
>>Then I placed the Form into the session in the action like this:
>>session.setAttribute( "customerDetailsForm", custForm);
>>
>>This works but, I do not want to hard-code the form reference like this.
>>
>>Mark
>>
>>
>>
>>-----Original Message-----
>>From: Mark Conlin [mailto:meconlin@yahoo.com]
>>Sent: Friday, December 20, 2002 2:30 PM
>>To: 'Struts Users Mailing List'
>>Subject: RE: Pre-populating Form Bean
>>
>>
>>
>>Okay, I think I am missing something major here.
>>By watching the log files I see the following.
>>
>>1)Proccessing my pre edit Action -
>>"customer.customAccountDetails.pre.edit"
>>2)Struts then looks for my ActionForm -  "customerDetailsForm"
>>3)Struts then creates my ActionForm since it can not find it.
>>4)The form fails validation, as described by my validation.xml file.
>>
>>The pre edit Action never runs...
>>
>>The result is that I arrive at my "create" page with validation errors
>>because the validation logic tells it to return to that page.
>>
>>So, how can I pre-populate a Form? What am I don't wrong here...
>>
>>Mark
>>
>>
>>-----Original Message-----
>>From: Mark Conlin [mailto:meconlin@yahoo.com]
>>Sent: Friday, December 20, 2002 1:38 PM
>>To: 'Struts Users Mailing List'
>>Subject: RE: Pre-populating Form Bean
>>
>>
>>Okay so I have done the following...
>>I placed name="customerDetailsForm" into my action declaration..
>>It wanted an input field as well so I added that too.
>>
>>Now my form comes up and it is still not populated...
>>
>>My action execute code is below... are you sure I don't need to place
>>the custForm back into the session somehow ?
>>
>>
>>Thanks
>>Mark
>>
>>logger.debug("performAction starting");
>>ActionErrors errors = new ActionErrors();
>>ActionForward actionForward = mapping.findForward(FAILURE);
>>CustomerDetailsForm custForm = (CustomerDetailsForm) form;
>>HttpSession session = (HttpSession) request.getSession();
>>
>>custForm = this.setup( session );
>>actionForward = mapping.findForward(SUCCESS);
>>
>>logger.debug("performAction exiting");
>>
>>Action Declaration:
>>
>><action path="/customer.customerAccountDetails.edit"
>>type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
>>name="customerDetailsForm"
>>scope="session"
>>input="customer.account_details_view">
>><forward name="success"
>>path="/customer.customerAccountDetails.view.do"/>
>><forward name="failure" path="customer.edit_accountdetails"/>
>></action>
>>
>>
>>-----Original Message-----
>>From: Eddie Bush [mailto:ekbush@swbell.net]
>>Sent: Friday, December 20, 2002 2:13 PM
>>To: Struts Users Mailing List
>>Subject: Re: Pre-populating Form Bean
>>
>>If this is a form which you've declared in your config file, and it's
>>associated with this action and you're forwarding to a JSP, you really
>>needn't bother sticking it into any scope.  Struts will do this for you.
>>
>> Just populate the form and return an ActionForward and let Struts do
>>it's thing.
>>
>>... so far as your error is concerned, I can't imagine why you're
>>receiving it.  You did specify a 'name="formName"' as an attribute to
>>this action, right?  That's how you make the association between the
>>action and the form.  I believe this value would probably be null if you
>>
>>didn't specify that attribute - and I can see where that would generate
>>an error.
>>
>>Ah - yes.  I see your action declaration now.  Add in
>>'name="customerDetailsForm"' to your <action line.  That will build the
>>association for you.  Once you've done this, you no longer have to worry
>>
>>about creating the form ... or anything like that - and it's the *only*
>>way you're going to get Struts to populate the form for you
>>automatically (why would it populate something if it doesn't know there
>>is something to populate?).
>>
>>Good luck!
>>
>>Mark Conlin wrote:
>>
>>    
>>
>>>I would like to pre-populate a form bean for an edit screen.
>>>I have spent the last hour or two reading the archives and still I have
>>>failed to find the help I need.
>>>Any feedback would be appreciated.
>>>
>>>I have an Action class CustomerAccountDetailsPreEditAction that
>>>pre-populates my form.
>>>However, I do not know how to place the form back into the session or
>>>request so that the jsp page can find it and use it to display values.
>>>
>>>request.setAttribute(mapping.getName(), myForm);
>>>session.setAttribute(mapping.getName(), myForm);
>>>
>>>Both result in an error.
>>>
>>>Here is the action declaration:
>>>           <action path="/customer.customerAccountDetails.pre.edit"
>>>
>>>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>>>                       <forward name="success"
>>>path="customer.edit_accountdetails"/>
>>>           </action>
>>>
>>>
>>>Here is the form declaration:
>>><form-bean name="customerDetailsForm"
>>>type="com.yordata.form.CustomerDetailsForm"/>
>>>
>>>
>>>Thanks for your help,
>>>Mark
>>>
>>>
>>>
>>>      
>>>
>>--
>>Eddie Bush
>>
>>
>>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>>
>>--
>>To unsubscribe, e-mail:
>>    
>>
><ma...@jakarta.apache.org>
>  
>
>>For additional commands, e-mail:
>>    
>>
><ma...@jakarta.apache.org>
>  
>
>>    
>>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>  
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Pre-populating DynaActionForm Bean (solved)

Posted by Dan Allen <da...@mojavelinux.com>.
> Thus, the fact that this is an undocumented method and not used in the
> struts example application, leads me to believe my understanding is wrong.
> How would one grab data from a database and use that data to populate a form
> in struts?

You request an action mapping, such as

/EditAccount

and in that Action (EditAccountAction), which is passed a reference
to your form, you use BeanUtils.copyProperties or whatever to
transfer the data into your form and then you forward to your form
page.  Then you submit it and do the reverse on an action like

/SaveAccountChanges

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <da...@mojavelinux.com>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Microsoft is not the answer, it is the question. 
The answer is NO!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

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


Re: Pre-populating DynaActionForm Bean (solved)

Posted by Dave Ford <df...@smart-soft.com>.
> Should use the following way to instantiate a DynaActionForm:
>
> DynaBean form =
> DynaActionFormClass.getDynaActionFormClass("accessory").newInstance();
>
> But surprisingly i can't find this method on the API on the Docs on the
> struts website. http://jakarta.apache.org/struts/api/index.html

Maybe I'm missing something. But I thought the primary purpose of the form
bean was to re-populate forms, but also to POPULATE forms (without the re).
How can one do this without the being able to create a DynaActionForm
instance? My understanding is that almost every struts application would
need this capability. For example: grab data from a database to populate a
form.

Thus, the fact that this is an undocumented method and not used in the
struts example application, leads me to believe my understanding is wrong.
How would one grab data from a database and use that data to populate a form
in struts?

Thanks.

Dave Ford
Smart Soft - The Developer Training Company
http://www.smart-soft.com



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


Re: Pre-populating DynaActionForm Bean (solved)

Posted by Affan Qureshi <qu...@etilize.com>.
Should use the following way to instantiate a DynaActionForm:

DynaBean form =
DynaActionFormClass.getDynaActionFormClass("accessory").newInstance();

But surprisingly i can't find this method on the API on the Docs on the
struts website. http://jakarta.apache.org/struts/api/index.html

Thanks,

Affan

----- Original Message -----
From: "Affan Qureshi" <qu...@etilize.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Saturday, December 21, 2002 4:33 PM
Subject: Re: Pre-populating DynaActionForm Bean


> I have a similar scenario but in my case the sending action does not have
> the same form bean bean associated as the destination. So what I want to
do
> is to instantiate a form bean which the JSP is expecting and put it in the
> request scope.
>
> Here is my code:
>
> DynaActionForm form = new DynaActionForm();
> form.set("productId", String.valueOf(acc.getProductId()));
> form.set("mfrPartNumber", acc.getAccessoryProduct().getMfgPartNo());
> form.set("description", acc.getAccessoryProduct().getDescription());
> form.set("notes", acc.getNotes());
> req.setAttribute("accessory", form);
>
> This is the JSP to which I am sending this request:
> <html:form action="saveAcc.do" method="GET" >
>             <html:text property="productId"
size="25"readonly="true"/></td>
>             <html:text property="mfrPartNumber" size="25"/></td>
>             <html:text property="description" size="25"/></td>
>             <html:textarea property="notes" rows="8"/></td>
>             <html:submit >Save Accessory</html:submit>
>     </html:form>
>
> In struts-config.xml I have the following def for action saveAcc.do
> <action path="/saveAcc" type="my.mypackage.MySaveAccessoryAction"
> name="accessory" validate="false" scope="request">
>
> This is the error I get when submitting to the JSP:
> java.lang.NullPointerException at
>
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:
> 545) at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:361)
> at com.etilize.cms.web.actions.AddAccessoriesAction.editAccessory ......
> (more...)
>
> I am sorry if this has come up earlier but I could not find one.
>
> Thanks a lot.
> Affan



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Pre-populating DynaActionForm Bean

Posted by Affan Qureshi <qu...@etilize.com>.
I have a similar scenario but in my case the sending action does not have
the same form bean bean associated as the destination. So what I want to do
is to instantiate a form bean which the JSP is expecting and put it in the
request scope.

Here is my code:

DynaActionForm form = new DynaActionForm();
form.set("productId", String.valueOf(acc.getProductId()));
form.set("mfrPartNumber", acc.getAccessoryProduct().getMfgPartNo());
form.set("description", acc.getAccessoryProduct().getDescription());
form.set("notes", acc.getNotes());
req.setAttribute("accessory", form);

This is the JSP to which I am sending this request:
<html:form action="saveAcc.do" method="GET" >
            <html:text property="productId" size="25"readonly="true"/></td>
            <html:text property="mfrPartNumber" size="25"/></td>
            <html:text property="description" size="25"/></td>
            <html:textarea property="notes" rows="8"/></td>
            <html:submit >Save Accessory</html:submit>
    </html:form>

In struts-config.xml I have the following def for action saveAcc.do
<action path="/saveAcc" type="my.mypackage.MySaveAccessoryAction"
name="accessory" validate="false" scope="request">

This is the error I get when submitting to the JSP:
java.lang.NullPointerException at
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:
545) at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:361)
at com.etilize.cms.web.actions.AddAccessoriesAction.editAccessory ......
(more...)

I am sorry if this has come up earlier but I could not find one.

Thanks a lot.
Affan
----- Original Message -----
From: "Mark Lowe" <ma...@libero.it>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Saturday, December 21, 2002 1:17 AM
Subject: Re: Pre-populating Form Bean


> As a side note I'd watch out putting dots in your actions .. I was doing
the
> same and it worked .. and then i was getting an error that complained it
> could find the action...
>
> perhaps it was the release i was using or something, but i'd hate someone
> else to wash time out over this as well.. If its working however then
don't
> fix it...
>
>
>
> ----- Original Message -----
> From: "Mark Conlin" <me...@yahoo.com>
> To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
> Sent: Friday, December 20, 2002 8:42 PM
> Subject: RE: Pre-populating Form Bean
>
>
> >
> > This can not be the correct way to do this.
> >
> > I removed any reference to the form from the pre-Action:
> >
> > <action path="/customer.customerAccountDetails.pre.edit"
> > type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> > <forward name="success" path="customer.edit_accountdetails"/>
> > </action>
> >
> > Then I placed the Form into the session in the action like this:
> > session.setAttribute( "customerDetailsForm", custForm);
> >
> > This works but, I do not want to hard-code the form reference like this.
> >
> > Mark
> >
> >
> >
> > -----Original Message-----
> > From: Mark Conlin [mailto:meconlin@yahoo.com]
> > Sent: Friday, December 20, 2002 2:30 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Pre-populating Form Bean
> >
> >
> >
> > Okay, I think I am missing something major here.
> > By watching the log files I see the following.
> >
> > 1)Proccessing my pre edit Action -
> > "customer.customAccountDetails.pre.edit"
> > 2)Struts then looks for my ActionForm -  "customerDetailsForm"
> > 3)Struts then creates my ActionForm since it can not find it.
> > 4)The form fails validation, as described by my validation.xml file.
> >
> > The pre edit Action never runs...
> >
> > The result is that I arrive at my "create" page with validation errors
> > because the validation logic tells it to return to that page.
> >
> > So, how can I pre-populate a Form? What am I don't wrong here...
> >
> > Mark
> >
> >
> > -----Original Message-----
> > From: Mark Conlin [mailto:meconlin@yahoo.com]
> > Sent: Friday, December 20, 2002 1:38 PM
> > To: 'Struts Users Mailing List'
> > Subject: RE: Pre-populating Form Bean
> >
> >
> > Okay so I have done the following...
> > I placed name="customerDetailsForm" into my action declaration..
> > It wanted an input field as well so I added that too.
> >
> > Now my form comes up and it is still not populated...
> >
> > My action execute code is below... are you sure I don't need to place
> > the custForm back into the session somehow ?
> >
> >
> > Thanks
> > Mark
> >
> > logger.debug("performAction starting");
> > ActionErrors errors = new ActionErrors();
> > ActionForward actionForward = mapping.findForward(FAILURE);
> > CustomerDetailsForm custForm = (CustomerDetailsForm) form;
> > HttpSession session = (HttpSession) request.getSession();
> >
> > custForm = this.setup( session );
> > actionForward = mapping.findForward(SUCCESS);
> >
> > logger.debug("performAction exiting");
> >
> > Action Declaration:
> >
> > <action path="/customer.customerAccountDetails.edit"
> > type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
> > name="customerDetailsForm"
> > scope="session"
> > input="customer.account_details_view">
> > <forward name="success"
> > path="/customer.customerAccountDetails.view.do"/>
> > <forward name="failure" path="customer.edit_accountdetails"/>
> > </action>
> >
> >
> > -----Original Message-----
> > From: Eddie Bush [mailto:ekbush@swbell.net]
> > Sent: Friday, December 20, 2002 2:13 PM
> > To: Struts Users Mailing List
> > Subject: Re: Pre-populating Form Bean
> >
> > If this is a form which you've declared in your config file, and it's
> > associated with this action and you're forwarding to a JSP, you really
> > needn't bother sticking it into any scope.  Struts will do this for you.
> >
> >  Just populate the form and return an ActionForward and let Struts do
> > it's thing.
> >
> > ... so far as your error is concerned, I can't imagine why you're
> > receiving it.  You did specify a 'name="formName"' as an attribute to
> > this action, right?  That's how you make the association between the
> > action and the form.  I believe this value would probably be null if you
> >
> > didn't specify that attribute - and I can see where that would generate
> > an error.
> >
> > Ah - yes.  I see your action declaration now.  Add in
> > 'name="customerDetailsForm"' to your <action line.  That will build the
> > association for you.  Once you've done this, you no longer have to worry
> >
> > about creating the form ... or anything like that - and it's the *only*
> > way you're going to get Struts to populate the form for you
> > automatically (why would it populate something if it doesn't know there
> > is something to populate?).
> >
> > Good luck!
> >
> > Mark Conlin wrote:
> >
> > >
> > >I would like to pre-populate a form bean for an edit screen.
> > >I have spent the last hour or two reading the archives and still I have
> > >failed to find the help I need.
> > >Any feedback would be appreciated.
> > >
> > >I have an Action class CustomerAccountDetailsPreEditAction that
> > >pre-populates my form.
> > >However, I do not know how to place the form back into the session or
> > >request so that the jsp page can find it and use it to display values.
> > >
> > >request.setAttribute(mapping.getName(), myForm);
> > >session.setAttribute(mapping.getName(), myForm);
> > >
> > >Both result in an error.
> > >
> > >Here is the action declaration:
> > >            <action path="/customer.customerAccountDetails.pre.edit"
> > >
> > >type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> > >                        <forward name="success"
> > >path="customer.edit_accountdetails"/>
> > >            </action>
> > >
> > >
> > >Here is the form declaration:
> > ><form-bean name="customerDetailsForm"
> > >type="com.yordata.form.CustomerDetailsForm"/>
> > >
> > >
> > >Thanks for your help,
> > >Mark
> > >
> > >
> > >
> >
> > --
> > Eddie Bush
> >
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Pre-populating Form Bean

Posted by Mark Lowe <ma...@libero.it>.
As a side note I'd watch out putting dots in your actions .. I was doing the
same and it worked .. and then i was getting an error that complained it
could find the action...

perhaps it was the release i was using or something, but i'd hate someone
else to wash time out over this as well.. If its working however then don't
fix it...



----- Original Message -----
From: "Mark Conlin" <me...@yahoo.com>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Friday, December 20, 2002 8:42 PM
Subject: RE: Pre-populating Form Bean


>
> This can not be the correct way to do this.
>
> I removed any reference to the form from the pre-Action:
>
> <action path="/customer.customerAccountDetails.pre.edit"
> type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> <forward name="success" path="customer.edit_accountdetails"/>
> </action>
>
> Then I placed the Form into the session in the action like this:
> session.setAttribute( "customerDetailsForm", custForm);
>
> This works but, I do not want to hard-code the form reference like this.
>
> Mark
>
>
>
> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 2:30 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
>
> Okay, I think I am missing something major here.
> By watching the log files I see the following.
>
> 1)Proccessing my pre edit Action -
> "customer.customAccountDetails.pre.edit"
> 2)Struts then looks for my ActionForm -  "customerDetailsForm"
> 3)Struts then creates my ActionForm since it can not find it.
> 4)The form fails validation, as described by my validation.xml file.
>
> The pre edit Action never runs...
>
> The result is that I arrive at my "create" page with validation errors
> because the validation logic tells it to return to that page.
>
> So, how can I pre-populate a Form? What am I don't wrong here...
>
> Mark
>
>
> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 1:38 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
> Okay so I have done the following...
> I placed name="customerDetailsForm" into my action declaration..
> It wanted an input field as well so I added that too.
>
> Now my form comes up and it is still not populated...
>
> My action execute code is below... are you sure I don't need to place
> the custForm back into the session somehow ?
>
>
> Thanks
> Mark
>
> logger.debug("performAction starting");
> ActionErrors errors = new ActionErrors();
> ActionForward actionForward = mapping.findForward(FAILURE);
> CustomerDetailsForm custForm = (CustomerDetailsForm) form;
> HttpSession session = (HttpSession) request.getSession();
>
> custForm = this.setup( session );
> actionForward = mapping.findForward(SUCCESS);
>
> logger.debug("performAction exiting");
>
> Action Declaration:
>
> <action path="/customer.customerAccountDetails.edit"
> type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
> name="customerDetailsForm"
> scope="session"
> input="customer.account_details_view">
> <forward name="success"
> path="/customer.customerAccountDetails.view.do"/>
> <forward name="failure" path="customer.edit_accountdetails"/>
> </action>
>
>
> -----Original Message-----
> From: Eddie Bush [mailto:ekbush@swbell.net]
> Sent: Friday, December 20, 2002 2:13 PM
> To: Struts Users Mailing List
> Subject: Re: Pre-populating Form Bean
>
> If this is a form which you've declared in your config file, and it's
> associated with this action and you're forwarding to a JSP, you really
> needn't bother sticking it into any scope.  Struts will do this for you.
>
>  Just populate the form and return an ActionForward and let Struts do
> it's thing.
>
> ... so far as your error is concerned, I can't imagine why you're
> receiving it.  You did specify a 'name="formName"' as an attribute to
> this action, right?  That's how you make the association between the
> action and the form.  I believe this value would probably be null if you
>
> didn't specify that attribute - and I can see where that would generate
> an error.
>
> Ah - yes.  I see your action declaration now.  Add in
> 'name="customerDetailsForm"' to your <action line.  That will build the
> association for you.  Once you've done this, you no longer have to worry
>
> about creating the form ... or anything like that - and it's the *only*
> way you're going to get Struts to populate the form for you
> automatically (why would it populate something if it doesn't know there
> is something to populate?).
>
> Good luck!
>
> Mark Conlin wrote:
>
> >
> >I would like to pre-populate a form bean for an edit screen.
> >I have spent the last hour or two reading the archives and still I have
> >failed to find the help I need.
> >Any feedback would be appreciated.
> >
> >I have an Action class CustomerAccountDetailsPreEditAction that
> >pre-populates my form.
> >However, I do not know how to place the form back into the session or
> >request so that the jsp page can find it and use it to display values.
> >
> >request.setAttribute(mapping.getName(), myForm);
> >session.setAttribute(mapping.getName(), myForm);
> >
> >Both result in an error.
> >
> >Here is the action declaration:
> >            <action path="/customer.customerAccountDetails.pre.edit"
> >
> >type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> >                        <forward name="success"
> >path="customer.edit_accountdetails"/>
> >            </action>
> >
> >
> >Here is the form declaration:
> ><form-bean name="customerDetailsForm"
> >type="com.yordata.form.CustomerDetailsForm"/>
> >
> >
> >Thanks for your help,
> >Mark
> >
> >
> >
>
> --
> Eddie Bush
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Pre-populating Form Bean

Posted by Eddie Bush <ek...@swbell.net>.
Your problem is that you need validate="false" -- that will get rid of 
the requirement to have 'input="?"' and will allow your action to 
execute as you expect.  Nothing major at all - very subtle problem.

Mark Conlin wrote:

>This can not be the correct way to do this.
>
>I removed any reference to the form from the pre-Action:
>
><action path="/customer.customerAccountDetails.pre.edit"
>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
><forward name="success" path="customer.edit_accountdetails"/>
></action>
>
>Then I placed the Form into the session in the action like this:
>session.setAttribute( "customerDetailsForm", custForm);
>
>This works but, I do not want to hard-code the form reference like this.
>
>Mark
>

-- 
Eddie Bush





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Pre-populating Form Bean

Posted by Mark Conlin <me...@yahoo.com>.
This can not be the correct way to do this.

I removed any reference to the form from the pre-Action:

<action path="/customer.customerAccountDetails.pre.edit"
type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
<forward name="success" path="customer.edit_accountdetails"/>
</action>

Then I placed the Form into the session in the action like this:
session.setAttribute( "customerDetailsForm", custForm);

This works but, I do not want to hard-code the form reference like this.

Mark



-----Original Message-----
From: Mark Conlin [mailto:meconlin@yahoo.com] 
Sent: Friday, December 20, 2002 2:30 PM
To: 'Struts Users Mailing List'
Subject: RE: Pre-populating Form Bean



Okay, I think I am missing something major here.
By watching the log files I see the following.

1)Proccessing my pre edit Action -
"customer.customAccountDetails.pre.edit" 
2)Struts then looks for my ActionForm -  "customerDetailsForm"
3)Struts then creates my ActionForm since it can not find it.
4)The form fails validation, as described by my validation.xml file. 

The pre edit Action never runs...

The result is that I arrive at my "create" page with validation errors
because the validation logic tells it to return to that page.

So, how can I pre-populate a Form? What am I don't wrong here...

Mark


-----Original Message-----
From: Mark Conlin [mailto:meconlin@yahoo.com] 
Sent: Friday, December 20, 2002 1:38 PM
To: 'Struts Users Mailing List'
Subject: RE: Pre-populating Form Bean


Okay so I have done the following...
I placed name="customerDetailsForm" into my action declaration..
It wanted an input field as well so I added that too.

Now my form comes up and it is still not populated...

My action execute code is below... are you sure I don't need to place
the custForm back into the session somehow ?


Thanks 
Mark 

logger.debug("performAction starting");
ActionErrors errors 			= new ActionErrors();
ActionForward actionForward 	= mapping.findForward(FAILURE);
CustomerDetailsForm custForm 	= (CustomerDetailsForm) form;
HttpSession session = (HttpSession) request.getSession();
	
custForm = this.setup( session );
actionForward = mapping.findForward(SUCCESS);	
					
logger.debug("performAction exiting");

Action Declaration:

<action path="/customer.customerAccountDetails.edit"
type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
	name="customerDetailsForm"
	scope="session"
	input="customer.account_details_view">
<forward name="success"
path="/customer.customerAccountDetails.view.do"/>
<forward name="failure" path="customer.edit_accountdetails"/>
</action>


-----Original Message-----
From: Eddie Bush [mailto:ekbush@swbell.net] 
Sent: Friday, December 20, 2002 2:13 PM
To: Struts Users Mailing List
Subject: Re: Pre-populating Form Bean

If this is a form which you've declared in your config file, and it's 
associated with this action and you're forwarding to a JSP, you really 
needn't bother sticking it into any scope.  Struts will do this for you.

 Just populate the form and return an ActionForward and let Struts do 
it's thing.

... so far as your error is concerned, I can't imagine why you're 
receiving it.  You did specify a 'name="formName"' as an attribute to 
this action, right?  That's how you make the association between the 
action and the form.  I believe this value would probably be null if you

didn't specify that attribute - and I can see where that would generate 
an error.

Ah - yes.  I see your action declaration now.  Add in 
'name="customerDetailsForm"' to your <action line.  That will build the 
association for you.  Once you've done this, you no longer have to worry

about creating the form ... or anything like that - and it's the *only* 
way you're going to get Struts to populate the form for you 
automatically (why would it populate something if it doesn't know there 
is something to populate?).

Good luck!

Mark Conlin wrote:

> 
>I would like to pre-populate a form bean for an edit screen.
>I have spent the last hour or two reading the archives and still I have
>failed to find the help I need.
>Any feedback would be appreciated.
> 
>I have an Action class CustomerAccountDetailsPreEditAction that
>pre-populates my form.
>However, I do not know how to place the form back into the session or
>request so that the jsp page can find it and use it to display values.
> 
>request.setAttribute(mapping.getName(), myForm);
>session.setAttribute(mapping.getName(), myForm); 
> 
>Both result in an error.
> 
>Here is the action declaration:
>            <action path="/customer.customerAccountDetails.pre.edit"
> 
>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>                        <forward name="success"
>path="customer.edit_accountdetails"/>
>            </action>
> 
> 
>Here is the form declaration:
><form-bean name="customerDetailsForm"
>type="com.yordata.form.CustomerDetailsForm"/>
> 
> 
>Thanks for your help,
>Mark 
>
>  
>

-- 
Eddie Bush





--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Pre-populating Form Bean

Posted by Mark Conlin <me...@yahoo.com>.
Yes, this did the trick, setting the validate="false" works great!

Thank you so much.
Mark

-----Original Message-----
From: Robert Taylor [mailto:rtaylor@mulework.com] 
Sent: Friday, December 20, 2002 2:56 PM
To: Struts Users Mailing List
Subject: RE: Pre-populating Form Bean

Don't validate the pre edit Action. This should allow your form to
propogate
to the Action.execute() where you can populate the form. Make sure you
are
forwarding to the destination page and not redirecting.
Your almost there, don't give up yet. So set validate="false" in the
struts
config file for the pre edit action mapping.

robert

> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 2:30 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
>
>
> Okay, I think I am missing something major here.
> By watching the log files I see the following.
>
> 1)Proccessing my pre edit Action -
> "customer.customAccountDetails.pre.edit"
> 2)Struts then looks for my ActionForm -  "customerDetailsForm"
> 3)Struts then creates my ActionForm since it can not find it.
> 4)The form fails validation, as described by my validation.xml file.
>
> The pre edit Action never runs...
>
> The result is that I arrive at my "create" page with validation errors
> because the validation logic tells it to return to that page.
>
> So, how can I pre-populate a Form? What am I don't wrong here...
>
> Mark
>
>
> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 1:38 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
> Okay so I have done the following...
> I placed name="customerDetailsForm" into my action declaration..
> It wanted an input field as well so I added that too.
>
> Now my form comes up and it is still not populated...
>
> My action execute code is below... are you sure I don't need to place
> the custForm back into the session somehow ?
>
>
> Thanks
> Mark
>
> logger.debug("performAction starting");
> ActionErrors errors 			= new ActionErrors();
> ActionForward actionForward 	= mapping.findForward(FAILURE);
> CustomerDetailsForm custForm 	= (CustomerDetailsForm) form;
> HttpSession session = (HttpSession) request.getSession();
>
> custForm = this.setup( session );
> actionForward = mapping.findForward(SUCCESS);
>
> logger.debug("performAction exiting");
>
> Action Declaration:
>
> <action path="/customer.customerAccountDetails.edit"
> type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
> 	name="customerDetailsForm"
> 	scope="session"
> 	input="customer.account_details_view">
> <forward name="success"
> path="/customer.customerAccountDetails.view.do"/>
> <forward name="failure" path="customer.edit_accountdetails"/>
> </action>
>
>
> -----Original Message-----
> From: Eddie Bush [mailto:ekbush@swbell.net]
> Sent: Friday, December 20, 2002 2:13 PM
> To: Struts Users Mailing List
> Subject: Re: Pre-populating Form Bean
>
> If this is a form which you've declared in your config file, and it's
> associated with this action and you're forwarding to a JSP, you really
> needn't bother sticking it into any scope.  Struts will do this for
you.
>
>  Just populate the form and return an ActionForward and let Struts do
> it's thing.
>
> ... so far as your error is concerned, I can't imagine why you're
> receiving it.  You did specify a 'name="formName"' as an attribute to
> this action, right?  That's how you make the association between the
> action and the form.  I believe this value would probably be null if
you
>
> didn't specify that attribute - and I can see where that would
generate
> an error.
>
> Ah - yes.  I see your action declaration now.  Add in
> 'name="customerDetailsForm"' to your <action line.  That will build
the
> association for you.  Once you've done this, you no longer have to
worry
>
> about creating the form ... or anything like that - and it's the
*only*
> way you're going to get Struts to populate the form for you
> automatically (why would it populate something if it doesn't know
there
> is something to populate?).
>
> Good luck!
>
> Mark Conlin wrote:
>
> >
> >I would like to pre-populate a form bean for an edit screen.
> >I have spent the last hour or two reading the archives and still I
have
> >failed to find the help I need.
> >Any feedback would be appreciated.
> >
> >I have an Action class CustomerAccountDetailsPreEditAction that
> >pre-populates my form.
> >However, I do not know how to place the form back into the session or
> >request so that the jsp page can find it and use it to display
values.
> >
> >request.setAttribute(mapping.getName(), myForm);
> >session.setAttribute(mapping.getName(), myForm);
> >
> >Both result in an error.
> >
> >Here is the action declaration:
> >            <action path="/customer.customerAccountDetails.pre.edit"
> >
>
>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> >                        <forward name="success"
> >path="customer.edit_accountdetails"/>
> >            </action>
> >
> >
> >Here is the form declaration:
> ><form-bean name="customerDetailsForm"
> >type="com.yordata.form.CustomerDetailsForm"/>
> >
> >
> >Thanks for your help,
> >Mark
> >
> >
> >
>
> --
> Eddie Bush
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: reset doesn't work well

Posted by Mark Lepkowski <Ma...@lmco.com>.
In my experience, the reset condition is the state that the form was in when it was loaded.  So if you have a checkbox set when the form is loaded, uncheck it, and click [Reset], the checkbox becomes checked again.

----- Original Message ----- 
From: "Doug Ogateter" <hi...@yahoo.ca>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, December 20, 2002 3:37 PM
Subject: reset doesn't work well


> 
> Hi:
> I have a problem with reset button. In my jsp file, I have
> <html:reset/>. In my form class, I have: 
> 
>   public void reset(ActionMapping mapping, HttpServletRequest request) {
>     amount = null;
> 
>     password = null;
>    }
> 
> in the struts-config.xml file, it has:
> 
>    <action    path="/xxx"
>                type="yyy"
>                name="myForm"
>               scope="request"
> 
>               input="/zzz.jsp">
>           <forward name="success"             path="/zzz.jsp"/>    
>     </action>
> 
> I filled out the fields, if I click reset button before submit the form,
> the fields are cleared. But if I submit the form first, and it detects
> some error(for example: the password is not correct), the form is showed
> with error message. In this case, when I click reset button, the fields
> are not cleared. What is wrong with this. I really want the fields can
> be cleared if errors are detected. Could someone help me out?
> 
> Thanks.
> 
> Doug
> 
> 
> 
> ---------------------------------
> Post your free ad now! Yahoo! Canada Personals
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


reset doesn't work well

Posted by Doug Ogateter <hi...@yahoo.ca>.
Hi:
I have a problem with reset button. In my jsp file, I have <html:reset/>. In my form class, I have: 

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    amount = null;

    password = null;
   }

in the struts-config.xml file, it has:

   <action    path="/xxx"
               type="yyy"
               name="myForm"
              scope="request"

              input="/zzz.jsp">
          <forward name="success"             path="/zzz.jsp"/>    
    </action>

I filled out the fields, if I click reset button before submit the form, the fields are cleared. But if I submit the form first, and it detects some error(for example: the password is not correct), the form is showed  with error message. In this case, when I click reset button, the fields are not cleared. What is wrong with this. I really want the fields can be cleared if errors are detected. Could someone help me out?

Thanks.

Doug



---------------------------------
Post your free ad now! Yahoo! Canada Personals

RE: Pre-populating Form Bean

Posted by Robert Taylor <rt...@mulework.com>.
Don't validate the pre edit Action. This should allow your form to propogate
to the Action.execute() where you can populate the form. Make sure you are
forwarding to the destination page and not redirecting.
Your almost there, don't give up yet. So set validate="false" in the struts
config file for the pre edit action mapping.

robert

> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 2:30 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
>
>
> Okay, I think I am missing something major here.
> By watching the log files I see the following.
>
> 1)Proccessing my pre edit Action -
> "customer.customAccountDetails.pre.edit"
> 2)Struts then looks for my ActionForm -  "customerDetailsForm"
> 3)Struts then creates my ActionForm since it can not find it.
> 4)The form fails validation, as described by my validation.xml file.
>
> The pre edit Action never runs...
>
> The result is that I arrive at my "create" page with validation errors
> because the validation logic tells it to return to that page.
>
> So, how can I pre-populate a Form? What am I don't wrong here...
>
> Mark
>
>
> -----Original Message-----
> From: Mark Conlin [mailto:meconlin@yahoo.com]
> Sent: Friday, December 20, 2002 1:38 PM
> To: 'Struts Users Mailing List'
> Subject: RE: Pre-populating Form Bean
>
>
> Okay so I have done the following...
> I placed name="customerDetailsForm" into my action declaration..
> It wanted an input field as well so I added that too.
>
> Now my form comes up and it is still not populated...
>
> My action execute code is below... are you sure I don't need to place
> the custForm back into the session somehow ?
>
>
> Thanks
> Mark
>
> logger.debug("performAction starting");
> ActionErrors errors 			= new ActionErrors();
> ActionForward actionForward 	= mapping.findForward(FAILURE);
> CustomerDetailsForm custForm 	= (CustomerDetailsForm) form;
> HttpSession session = (HttpSession) request.getSession();
>
> custForm = this.setup( session );
> actionForward = mapping.findForward(SUCCESS);
>
> logger.debug("performAction exiting");
>
> Action Declaration:
>
> <action path="/customer.customerAccountDetails.edit"
> type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
> 	name="customerDetailsForm"
> 	scope="session"
> 	input="customer.account_details_view">
> <forward name="success"
> path="/customer.customerAccountDetails.view.do"/>
> <forward name="failure" path="customer.edit_accountdetails"/>
> </action>
>
>
> -----Original Message-----
> From: Eddie Bush [mailto:ekbush@swbell.net]
> Sent: Friday, December 20, 2002 2:13 PM
> To: Struts Users Mailing List
> Subject: Re: Pre-populating Form Bean
>
> If this is a form which you've declared in your config file, and it's
> associated with this action and you're forwarding to a JSP, you really
> needn't bother sticking it into any scope.  Struts will do this for you.
>
>  Just populate the form and return an ActionForward and let Struts do
> it's thing.
>
> ... so far as your error is concerned, I can't imagine why you're
> receiving it.  You did specify a 'name="formName"' as an attribute to
> this action, right?  That's how you make the association between the
> action and the form.  I believe this value would probably be null if you
>
> didn't specify that attribute - and I can see where that would generate
> an error.
>
> Ah - yes.  I see your action declaration now.  Add in
> 'name="customerDetailsForm"' to your <action line.  That will build the
> association for you.  Once you've done this, you no longer have to worry
>
> about creating the form ... or anything like that - and it's the *only*
> way you're going to get Struts to populate the form for you
> automatically (why would it populate something if it doesn't know there
> is something to populate?).
>
> Good luck!
>
> Mark Conlin wrote:
>
> >
> >I would like to pre-populate a form bean for an edit screen.
> >I have spent the last hour or two reading the archives and still I have
> >failed to find the help I need.
> >Any feedback would be appreciated.
> >
> >I have an Action class CustomerAccountDetailsPreEditAction that
> >pre-populates my form.
> >However, I do not know how to place the form back into the session or
> >request so that the jsp page can find it and use it to display values.
> >
> >request.setAttribute(mapping.getName(), myForm);
> >session.setAttribute(mapping.getName(), myForm);
> >
> >Both result in an error.
> >
> >Here is the action declaration:
> >            <action path="/customer.customerAccountDetails.pre.edit"
> >
> >type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
> >                        <forward name="success"
> >path="customer.edit_accountdetails"/>
> >            </action>
> >
> >
> >Here is the form declaration:
> ><form-bean name="customerDetailsForm"
> >type="com.yordata.form.CustomerDetailsForm"/>
> >
> >
> >Thanks for your help,
> >Mark
> >
> >
> >
>
> --
> Eddie Bush
>
>
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Pre-populating Form Bean

Posted by Mark Conlin <me...@yahoo.com>.

Okay, I think I am missing something major here.
By watching the log files I see the following.

1)Proccessing my pre edit Action -
"customer.customAccountDetails.pre.edit" 
2)Struts then looks for my ActionForm -  "customerDetailsForm"
3)Struts then creates my ActionForm since it can not find it.
4)The form fails validation, as described by my validation.xml file. 

The pre edit Action never runs...

The result is that I arrive at my "create" page with validation errors
because the validation logic tells it to return to that page.

So, how can I pre-populate a Form? What am I don't wrong here...

Mark


-----Original Message-----
From: Mark Conlin [mailto:meconlin@yahoo.com] 
Sent: Friday, December 20, 2002 1:38 PM
To: 'Struts Users Mailing List'
Subject: RE: Pre-populating Form Bean


Okay so I have done the following...
I placed name="customerDetailsForm" into my action declaration..
It wanted an input field as well so I added that too.

Now my form comes up and it is still not populated...

My action execute code is below... are you sure I don't need to place
the custForm back into the session somehow ?


Thanks 
Mark 

logger.debug("performAction starting");
ActionErrors errors 			= new ActionErrors();
ActionForward actionForward 	= mapping.findForward(FAILURE);
CustomerDetailsForm custForm 	= (CustomerDetailsForm) form;
HttpSession session = (HttpSession) request.getSession();
	
custForm = this.setup( session );
actionForward = mapping.findForward(SUCCESS);	
					
logger.debug("performAction exiting");

Action Declaration:

<action path="/customer.customerAccountDetails.edit"
type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
	name="customerDetailsForm"
	scope="session"
	input="customer.account_details_view">
<forward name="success"
path="/customer.customerAccountDetails.view.do"/>
<forward name="failure" path="customer.edit_accountdetails"/>
</action>


-----Original Message-----
From: Eddie Bush [mailto:ekbush@swbell.net] 
Sent: Friday, December 20, 2002 2:13 PM
To: Struts Users Mailing List
Subject: Re: Pre-populating Form Bean

If this is a form which you've declared in your config file, and it's 
associated with this action and you're forwarding to a JSP, you really 
needn't bother sticking it into any scope.  Struts will do this for you.

 Just populate the form and return an ActionForward and let Struts do 
it's thing.

... so far as your error is concerned, I can't imagine why you're 
receiving it.  You did specify a 'name="formName"' as an attribute to 
this action, right?  That's how you make the association between the 
action and the form.  I believe this value would probably be null if you

didn't specify that attribute - and I can see where that would generate 
an error.

Ah - yes.  I see your action declaration now.  Add in 
'name="customerDetailsForm"' to your <action line.  That will build the 
association for you.  Once you've done this, you no longer have to worry

about creating the form ... or anything like that - and it's the *only* 
way you're going to get Struts to populate the form for you 
automatically (why would it populate something if it doesn't know there 
is something to populate?).

Good luck!

Mark Conlin wrote:

> 
>I would like to pre-populate a form bean for an edit screen.
>I have spent the last hour or two reading the archives and still I have
>failed to find the help I need.
>Any feedback would be appreciated.
> 
>I have an Action class CustomerAccountDetailsPreEditAction that
>pre-populates my form.
>However, I do not know how to place the form back into the session or
>request so that the jsp page can find it and use it to display values.
> 
>request.setAttribute(mapping.getName(), myForm);
>session.setAttribute(mapping.getName(), myForm); 
> 
>Both result in an error.
> 
>Here is the action declaration:
>            <action path="/customer.customerAccountDetails.pre.edit"
> 
>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>                        <forward name="success"
>path="customer.edit_accountdetails"/>
>            </action>
> 
> 
>Here is the form declaration:
><form-bean name="customerDetailsForm"
>type="com.yordata.form.CustomerDetailsForm"/>
> 
> 
>Thanks for your help,
>Mark 
>
>  
>

-- 
Eddie Bush





--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Pre-populating Form Bean

Posted by Mark Conlin <me...@yahoo.com>.
Okay so I have done the following...
I placed name="customerDetailsForm" into my action declaration..
It wanted an input field as well so I added that too.

Now my form comes up and it is still not populated...

My action execute code is below... are you sure I don't need to place
the custForm back into the session somehow ?


Thanks 
Mark 

logger.debug("performAction starting");
ActionErrors errors 			= new ActionErrors();
ActionForward actionForward 	= mapping.findForward(FAILURE);
CustomerDetailsForm custForm 	= (CustomerDetailsForm) form;
HttpSession session = (HttpSession) request.getSession();
	
custForm = this.setup( session );
actionForward = mapping.findForward(SUCCESS);	
					
logger.debug("performAction exiting");

Action Declaration:

<action path="/customer.customerAccountDetails.edit"
type="com.yordata.action.customer.CustomerAccountDetailsEditAction"
	name="customerDetailsForm"
	scope="session"
	input="customer.account_details_view">
<forward name="success"
path="/customer.customerAccountDetails.view.do"/>
<forward name="failure" path="customer.edit_accountdetails"/>
</action>


-----Original Message-----
From: Eddie Bush [mailto:ekbush@swbell.net] 
Sent: Friday, December 20, 2002 2:13 PM
To: Struts Users Mailing List
Subject: Re: Pre-populating Form Bean

If this is a form which you've declared in your config file, and it's 
associated with this action and you're forwarding to a JSP, you really 
needn't bother sticking it into any scope.  Struts will do this for you.

 Just populate the form and return an ActionForward and let Struts do 
it's thing.

... so far as your error is concerned, I can't imagine why you're 
receiving it.  You did specify a 'name="formName"' as an attribute to 
this action, right?  That's how you make the association between the 
action and the form.  I believe this value would probably be null if you

didn't specify that attribute - and I can see where that would generate 
an error.

Ah - yes.  I see your action declaration now.  Add in 
'name="customerDetailsForm"' to your <action line.  That will build the 
association for you.  Once you've done this, you no longer have to worry

about creating the form ... or anything like that - and it's the *only* 
way you're going to get Struts to populate the form for you 
automatically (why would it populate something if it doesn't know there 
is something to populate?).

Good luck!

Mark Conlin wrote:

> 
>I would like to pre-populate a form bean for an edit screen.
>I have spent the last hour or two reading the archives and still I have
>failed to find the help I need.
>Any feedback would be appreciated.
> 
>I have an Action class CustomerAccountDetailsPreEditAction that
>pre-populates my form.
>However, I do not know how to place the form back into the session or
>request so that the jsp page can find it and use it to display values.
> 
>request.setAttribute(mapping.getName(), myForm);
>session.setAttribute(mapping.getName(), myForm); 
> 
>Both result in an error.
> 
>Here is the action declaration:
>            <action path="/customer.customerAccountDetails.pre.edit"
> 
>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>                        <forward name="success"
>path="customer.edit_accountdetails"/>
>            </action>
> 
> 
>Here is the form declaration:
><form-bean name="customerDetailsForm"
>type="com.yordata.form.CustomerDetailsForm"/>
> 
> 
>Thanks for your help,
>Mark 
>
>  
>

-- 
Eddie Bush





--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Pre-populating Form Bean

Posted by Eddie Bush <ek...@swbell.net>.
If this is a form which you've declared in your config file, and it's 
associated with this action and you're forwarding to a JSP, you really 
needn't bother sticking it into any scope.  Struts will do this for you. 
 Just populate the form and return an ActionForward and let Struts do 
it's thing.

... so far as your error is concerned, I can't imagine why you're 
receiving it.  You did specify a 'name="formName"' as an attribute to 
this action, right?  That's how you make the association between the 
action and the form.  I believe this value would probably be null if you 
didn't specify that attribute - and I can see where that would generate 
an error.

Ah - yes.  I see your action declaration now.  Add in 
'name="customerDetailsForm"' to your <action line.  That will build the 
association for you.  Once you've done this, you no longer have to worry 
about creating the form ... or anything like that - and it's the *only* 
way you're going to get Struts to populate the form for you 
automatically (why would it populate something if it doesn't know there 
is something to populate?).

Good luck!

Mark Conlin wrote:

> 
>I would like to pre-populate a form bean for an edit screen.
>I have spent the last hour or two reading the archives and still I have
>failed to find the help I need.
>Any feedback would be appreciated.
> 
>I have an Action class CustomerAccountDetailsPreEditAction that
>pre-populates my form.
>However, I do not know how to place the form back into the session or
>request so that the jsp page can find it and use it to display values.
> 
>request.setAttribute(mapping.getName(), myForm);
>session.setAttribute(mapping.getName(), myForm); 
> 
>Both result in an error.
> 
>Here is the action declaration:
>            <action path="/customer.customerAccountDetails.pre.edit"
> 
>type="com.yordata.action.customer.CustomerAccountDetailsPreEditAction">
>                        <forward name="success"
>path="customer.edit_accountdetails"/>
>            </action>
> 
> 
>Here is the form declaration:
><form-bean name="customerDetailsForm"
>type="com.yordata.form.CustomerDetailsForm"/>
> 
> 
>Thanks for your help,
>Mark 
>
>  
>

-- 
Eddie Bush





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>