indexed property problem

2004-03-18 Thread Axel Groß
Hi Mark!

thanks for your answer
 tdtestPrimKey[${ctr}]/td
evaluates to as it should to testPrimKey[0], testPrimKey[1]..
( i did a stupid mistake in my code ),

On 2004-03-18 at 13:25:22 +0100, Mark Lowe wrote:
 ${testPrimKey[ctr]}
that actually evaluates to nothing
but ${mappedTest.testPrimKey[ctr]}
gets the right result

BUT my original intention (to use it with html:struts) still fails, because
the tag doesnt populate the value for the indexed property:
without using the indexed property:
 html:text name=mappedTest property='testPrimKey'/html:text
- is as expected:
 input type=text name=testPrimKey value=[Ljava...{right object reference} /

with using the indexed property
 html:text name=mappedTest property='testPrimKey[${ctr}]' /
- doesnt put value attribute:
 input type=text name=testPrimKey[0] value= / 
 input type=text name=testPrimKey[1] value= / 
 ...

if anybody could help me with that one, i'd be relieved
thanks,
axel

 
 or perhaps with the wrappers
 
 c:set var=key value=${testPrimKey[ctr]} /
 ${key}
 
  what does that do?
 
 
 On 18 Mar 2004, at 12:46, Axel Groß wrote:
 
 hi all!
 
 while trying to figure out how indexed/mapped properties work I get 
 some strange
 behaviour - I'm pretty sure this doesn't conform to standard (hope I'm
 mistaken):
 logic:iterate id=foo indexId=ctr name=mappedTest 
 property=testPrimKey
   tr
 td${foo}/td
 td${ctr}/td
 tdtestPrimKey[${ctr}]/td
   /tr
 /logic:iterate
 
 evaluates to:
   tr
 tdk1/td
 td0/td
 tdtestPrimKey[]/td
   /tr
   tr
 tdk2/td
 td1/td
 tdtestPrimKey[]/td
   /tr
   ...
 
 where the k1, k2.. are the expected values of key testPrimKey in the
 HashMap put under mappedTest in the PageContext
 BUT ${ctr} gets evaluated to different values
 
 I'm using struts1.1 and tomcat 5.0.19
 so whose wrong?
 me or the result ???
 
 thanks for enlightenment!
 Axel
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: indexed property problem

2004-03-18 Thread Mark Lowe
try

 html-el:text name=mappedTest property=testPrimKey(${ctr}) /



On 18 Mar 2004, at 14:49, Axel Groß wrote:

Hi Mark!

thanks for your answer
   tdtestPrimKey[${ctr}]/td
evaluates to as it should to testPrimKey[0], testPrimKey[1]..
( i did a stupid mistake in my code ),
On 2004-03-18 at 13:25:22 +0100, Mark Lowe wrote:
${testPrimKey[ctr]}
that actually evaluates to nothing
but ${mappedTest.testPrimKey[ctr]}
gets the right result
BUT my original intention (to use it with html:struts) still fails, 
because
the tag doesnt populate the value for the indexed property:
without using the indexed property:
 html:text name=mappedTest property='testPrimKey'/html:text
- is as expected:
 input type=text name=testPrimKey value=[Ljava...{right object 
reference} /

with using the indexed property
 html:text name=mappedTest property='testPrimKey[${ctr}]' /
- doesnt put value attribute:
 input type=text name=testPrimKey[0] value= /
 input type=text name=testPrimKey[1] value= /
 ...
if anybody could help me with that one, i'd be relieved
thanks,
axel
or perhaps with the wrappers

c:set var=key value=${testPrimKey[ctr]} /
${key}
 what does that do?

On 18 Mar 2004, at 12:46, Axel Groß wrote:

hi all!

while trying to figure out how indexed/mapped properties work I get
some strange
behaviour - I'm pretty sure this doesn't conform to standard (hope 
I'm
mistaken):
logic:iterate id=foo indexId=ctr name=mappedTest
property=testPrimKey
 tr
   td${foo}/td
   td${ctr}/td
   tdtestPrimKey[${ctr}]/td
 /tr
/logic:iterate

evaluates to:
 tr
   tdk1/td
   td0/td
   tdtestPrimKey[]/td
 /tr
 tr
   tdk2/td
   td1/td
   tdtestPrimKey[]/td
 /tr
 ...
where the k1, k2.. are the expected values of key testPrimKey in 
the
HashMap put under mappedTest in the PageContext
BUT ${ctr} gets evaluated to different values

I'm using struts1.1 and tomcat 5.0.19
so whose wrong?
me or the result ???
thanks for enlightenment!
Axel
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: indexed property problem

2004-03-18 Thread Axel Groß
On 2004-03-18 at 15:10:47 +0100, Mark Lowe wrote:
 try
 
  html-el:text name=mappedTest property=testPrimKey(${ctr}) /
doesnt exist in struts 1.1,right?
should be evaluated anyway...
i tried now
 html:text name=mappedTest property='testPrimKey[0]' /
- still
 input type=text name=testPrimKey[0] value= /
 
should that version work? if so it doesnt seem to be the EL part which is
amiss.

 
 
 
 
 On 18 Mar 2004, at 14:49, Axel Groß wrote:
 
 Hi Mark!
 
 thanks for your answer
tdtestPrimKey[${ctr}]/td
 evaluates to as it should to testPrimKey[0], testPrimKey[1]..
 ( i did a stupid mistake in my code ),
 
 On 2004-03-18 at 13:25:22 +0100, Mark Lowe wrote:
 ${testPrimKey[ctr]}
 that actually evaluates to nothing
 but ${mappedTest.testPrimKey[ctr]}
 gets the right result
 
 BUT my original intention (to use it with html:struts) still fails, 
 because
 the tag doesnt populate the value for the indexed property:
 without using the indexed property:
  html:text name=mappedTest property='testPrimKey'/html:text
 - is as expected:
  input type=text name=testPrimKey value=[Ljava...{right object 
 reference} /
 
 with using the indexed property
  html:text name=mappedTest property='testPrimKey[${ctr}]' /
 - doesnt put value attribute:
  input type=text name=testPrimKey[0] value= /
  input type=text name=testPrimKey[1] value= /
  ...
 
 if anybody could help me with that one, i'd be relieved
 thanks,
 axel
 
 
 or perhaps with the wrappers
 
 c:set var=key value=${testPrimKey[ctr]} /
 ${key}
 
  what does that do?
 
 
 On 18 Mar 2004, at 12:46, Axel Groß wrote:
 
 hi all!
 
 while trying to figure out how indexed/mapped properties work I get
 some strange
 behaviour - I'm pretty sure this doesn't conform to standard (hope 
 I'm
 mistaken):
 logic:iterate id=foo indexId=ctr name=mappedTest
 property=testPrimKey
  tr
td${foo}/td
td${ctr}/td
tdtestPrimKey[${ctr}]/td
  /tr
 /logic:iterate
 
 evaluates to:
  tr
tdk1/td
td0/td
tdtestPrimKey[]/td
  /tr
  tr
tdk2/td
td1/td
tdtestPrimKey[]/td
  /tr
  ...
 
 where the k1, k2.. are the expected values of key testPrimKey in 
 the
 HashMap put under mappedTest in the PageContext
 BUT ${ctr} gets evaluated to different values
 
 I'm using struts1.1 and tomcat 5.0.19
 so whose wrong?
 me or the result ???
 
 thanks for enlightenment!
 Axel
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: indexed property problem

2004-03-18 Thread Mark Lowe
I thought you were trying to get a mapped property.

What does the structure look like? I cant see what you're drilling to.

On 18 Mar 2004, at 15:23, Axel Groß wrote:

On 2004-03-18 at 15:10:47 +0100, Mark Lowe wrote:
try

 html-el:text name=mappedTest property=testPrimKey(${ctr}) /
doesnt exist in struts 1.1,right?
should be evaluated anyway...
i tried now
 html:text name=mappedTest property='testPrimKey[0]' /
- still
 input type=text name=testPrimKey[0] value= /
should that version work? if so it doesnt seem to be the EL part which  
is
amiss.





On 18 Mar 2004, at 14:49, Axel Groß wrote:

Hi Mark!

thanks for your answer
  tdtestPrimKey[${ctr}]/td
evaluates to as it should to testPrimKey[0], testPrimKey[1]..
( i did a stupid mistake in my code ),
On 2004-03-18 at 13:25:22 +0100, Mark Lowe wrote:
${testPrimKey[ctr]}
that actually evaluates to nothing
but ${mappedTest.testPrimKey[ctr]}
gets the right result
BUT my original intention (to use it with html:struts) still fails,
because
the tag doesnt populate the value for the indexed property:
without using the indexed property:
html:text name=mappedTest property='testPrimKey'/html:text
- is as expected:
input type=text name=testPrimKey value=[Ljava...{right object
reference} /
with using the indexed property
html:text name=mappedTest property='testPrimKey[${ctr}]' /
- doesnt put value attribute:
input type=text name=testPrimKey[0] value= /
input type=text name=testPrimKey[1] value= /
...
if anybody could help me with that one, i'd be relieved
thanks,
axel
or perhaps with the wrappers

c:set var=key value=${testPrimKey[ctr]} /
${key}
what does that do?

On 18 Mar 2004, at 12:46, Axel Groß wrote:

hi all!

while trying to figure out how indexed/mapped properties work I get
some strange
behaviour - I'm pretty sure this doesn't conform to standard (hope
I'm
mistaken):
logic:iterate id=foo indexId=ctr name=mappedTest
property=testPrimKey
tr
  td${foo}/td
  td${ctr}/td
  tdtestPrimKey[${ctr}]/td
/tr
/logic:iterate
evaluates to:
tr
  tdk1/td
  td0/td
  tdtestPrimKey[]/td
/tr
tr
  tdk2/td
  td1/td
  tdtestPrimKey[]/td
/tr
...
where the k1, k2.. are the expected values of key testPrimKey in
the
HashMap put under mappedTest in the PageContext
BUT ${ctr} gets evaluated to different values
I'm using struts1.1 and tomcat 5.0.19
so whose wrong?
me or the result ???
thanks for enlightenment!
Axel
--- 
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:  
[EMAIL PROTECTED]



 
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: indexed property problem

2004-03-18 Thread Axel Groß
i was trying to figure out how to use indexed properties.
in the end I want to pass a collection of name/value pairs to the form,
which the user can edit and then check those and maybe pass the new values
to business logic.
at the moment i'm trying to do this with two String[], one called keys the
other one called values.
For passing those values to the browser, I try using indexed propertie.
As I'm not sure how it has to look like in html so that struts will
populate the ActionForm I'm stuck with the html:text tag, which I can't 
make work the way I'd like it to

testPrimKey is a String[] which should put values into the html,
which should get put into the ActionForm, which has an indexed 
property called 'keys'
so if I'm guessing right it should look in the end like
 input type=text value=k1 name=keys[0] /
but if I have that i get a 

ServletException: BeanUtils.populate
..(RequestUtils.java:1254)
root cause
 ArrayIndexOutOfBoundsException
   java.lang.reflect.Aray.set(Native Method)

...
so maybe that means, the html syntax is ok; but i don't know..
:/

On 2004-03-18 at 17:17:10 +0100, Mark Lowe wrote:
 I thought you were trying to get a mapped property.
 
 What does the structure look like? I cant see what you're drilling to.
 
 
 On 18 Mar 2004, at 15:23, Axel Groß wrote:
 
 On 2004-03-18 at 15:10:47 +0100, Mark Lowe wrote:
 try
 
  html-el:text name=mappedTest property=testPrimKey(${ctr}) /
 doesnt exist in struts 1.1,right?
 should be evaluated anyway...
 i tried now
  html:text name=mappedTest property='testPrimKey[0]' /
 - still
  input type=text name=testPrimKey[0] value= /
 
 should that version work? if so it doesnt seem to be the EL part which  
 is
 amiss.
 
 
 
 
 
 On 18 Mar 2004, at 14:49, Axel Groß wrote:
 
 Hi Mark!
 
 thanks for your answer
   tdtestPrimKey[${ctr}]/td
 evaluates to as it should to testPrimKey[0], testPrimKey[1]..
 ( i did a stupid mistake in my code ),
 
 On 2004-03-18 at 13:25:22 +0100, Mark Lowe wrote:
 ${testPrimKey[ctr]}
 that actually evaluates to nothing
 but ${mappedTest.testPrimKey[ctr]}
 gets the right result
 
 BUT my original intention (to use it with html:struts) still fails,
 because
 the tag doesnt populate the value for the indexed property:
 without using the indexed property:
 html:text name=mappedTest property='testPrimKey'/html:text
 - is as expected:
 input type=text name=testPrimKey value=[Ljava...{right object
 reference} /
 
 with using the indexed property
 html:text name=mappedTest property='testPrimKey[${ctr}]' /
 - doesnt put value attribute:
 input type=text name=testPrimKey[0] value= /
 input type=text name=testPrimKey[1] value= /
 ...
 
 if anybody could help me with that one, i'd be relieved
 thanks,
 axel
 
 
 or perhaps with the wrappers
 
 c:set var=key value=${testPrimKey[ctr]} /
 ${key}
 
 what does that do?
 
 
 On 18 Mar 2004, at 12:46, Axel Groß wrote:
 
 hi all!
 
 while trying to figure out how indexed/mapped properties work I get
 some strange
 behaviour - I'm pretty sure this doesn't conform to standard (hope
 I'm
 mistaken):
 logic:iterate id=foo indexId=ctr name=mappedTest
 property=testPrimKey
 tr
   td${foo}/td
   td${ctr}/td
   tdtestPrimKey[${ctr}]/td
 /tr
 /logic:iterate
 
 evaluates to:
 tr
   tdk1/td
   td0/td
   tdtestPrimKey[]/td
 /tr
 tr
   tdk2/td
   td1/td
   tdtestPrimKey[]/td
 /tr
 ...
 
 where the k1, k2.. are the expected values of key testPrimKey in
 the
 HashMap put under mappedTest in the PageContext
 BUT ${ctr} gets evaluated to different values
 
 I'm using struts1.1 and tomcat 5.0.19
 so whose wrong?
 me or the result ???
 
 thanks for enlightenment!
 Axel
 
 --- 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail:  
 [EMAIL PROTECTED]
 
 
 
  
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: indexed property problem

2004-03-18 Thread Axel Groß
went through the beanutils code to find the reason for the
ArrayIndexOutOfBounds.
found that it doesn't use my setter method, which would adjust the array
size, but just my getter method (which returns an array, which isn't big
enough); moving over to lists instead

so i suppose my html was correct.
the html:text issues are still not working anyway :/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Indexed Property Problem.

2003-07-08 Thread Anurag Garg
Hi All,

I know this question would have been posted earlier also.
I want to know how to work with the indexed form fields and their property
in the action form class.
Any link or ample code will be helpful.

Anurag Garg


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Indexed property problem

2003-02-25 Thread Richard Kooijman
Hello,

I have a problem setting form properties that have a type of String[]. I have seen 
similar problems in other messages that came around, but now of them or their answers 
seem to address the specfic issue we encountered.

Somewhere in Struts (see stack trace below) the Array.set() method tries to fill in 
the String array using the indices from the form parameters of the submit request. The 
array that that method uses or gets passed has not been allocated to be able to hold 
the number of parameters we tries to pass on. In fact it is of String[0].

Somehow you would expect that either Struts of the DynaActionForm beans should make an 
extra step and pre-allocate the array before setting the individual array elements.
This does not seem to be done. 

My questions are:
- do we use the feature in the wrong manner?
- do we need to specify that array size somewhere, with which Struts can pre-allocate 
the array?
- did we stumble on a bug?

Any input appreciated,


Richard Kooijman

Here follows some details on this issue:

I have this defined in my struts-config.xml:

 form-bean dynamic=true name=soortopvanglocatieForm 
type=org.apache.struts.validator.DynaValidatorForm
 form-property name=vorm type=java.lang.String /
 form-property name=voorkeurenKinderdagverblijfVoorkeur 
type=java.lang.String[] /
 form-property 
name=voorkeurenBuitenschoolseopvangVoorkeur type=java.lang.String /
 form-property 
name=voorkeurenBuitenschoolseopvangBasisschool type=java.lang.String /
 form-property name=voorkeurenHalvedagopvangVoorkeur 
type=java.lang.String /

 /form-bean

Note the array of String as the type of voorkeurenKinderdagverblijfVoorkeur.

In my .jsp I have this:
logic:iterate id=voorkeur
name=soortopvanglocatieForm
property=voorkeurenKinderdagverblijfVoorkeur
indexId=i
html:text name=soortopvanglocatieForm 
property='%=voorkeurenKinderdagverblijfVoorkeur[ + i + ]%' size=20/
/logic:iterate

What happens is that the initial display of the page looks just fine. 
Things start to get messy when I essentially try to add or delete a 
html:text field (by trying to change the array of 
voorkeurenKinderdagverblijfVoorkeur in the background).
When I hit one of the two buttons I defined, Struts start parsing the 
POST information but halts in the bean populate() section:

java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.set(Native Method)
at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:457)
at 
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1414)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1097)
at 
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
at 
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)

I debugged this in the source and the array that is to be set by 
Array.set is of type String[0].
And the particular instance that is being set is at index 1.
Anyway, it seems that the array properties in the DynaValidatorForm we 
are using aren't being allocated.

Any ideas or hints?

We use Struts 1.1b3, bean-utils 1.6.1.


Regards, Richard.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed property problem

2003-02-25 Thread Brandon Goodin
In the commons-collections use ListUtils.LazyList to initialize a list in
the bean.

Brandon Goodin
Phase Web and Multimedia
PO Box 85
Whitefish MT 59937
P (406) 862-2245
F (406) 862-0354
[EMAIL PROTECTED]
http://www.phase.ws


-Original Message-
From: Richard Kooijman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 25, 2003 1:56 PM
To: [EMAIL PROTECTED]
Subject: Indexed property problem


Hello,

I have a problem setting form properties that have a type of String[]. I
have seen similar problems in other messages that came around, but now of
them or their answers seem to address the specfic issue we encountered.

Somewhere in Struts (see stack trace below) the Array.set() method tries to
fill in the String array using the indices from the form parameters of the
submit request. The array that that method uses or gets passed has not been
allocated to be able to hold the number of parameters we tries to pass on.
In fact it is of String[0].

Somehow you would expect that either Struts of the DynaActionForm beans
should make an extra step and pre-allocate the array before setting the
individual array elements.
This does not seem to be done.

My questions are:
- do we use the feature in the wrong manner?
- do we need to specify that array size somewhere, with which Struts can
pre-allocate the array?
- did we stumble on a bug?

Any input appreciated,


Richard Kooijman

Here follows some details on this issue:

I have this defined in my struts-config.xml:

 form-bean dynamic=true name=soortopvanglocatieForm
type=org.apache.struts.validator.DynaValidatorForm
 form-property name=vorm type=java.lang.String /
 form-property name=voorkeurenKinderdagverblijfVoorkeur
type=java.lang.String[] /
 form-property
name=voorkeurenBuitenschoolseopvangVoorkeur type=java.lang.String /
 form-property
name=voorkeurenBuitenschoolseopvangBasisschool type=java.lang.String /
 form-property name=voorkeurenHalvedagopvangVoorkeur
type=java.lang.String /

 /form-bean

Note the array of String as the type of voorkeurenKinderdagverblijfVoorkeur.

In my .jsp I have this:
logic:iterate id=voorkeur
name=soortopvanglocatieForm
property=voorkeurenKinderdagverblijfVoorkeur
indexId=i
html:text name=soortopvanglocatieForm
property='%=voorkeurenKinderdagverblijfVoorkeur[ + i + ]%' size=20/
/logic:iterate

What happens is that the initial display of the page looks just fine.
Things start to get messy when I essentially try to add or delete a
html:text field (by trying to change the array of
voorkeurenKinderdagverblijfVoorkeur in the background).
When I hit one of the two buttons I defined, Struts start parsing the
POST information but halts in the bean populate() section:

java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.set(Native Method)
at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:457)
at
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.
java:1414)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1097)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:798)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)

