struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaikar gupta <gupta.jai...@gmail.com>
Subject Re: Only one Object gets initialized in action class?
Date Sun, 03 Mar 2013 11:16:41 GMT
Do you have public setter/getter for your private member varibale in your
Action Class

private CustomerData customerData=null
private CustomerAddress  customerAddress=null;
private ShoppingDetail shoppingDetail=null;
Thanks & Regards

keepFaith,
Jaikar Gupta


On Sun, Mar 3, 2013 at 3:06 PM, Mohit Gupta <motgupta@gmail.com> wrote:

> By initialization i mean  when i hit the url stated in my example, i should
> be able to see below objects should be initialized in my action class
>
> customerData object should be initialized with custName as "Scott"
> customerAddress object should be initialized with street1 as "Escort
> Avenue"
> ShoppingDetail object should be initialized with item as "Laptop"
>
> Yes all my objects have default constructor and have setters for propertu
> for the value i am setting thru s:param.
>
> On Sun, Mar 3, 2013 at 3:28 PM, Lukasz Lenart <lukaszlenart@apache.org
> >wrote:
>
> > What do you mean by initialised? S2 can create objects if they have
> > default constructor and then S2 can apply request params onto
> > corresponded fields (if setters were defined) of these objects.
> >
> > So whit your example all these three object must have default
> > constructors in place and all the fields must have dedicated setters.
> >
> > Ł.
> >
> > 2013/3/3 Mohit Gupta <motgupta@gmail.com>:
> > > Hi Lukasz,
> > >
> > > First of all i would like to know, if i have below code ,how it is
> > supposed
> > > to work
> > >
> > > Here is my action class i.e  DisplayCustomerAction.java which has 3
> type
> > of
> > > instance variable i.e
> > >
> > > private CustomerData customerData=null
> > > private CustomerAddress  customerAddress=null;
> > > private ShoppingDetail shoppingDetail=null;
> > >
> > > // getters and setters of above variable
> > >
> > > Now i have below code snippet in JSP
> > >
> > > <s:url namespace="/customer" action="displayCustomer"
> > > method="displayCustomer"  >
> > >     <s:param name="customerData.custName" value="Scott"></s:param>
> > >     <s:param name="customerAddress.street1" value="Escort
> > Avenue"></s:param>
> > >     <s:param name="shoppingDetail.item" value="Laptop"></s:param>
> > > </s:url>
> > >
> > >
> > > Am i supposed to get all 3 instance variable initialized(i.e
> > customerData,
> > > customerAddress,shoppingDetail) in action class with
> > > the values passed in s:param tag ? This is the main point question
> here.
> > >
> > > What i am experiencing is only one object gets initialized which is
> first
> > > in order as s:param under s:url. In this case customerData.
> > > Similary if i put   <s:param name="shoppingDetail.item"
> > > value="Laptop"></s:param> as first parameter under s:url tag then
only
> > > shoppingDetail gets initialized while rest two are not initialized?
> > >
> > >
> > >
> > > On Sat, Mar 2, 2013 at 8:37 PM, Lukasz Lenart <lukaszlenart@apache.org
> > >wrote:
> > >
> > >> I have tested with the latest version and everything is ok.
> > >>
> > >> Did you try that way <s:param name="customerAddress.street1"
> > >> value="Escort Avenue"/> ?
> > >>
> > >>
> > >> Regards
> > >> --
> > >> Łukasz
> > >> + 48 606 323 122 http://www.lenart.org.pl/
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > >> For additional commands, e-mail: user-help@struts.apache.org
> > >>
> > >>
> >
> >
> >
> > --
> > Łukasz
> > + 48 606 323 122 http://www.lenart.org.pl/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message