You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vi...@siriuscom.com on 2004/03/03 23:02:30 UTC

Question

Hello All,

I have a requirement, where on page we have 3 fields named condition1, 
condition2, and condition3. These three fields are text fields.
No problem in doing that. 
Now the requirement is that if the user wants to add more conditions they 
can click on the more conditions link and then we are suppose to 
show next three conditions.. and this process in not finite it can be any 
number of conditions. How can i handle that ? Any solution. I heard 
something like indexed property in ActionForm. Can someone please explain 
what is the best to do in such scineario.

Thanks in advance,
Vijay.

RE: Question

Posted by Andrew Hill <an...@gridnode.com>.
If you want to get better answers quicker Id suggest you learn the concept
of 'meaningful subjects' for emails. "Question" is not a meaningful subject
line.
http://www.catb.org/~esr/faqs/smart-questions.html

Ok now on to your "Question".
Having been kind enough to take the time to read it to see if its something
I can help with I have found you are in luck. So here is an answer:

For 'complex' stuff like this you could make full use nested beans as
demonstrated in this tutorial:
http://www.keyboardmonkey.com/next/index.jsp


In this case as its just one column of text fields you could also get away
with just using a collection property in your actionform, and you could back
it with a lazy list from commons collections:
http://jakarta.apache.org/commons/collections/api/index.html

Your view rendering code could iterate through the collection rendering out
fields for each:
ie renders the html: <input name="condition[3]" value="foo"/> (I think the
nested tags can do the indexing for you if your using JSP? not sure.  Dont
use jsp myself)

Your 'add' button or 'conditions link' or whatever would submit and on the
server side you try to get the next three items from the lazylist causing
them to be instatntiated by the factory you specify. On return to the view
the extra fields are rendered ready for input.

-----Original Message-----
From: Vijay.Kukreja@siriuscom.com [mailto:Vijay.Kukreja@siriuscom.com]
Sent: Thursday, 4 March 2004 06:03
To: struts-user@jakarta.apache.org
Subject: Question


Hello All,

I have a requirement, where on page we have 3 fields named condition1,
condition2, and condition3. These three fields are text fields.
No problem in doing that.
Now the requirement is that if the user wants to add more conditions they
can click on the more conditions link and then we are suppose to
show next three conditions.. and this process in not finite it can be any
number of conditions. How can i handle that ? Any solution. I heard
something like indexed property in ActionForm. Can someone please explain
what is the best to do in such scineario.

Thanks in advance,
Vijay.


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