I debugged this in the source and the array that is to be set by
Array.set is of type String[0].
And the particular instance that is being set is at index 1.
Anyway, it seems that the array properties in the DynaValidatorForm we
are using aren't being allocated.

Any ideas or hints?

We use Struts 1.1b3, bean-utils 1.6.1.


Regards, Richard.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Indexed property problem

2003-02-21 Thread Richard Kooijman
Hello,

I have a problem setting form properties that have a type of String[].

I have this defined in my struts-config.xml:

 form-bean dynamic=true name=soortopvanglocatieForm 
type=org.apache.struts.validator.DynaValidatorForm
 form-property name=vorm type=java.lang.String /
 form-property name=voorkeurenKinderdagverblijfVoorkeur 
type=java.lang.String[] /
 form-property 
name=voorkeurenBuitenschoolseopvangVoorkeur type=java.lang.String /
 form-property 
name=voorkeurenBuitenschoolseopvangBasisschool type=java.lang.String /
 form-property name=voorkeurenHalvedagopvangVoorkeur 
type=java.lang.String /

 /form-bean

Note the array of String as the type of voorkeurenKinderdagverblijfVoorkeur.

In my .jsp I have this:
logic:iterate id=voorkeur
name=soortopvanglocatieForm
property=voorkeurenKinderdagverblijfVoorkeur
indexId=i
html:text name=soortopvanglocatieForm 
property='%=voorkeurenKinderdagverblijfVoorkeur[ + i + ]%' size=20/
/logic:iterate

