Struts does not seem to accept a Vector-typed field as a property value. The
form simply fails to load.
I'd happily use LazyList and a Factory together instead of a Vector if it's
easy to implement...
First I wanted to get it working with Vector, then I can easily switch to a
different container.
------------------------------------
In my JSP:
<html:select property="vizsgalatEsOrvos[0]">
------------------------------------
In my bean:
private Vector vizsgalatEsOrvos;
public Vector getVizsgalatEsOrvos() {
return vizsgalatEsOrvos;
}
public void setVizsgalatEsOrvos(Vector vizsgalatEsOrvos) {
this.vizsgalatEsOrvos = vizsgalatEsOrvos;
}
------------------------------------
Instantiating my Vector in the constructor won't help...
Struts should call
myForm.getMyVector().set(0, ?)
Do I need to implement this metod? Do I need to write my own setters/getters to
do this?
How can I do this exactly?
Thanks,
MB
----- Original Message ----
From: Lance <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, April 16, 2007 12:12:00 PM
Subject: Re: Form data to Vector
Lance wrote:
> Sorry, it helps if i read your question fully.
>
> The way to do this is to name your html form elements using in the
> struts (BeanUtils) conventions
> If you have a form element named "myVector[3]" then struts will call
> myForm.getMyVector().set(3, ?)
>
> It is sometimes easiest to use the struts nested tags to do this
>
> <nested:iterate property="myVector">
> <nested:text property="name" />
> <nested:text property="age" />
> </nested:iterate>
>
> will produce
> <input type="text" name="myVector[0].name" value="" />
> <input type="text" name="myVector[0].age" value="" />
> <input type="text" name="myVector[1].name" value="" />
> <input type="text" name="myVector[1].age" value="" />
>
> If you are adding elements to the vector (instead of just editing
> existing vector elements), you might want to use a LazyList and a
> Factory together instead of a Vector, if you do, I can give you a bit
> more help if you need.
>
> Lance.
>
>
> Lance wrote:
>> Only way to get data into a Vector is by a scriptlet or in your action.
>> Struts 2's OGNL has a nice way of doing this but unfortunately with
>> S1 we're left with dirty scriptlets in JSPs some of the time.
>>
>> JSTL has a <c:forTokens /> that sometimes comes in handy where you
>> provide a comma separated list of Strings and iterate through the
>> elements.
>>
>> Balazs Michnay wrote:
>>> Thanks for the reply.
>>> Yes, I know how to use the <logic:iterate> to display the elements
>>> of a Vector (or ArrayList), I just don't see how to put these values
>>> into the Vector. I mean if I have a Vector (or an ArrayList)
>>> property in my form bean, how do I put some of my form data into my
>>> bean property. Do I need to modify the setters/getters? There must
>>> be a way to do this...
>>> And yes, you're right, one the data are in the Vector, I can use
>>> <logic:iterate> to display them.
>>> Thanks for your help,
>>>
>>> Regards,
>>>
>>> MB
>>>
>>> ----- Original Message ----
>>> From: Martin Gainty <[EMAIL PROTECTED]>
>>> To: Struts Users Mailing List <[email protected]>
>>> Sent: Friday, April 13, 2007 3:45:17 PM
>>> Subject: Re: Form data to Vector
>>>
>>> Balazs
>>>
>>> Take a look at
>>> http://struts.apache.org/1.0.2/api/org/apache/struts/taglib/logic/package-summary.html
>>>
>>>
>>> you will see this example of implementing a vector via use of struts
>>> logic:iterate in your jsp
>>>
>>> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
>>> <%
>>> java.util.Vector vector = new java.util.Vector();
>>> vector.add(new Integer(12));
>>> vector.add(new Integer(5));
>>> %>
>>> <logic:iterate id="myCollectionElement" collection="<%= vector %>">
>>> Do something with myCollectionElement
>>> </logic:iterate>
>>> This email message and any files transmitted with it contain
>>> confidential
>>> information intended only for the person(s) to whom this email
>>> message is
>>> addressed. If you have received this email message in error, please
>>> notify
>>> the sender immediately by telephone or email and destroy the original
>>> message without making a copy. Thank you.
>>>
>>> ----- Original Message ----- From: "Balazs Michnay"
>>> <[EMAIL PROTECTED]>
>>> To: "Struts Users Mailing List" <[email protected]>
>>> Sent: Friday, April 13, 2007 4:09 AM
>>> Subject: Form data to Vector
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> I have a form with two submit buttons. One should add the content
>>>> of a text field to a Vector (which is in the form bean?), and the
>>>> other one should point to another page that has access to the
>>>> Vector values.
>>>> I'd like to know how to add form data to a Vector.
>>>> Any help would be appreciated.
>>>>
>>>> Thanks a lot,
>>>>
>>>> MB
>>>>
>>>>
>>>>
>>>> __________________________________________________
>>>> Do You Yahoo!?
>>>> Tired of spam? Yahoo! Mail has the best spam protection around
>>>> http://mail.yahoo.com
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Tired of spam? Yahoo! Mail has the best spam protection around
>>> http://mail.yahoo.com
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com