You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stephane Cosmeur <co...@gmail.com> on 2010/03/27 07:50:18 UTC

Access to two diffrent beans in one form

Hello
I'm very new on struts 2 and i'm facing a problem i can't resolv. I think it
will be a formality for real users of struts.
I have two actions class, ProductAction and CliendAction. And i want to have
in a jsp two s:select to print the list of my clients and the list of my
products.
To display this jsp i call an action whose associed class is ClientAction.
So my first s:select work well, but i can't see how provide the
ProductAction to my second s:select.
I tried to make an interceptor to "load" the ProductAction but it didn't
work. I tried to use s:bean but it didn t work either. I know my problem can
looks stupid but i really need help ! i'm facing this problem since two
days.

thank you and sorry for my english :)

-- 
Stéphane Cosmeur
06 33 54 36 04

Re: Access to two diffrent beans in one form

Posted by Eduard Neuwirt <ed...@googlemail.com>.
Hello Stephane,

I think this a small differ approach would be better. I would declare 
only once Action for example DisplayAction.
Within this class define two member variables clients and lists. Access 
to these beans via select in the *.jsp.

Something like that:
class DisplayAction ...
{
     List<Client> clients;
     List<Products> products;
     //This will be set if you selects one from the list
     Client client;
     Product product;

     public void prepare()
     {
         clients = someMethodsFillingClients();
         products = someMethodFillingProducts();
     }


}

Display.jsp

<s:action="">
<s:select name="client" list=clients" />
<s:select name="product" list="products"/>
</s:action>


Am 27.03.2010 07:50, schrieb Stephane Cosmeur:
> Hello
> I'm very new on struts 2 and i'm facing a problem i can't resolv. I think it
> will be a formality for real users of struts.
> I have two actions class, ProductAction and CliendAction. And i want to have
> in a jsp two s:select to print the list of my clients and the list of my
> products.
> To display this jsp i call an action whose associed class is ClientAction.
> So my first s:select work well, but i can't see how provide the
> ProductAction to my second s:select.
> I tried to make an interceptor to "load" the ProductAction but it didn't
> work. I tried to use s:bean but it didn t work either. I know my problem can
> looks stupid but i really need help ! i'm facing this problem since two
> days.
>
> thank you and sorry for my english :)
>
>    


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