What happens is that the initial display of the page looks just fine. 
Things start to get messy when I essentially try to add or delete a 
html:text field (by trying to change the array of 
voorkeurenKinderdagverblijfVoorkeur in the background).
When I hit one of the two buttons I defined, Struts start parsing the 
POST information but halts in the bean populate() section:

java.lang.ArrayIndexOutOfBoundsException
at java.lang.reflect.Array.set(Native Method)
at org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:457)
at 
org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1414)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:1013)
at org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:808)
at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1097)
at 
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:798)
at 
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1422)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:523)

I debugged this in the source and the array that is to be set by 
Array.set is of type String[0].
And the particular instance that is being set is at index 1.
Anyway, it seems that the array properties in the DynaValidatorForm we 
are using aren't being allocated.

Any ideas or hints?

We use Struts 1.1b3, bean-utils 1.6.1.


Regards, Richard.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




html:select with indexed property problem

2001-04-11 Thread Dennis

Hi,

I'm having trouble getting an html:select tag to properly set an indexed
bean property.  The tag I'm using looks like:

html:select property="values[0]"

My Action form includes the following:

  protected String[]mValues;

  public void setValues(int index, String value) {
if (mValues == null) {
mValues = new String[10];
}
mValues[index] = value;
}

public String getValues(int index) {
return mValues[index];
}

