You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Upasana Sharma <sh...@gmail.com> on 2010/06/08 09:38:33 UTC

same bean multiple fields

I have a form which needs to submit multiple values(user name , last used
etc) of the same type for different users on a single click. But my form
bean refers to one user's field only . i need to submit all the fields using
a single form button click. how should i use beans n jsp in this case.

-- 
Thanks in advance
Upasana Sharma

Re: same bean multiple fields

Posted by satyanarayana katta <sa...@gmail.com>.
One way to have hidden variables for the remaining fields under the  
same form and by default all the fo fields get submitted

Sent from my iPhone

On Jun 8, 2010, at 1:05 AM, Upasana Sharma <sh...@gmail.com> wrote:

> Thanks for ur reply... by i m using struts 2.0...
>
> 2010/6/8 Paweł Wielgus <po...@gmail.com>
>
>> Hi Upasana,
>> if You are using struts1 You may look here:
>> http://struts.apache.org/1.x/struts-taglib/indexedprops.html
>>
>> Best greetings,
>> Paweł Wielgus.
>>
>>
>> 2010/6/8 Upasana Sharma <sh...@gmail.com>:
>>> I have a form which needs to submit multiple values(user name ,  
>>> last used
>>> etc) of the same type for different users on a single click. But  
>>> my form
>>> bean refers to one user's field only . i need to submit all the  
>>> fields
>> using
>>> a single form button click. how should i use beans n jsp in this  
>>> case.
>>>
>>> --
>>> Thanks in advance
>>> Upasana Sharma
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> -- 
> Thanks and Regards
> Upasana Sharma

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


Re: same bean multiple fields

Posted by Ken <ke...@aerose.com>.
Okay let me see if I understood correctly:

If your form were to be represented with xml... it would look something
like this:
<form>
   <person>
      <data/>
  </person>
   <person>
      <data/>
  </person>
  ...
</form>

So you could be submitting many people? I have not done this but I'd
like to know if this would work:
http://struts.apache.org/1.x/struts-taglib/faq.html#multiple  (I know
this is a struts1 example, but it is simple)
That is the section under: "Can I use multiple HTML form elements with
the same name?" 

Struts 2 can convert incoming data and place it in a bean that has a
primitive types or their object type, along with array, List and Map (or
even a custom type). In this case we want to populate an array or List.
Going with a List is probably easier than an array.  Each time a form
element with the name you've set occurs the beans setter will be
called.  

If you need to display the values of the array on a JSP use the
<iterator> tag http://struts.apache.org/2.1.8.1/docs/iterator.html
To push each element on to the value stack.

====================
If you are going to be working with struts 2, the book Struts 2 in
Action is worth getting, listing 5.2 "Targeting array properties for
data transfer" on page 112, is a nice example.


On Wed, 2010-06-09 at 10:26 +0530, Upasana Sharma wrote:

> hi thanks for ur reply
> 
> I do have working examples of both 1 and 2... using single bean and form
> where elements occur for once ..
> 
> 
> 
> On Wed, Jun 9, 2010 at 1:10 AM, Ken <ke...@aerose.com> wrote:
> 
> > 1) Do you have a working example where a single value is put on a form
> > and then displayed with a JSP?
> > 2)Do know how to display data on a JSP with Struts 2 from a bean?
> >
> > If you have 1) you are far closer than you think, if not but you
> > understand the magic behind number 2) then you'll see that Struts 2 is
> > able to perform similar magic from the Form to the Bean as it can from
> > the Bean to the JSP.
> >
> > Let us know where you are at exactly.
> >
> >
> > On Tue, 2010-06-08 at 13:35 +0530, Upasana Sharma wrote:
> >
> > > Thanks for ur reply... by i m using struts 2.0...
> > >
> > > 2010/6/8 Paweł Wielgus <po...@gmail.com>
> > >
> > > > Hi Upasana,
> > > > if You are using struts1 You may look here:
> > > > http://struts.apache.org/1.x/struts-taglib/indexedprops.html
> > > >
> > > > Best greetings,
> > > > Paweł Wielgus.
> > > >
> > > >
> > > > 2010/6/8 Upasana Sharma <sh...@gmail.com>:
> > > > > I have a form which needs to submit multiple values(user name , last
> > used
> > > > > etc) of the same type for different users on a single click. But my
> > form
> > > > > bean refers to one user's field only . i need to submit all the
> > fields
> > > > using
> > > > > a single form button click. how should i use beans n jsp in this
> > case.
> > > > >
> > > > > --
> > > > > Thanks in advance
> > > > > Upasana Sharma
> > > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: user-help@struts.apache.org

