This is what i think should happen...
(Correct me wherever i am wrong...)

This is how i call bean for setting values in config file:
------------------------------------
    <!-- Form bean -->
    <form-bean      name="myForm"
                    type="org.apache.struts.dir1.dir2.MyBean"
                    scope="session"/>
------------------------------------

then after i set the values and after validate method, control goes as
follows:
-----------------------------------------------
    <!-- Action mapping -->
    <action    path="/doSomeAction" <!-- when i view source of jsp page that
has form it has                   
                                    action as
"/struts-example/doSomeAction.do" -->
               type="org.apache.struts.dir1.dir2.ProcessMyBean"
               name="myForm"
              scope="session"
           validate="false">
      <forward name="success"              path="/dir1/dir2/Success.jsp"/>
      <forward name="failure"              path="/dir1/dir2/Error.jsp"/>
    </action>
-----------------------------------------------

So in ProcessMyBean class, i instantiated object MyBean with:
MyBean mb = new MyBean();
and then i called the getter to get the value which was set before:
(here is somewhat i am missing)

Please help me...
Nishit
-----Original Message-----
From: Jacob Thomas [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 29, 2001 5:58 PM
To: '[EMAIL PROTECTED]'
Subject: RE: getting value from bean


I think your <html:form> tag is instantiating a new Form bean and hence the
fields have their default values when the page is rendered. When the page is
submitted another form bean is getting created. You may want to set the
scope to 'session' and remove the bean appropriately.
--
Jacob

-----Original Message-----
From: Nishit Trivedi [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 29, 2001 2:49 PM
To: [EMAIL PROTECTED]
Subject: getting value from bean


hi.

I am new to struts...

I have a problem with getting a value from bean...
here are some pieces of my code where i set and get values:

 In jsp page i have this:
---------------------------------------------------------------------

    <td align="left">
      <html:text property="totalCopies" maxlength="3"/>
    </td>
--------------------------------------------------------------------

 In class i have getter and setter as:
--------------------------------------
 public String getTotalCopies(){
   System.out.println("getting total copies:"+this.totalCopies);
   return this.totalCopies;
 }

 public void setTotalCopies(String totCopy){
   this.totalCopies = totCopy;
   System.out.println("setting total copies:"+this.totalCopies);
 }
-------------------------------------

Print statement of setter is perfectly fine as i expected but
the statement in getter returns null...?? what's wrong?
TIA..

Nishit Trivedi
Software Engineer
Planet Access Networks - An InSage Company
973-691-4704 X157

Reply via email to