public String[] getValues() {
return mValues;
}

public void setValues(String[] vals) {
mValues = vals;
}

The attempt to set the values[0] property fails in the SelectTag
doStartTag() method with an InvocationTargetException, which results in the
following JspException:

Root cause:
javax.servlet.jsp.JspException: Getter for property values[0] threw
exception: java.lang.NullPointerException:
at org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:301)


I've successfully used the same form, and set the indexed properties using
html:hidden, but cannot get the html:select to work.  Any thoughts?

Thanks,

Dennis




RE: html:select with indexed property problem

2001-04-11 Thread Dennis

I found my problem - sorry for the bother.  I had an unitialized array in
there that was getting returned to the SelectTag.  Thanks anyway..

Dennis

-Original Message-
From: Dennis [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 11, 2001 4:03 PM
To: [EMAIL PROTECTED]
Subject: html:select with indexed property problem


Hi,

I'm having trouble getting an html:select tag to properly set an indexed
bean property.  The tag I'm using looks like:

html:select property="values[0]"

My Action form includes the following:

  protected String[]mValues;

  public void setValues(int index, String value) {
if (mValues == null) {
mValues = new String[10];
}
mValues[index] = value;
}

public String getValues(int index) {
return mValues[index];
}

public String[] getValues() {
return mValues;
}

public void setValues(String[] vals) {
mValues = vals;
}

The attempt to set the values[0] property fails in the SelectTag
doStartTag() method with an InvocationTargetException, which results in the
following JspException:

Root cause:
javax.servlet.jsp.JspException: Getter for property values[0] threw
exception: java.lang.NullPointerException:
at org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:301)


I've successfully used the same form, and set the indexed properties using
html:hidden, but cannot get the html:select to work.  Any thoughts?

Thanks,

Dennis