Re: same bean multiple fields

Posted by Upasana Sharma <sh...@gmail.com>.
hi thanks for ur reply

I do have working examples of both 1 and 2... using single bean and form
where elements occur for once ..



On Wed, Jun 9, 2010 at 1:10 AM, Ken <ke...@aerose.com> wrote:

> 1) Do you have a working example where a single value is put on a form
> and then displayed with a JSP?
> 2)Do know how to display data on a JSP with Struts 2 from a bean?
>
> If you have 1) you are far closer than you think, if not but you
> understand the magic behind number 2) then you'll see that Struts 2 is
> able to perform similar magic from the Form to the Bean as it can from
> the Bean to the JSP.
>
> Let us know where you are at exactly.
>
>
> On Tue, 2010-06-08 at 13:35 +0530, Upasana Sharma wrote:
>
> > Thanks for ur reply... by i m using struts 2.0...
> >
> > 2010/6/8 Paweł Wielgus <po...@gmail.com>
> >
> > > Hi Upasana,
> > > if You are using struts1 You may look here:
> > > http://struts.apache.org/1.x/struts-taglib/indexedprops.html
> > >
> > > Best greetings,
> > > Paweł Wielgus.
> > >
> > >
> > > 2010/6/8 Upasana Sharma <sh...@gmail.com>:
> > > > I have a form which needs to submit multiple values(user name , last
> used
> > > > etc) of the same type for different users on a single click. But my
> form
> > > > bean refers to one user's field only . i need to submit all the
> fields
> > > using
> > > > a single form button click. how should i use beans n jsp in this
> case.
> > > >
> > > > --
> > > > Thanks in advance
> > > > Upasana Sharma
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
>
>
>


-- 
Thanks and Regards
Upasana Sharma

Re: same bean multiple fields

Posted by Ken <ke...@aerose.com>.
1) Do you have a working example where a single value is put on a form
and then displayed with a JSP? 
2)Do know how to display data on a JSP with Struts 2 from a bean?

If you have 1) you are far closer than you think, if not but you
understand the magic behind number 2) then you'll see that Struts 2 is
able to perform similar magic from the Form to the Bean as it can from
the Bean to the JSP.

Let us know where you are at exactly.


On Tue, 2010-06-08 at 13:35 +0530, Upasana Sharma wrote:

> Thanks for ur reply... by i m using struts 2.0...
> 
> 2010/6/8 Paweł Wielgus <po...@gmail.com>
> 
> > Hi Upasana,
> > if You are using struts1 You may look here:
> > http://struts.apache.org/1.x/struts-taglib/indexedprops.html
> >
> > Best greetings,
> > Paweł Wielgus.
> >
> >
> > 2010/6/8 Upasana Sharma <sh...@gmail.com>:
> > > I have a form which needs to submit multiple values(user name , last used
> > > etc) of the same type for different users on a single click. But my form
> > > bean refers to one user's field only . i need to submit all the fields
> > using
> > > a single form button click. how should i use beans n jsp in this case.
> > >
> > > --
> > > Thanks in advance
> > > Upasana Sharma
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org



Re: same bean multiple fields

Posted by Upasana Sharma <sh...@gmail.com>.
Thanks for ur reply... by i m using struts 2.0...

2010/6/8 Paweł Wielgus <po...@gmail.com>

> Hi Upasana,
> if You are using struts1 You may look here:
> http://struts.apache.org/1.x/struts-taglib/indexedprops.html
>
> Best greetings,
> Paweł Wielgus.
>
>
> 2010/6/8 Upasana Sharma <sh...@gmail.com>:
> > I have a form which needs to submit multiple values(user name , last used
> > etc) of the same type for different users on a single click. But my form
> > bean refers to one user's field only . i need to submit all the fields
> using
> > a single form button click. how should i use beans n jsp in this case.
> >
> > --
> > Thanks in advance
> > Upasana Sharma
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Thanks and Regards
Upasana Sharma

Re: same bean multiple fields

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Upasana,
if You are using struts1 You may look here:
http://struts.apache.org/1.x/struts-taglib/indexedprops.html

Best greetings,
Paweł Wielgus.


2010/6/8 Upasana Sharma <sh...@gmail.com>:
> I have a form which needs to submit multiple values(user name , last used
> etc) of the same type for different users on a single click. But my form
> bean refers to one user's field only . i need to submit all the fields using
> a single form button click. how should i use beans n jsp in this case.
>
> --
> Thanks in advance
> Upasana Sharma
>

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