You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Prasenjit <pr...@quinnox.com> on 2003/05/19 08:57:18 UTC
help
Hello Everybody,
I have a problem. We are using struts for the first time in our
project.
I understand from <html:text> tag that that the property
attribute has to be present in the form bean as a class variable.
So if I have a tag <html:text name=formBeanMapName property=
firstName > , My form bean shud have a class level variable as firstName.
However in have dynamically generated rows like
------------- R1 -----------------------
------------- R2 -----------------------
------------- R3 -----------------------
each row contains a text box and a select box . When I say addMore more
rows can be added. So obviously I cannot possibly know the names of the text
field and select box in advance. Therefore I cannot have those fields in my
Form Bean. So how do I go about it. (After saying AddRow the new screen
that opens should also show the previously added data in the text field and
select box.)
If anyone has a solution for it please let me know.
Thanks in advance,
Regards,
Prasenjit.
Re: help
Posted by Rick Reumann <r...@reumann.net>.
On Mon, 19 May 2003 12:27:18 +0530, Prasenjit wrote:
> Hello Everybody,
>
> I have a problem. We are using struts for the first time in our
> project.
>
> I understand from <html:text> tag that that the property
> attribute has to be present in the form bean as a class variable.
>
> So if I have a tag <html:text name=formBeanMapName property=
> firstName > , My form bean shud have a class level variable as firstName.
>
>
> However in have dynamically generated rows like
>
> ------------- R1 -----------------------
> ------------- R2 -----------------------
> ------------- R3 -----------------------
>
> each row contains a text box and a select box . When I say addMore more
> rows can be added. So obviously I cannot possibly know the names of the text
> field and select box in advance. Therefore I cannot have those fields in my
> Form Bean. So how do I go about it. (After saying AddRow the new screen
> that opens should also show the previously added data in the text field and
> select box.)
IMO, the easiest way to accomplish what you want is to create a "Person"
bean, which has your properties (firstName, selectBoxProperty, etc.) but
then you set up your FormBean with a collection of these Person beans
(ArrayList of Person beans). When you submit the page each of your Person
objects in your List will automagically be updated accordingly.
--
Rick
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: help
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
It sounds to me as if you are describing a list of records where each
line has the same properties repeated. In this case you would use a
logic:iterate tag and enclose the 2 fields within it, so that the fields
are repeated with indices (indexed fields). I am sure there are some
tutorials or faqs about indexed fields on the struts website. HTH
Adam
Prasenjit wrote:
> Hello Everybody,
>
> I have a problem. We are using struts for the first time in our
> project.
>
> I understand from <html:text> tag that that the property
> attribute has to be present in the form bean as a class variable.
>
> So if I have a tag <html:text name=”formBeanMapName” property=”
> firstName” > , My form bean shud’ have a class level variable as firstName.
>
>
> However in have dynamically generated rows like
>
> ------------- R1 -----------------------
> ------------- R2 -----------------------
> ------------- R3 -----------------------
>
> each row contains a text box and a select box . When I say addMore more
> rows can be added. So obviously I cannot possibly know the names of the text
> field and select box in advance. Therefore I cannot have those fields in my
> Form Bean. So how do I go about it. (After saying AddRow the new screen
> that opens should also show the previously added data in the text field and
> select box.)
>
>
> If anyone has a solution for it please let me know.
> Thanks in advance,
>
> Regards,
> Prasenjit.
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: help
Posted by Vinod Kumar R <vi...@wisorindia.soft.net>.
hi,
try this one,
1) First of all have a formbean with properties firstName and mySelect.
2) Now have a collection formbean which can store a collection of these
individual formbeans.
3) In your JSP iterate over the collection formbean and do appropriate
action over the individual formebeans.
ex:
<logic:iterate id="myCollection" name="myCollectionFormBean" scope=either a
request or session type = fully qualified type of ur formbean which stores
the firstName>
<html:text name="myCollection" property="firstName"/>
</logic:iterate>
so when ever the user click on the addrow bitton submit the form to the
controller and add one more element into your collection.
i hopr this solves your problem
regards
vinod
-----Original Message-----
From: Prasenjit [mailto:prasenjitn@quinnox.com]
Sent: Monday, May 19, 2003 12:27 PM
To: struts-user@jakarta.apache.org
Subject: <html:text> help
Hello Everybody,
I have a problem. We are using struts for the first time in our
project.
I understand from <html:text> tag that that the property
attribute has to be present in the form bean as a class variable.
So if I have a tag <html:text name=formBeanMapName property=
firstName > , My form bean shud have a class level variable as firstName.
However in have dynamically generated rows like
------------- R1 -----------------------
------------- R2 -----------------------
------------- R3 -----------------------
each row contains a text box and a select box . When I say addMore more
rows can be added. So obviously I cannot possibly know the names of the text
field and select box in advance. Therefore I cannot have those fields in my
Form Bean. So how do I go about it. (After saying AddRow the new screen
that opens should also show the previously added data in the text field and
select box.)
If anyone has a solution for it please let me know.
Thanks in advance,
Regards,
Prasenjit.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org