You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Oleg V Alexeev <go...@penza.net> on 2000/11/09 11:38:14 UTC
Re[2]: complex, multidimensional properties
Hello Craig,
I have same problem. Some time ago I try to solve it by rewriting some
portion of code of AcrionServlet. I modify code to support such
properties as myProperty[1], myProperty[2] with indexed
setters, getters:
public void setMyProperty( int index, String value ) {}
public String getMyProperty( int index ) {}
In my database environment I have resultset with records wich contain
some entity info and id for it. Ids in resultset are not
continuous and I need to have 'real' ids of entities in setter to
modify target table in accordance with ids.
I think using of such indexed peoperties as:
public vois getMyProperty( String [] values ) {}
is not good idea in such case because of this method uses transfer of
large amount of data.
But my version of ActionServlet is limited against original version -
it is not support nested proeprties there - only simple and indexed.
Thursday, November 09, 2000, 4:30:58 AM, you wrote:
CRM> Eric wrote:
>> Sorry to post a similar question many times, but I'm striving to get
>> an answer before the prototype of my project is due.
>>
CRM> Sorry for not being able to give a comprehensive answer earlier ... I've
CRM> had more emergencies this week than I care to think about :-(.
>>
>> I'm looking for a way to deal with properties that correspond to form
>> parameters such as Zoo1Animal1, Zoo1Animal2, Zoo2Animal1, etc. I
>> would like them represented as two arrays in two seperate beans (a
>> Zoo array of AnimalForm objects and an Animal array of Strings in the
>> AnimalForm bean). This seems like something that could be used by a
>> lot of complex input forms (especially ones that strive to keep inputs
>> on one page).
>>
CRM> I am still not sure that I understand the data model you are trying to
CRM> achieve. Could you sketch out a few simple class and method signatures
CRM> that illustrate the pattern?
>>
>> My question is, why does BeanUtils.populate not use
>> PropertyUtils.setProperty? It seems like PropertyUtils.setProperty
>> would do exactly what I want...is it used anywhere? Is there some tag
>> that corresponds to it?
>>
CRM> PropertyUtils.setProperty does not do any type conversions -- it assumes
CRM> that your arguments are compatible and will throw exceptions if not.
CRM> BeanUtils.populate knows that the input values are strings, so it looks at
CRM> what the data type of the underlying property is and tries to do the right
CRM> thing. (In the future, it will also respect the existence of
CRM> PropertyEditor classes if you have them for the data types used by your
CRM> beans).
CRM> If you want to populate things yourself with PropertyUtils.setProperty,
CRM> this should be possible -- you have access to all of the incoming
CRM> information in the request. But you will need to be responsible for
CRM> converting from Strings (the way you receive all request parameters) to
CRM> the corresponding data types.
>>
>> Also, is what I'm considering reasonable? Has anyone dealt with
>> issues like this before? Is it possible for me to modify
>> BeanUtils.populate so that it uses PropertyUtils.setProperty and thus
>> provides the functionality I desire? Are there some inherant problems
>> with this that I'm not seeing?
>>
>> thanx,
>> eric.
CRM> Craig McClanahan
--
Best regards,
Oleg mailto:gonza@penza.net