Populate nested properties

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Populate nested properties

José Antonio Delgado Trujillo
Suppose that i have a nested Bean in a model class.


public Class Bean_B{
   private String text;
   private int number;
...
}

public Class Bean_A{
        private Bean_B beanB;
...
}

A form

<s:form action= “register”>
   <s:textField key=“beanA.beanB.text/>
   <s:textField key=“beanA.beanB.number/>
        …
   <s:submit>

When i submit the form the action class populate the nested properties text and number?





Un saludo,
José A.

Reply | Threaded
Open this post in threaded view
|

Re: Populate nested properties

Yasser Zamani-2


On 1/3/2018 1:30 AM, José Antonio Delgado Trujillo wrote:

> Suppose that i have a nested Bean in a model class.
>
>
> public Class Bean_B{
>     private String text;
>     private int number;
> ...
> }
>
> public Class Bean_A{
> private Bean_B beanB;
> ...
> }
>
> A form
>
> <s:form action= “register”>
>     <s:textField key=“beanA.beanB.text/>
>     <s:textField key=“beanA.beanB.number/>
> …
>     <s:submit>
>
> When i submit the form the action class populate the nested properties text and number?

If your action has getBeanA() method and your Bean_A class has
getBeanB() method and your Bean_B class has setText() and setNumber()
method then yes, it should be able to populate them, isn't it?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Populate nested properties

José Antonio Delgado Trujillo
Yes it is but i had a problem with instantiate the both beans.
Now it works and i understand with the message Instancia the bean.
Struts2/ONGL instantiate the beans but you must write the default constructor.

Thanks

> On 3 Jan 2018, at 05:52, Yasser Zamani <[hidden email]> wrote:
>
>
>
> On 1/3/2018 1:30 AM, José Antonio Delgado Trujillo wrote:
>> Suppose that i have a nested Bean in a model class.
>>
>>
>> public Class Bean_B{
>>    private String text;
>>    private int number;
>> ...
>> }
>>
>> public Class Bean_A{
>> private Bean_B beanB;
>> ...
>> }
>>
>> A form
>>
>> <s:form action= “register”>
>>    <s:textField key=“beanA.beanB.text/>
>>    <s:textField key=“beanA.beanB.number/>
>> …
>>    <s:submit>
>>
>> When i submit the form the action class populate the nested properties text and number?
>
> If your action has getBeanA() method and your Bean_A class has
> getBeanB() method and your Bean_B class has setText() and setNumber()
> method then yes, it should be able to populate them, isn't it?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]