Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Error using Indexed property

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to use Indexed properties in my application. I have declared the form bean to have a property "multiobjects" in struts-config.xml

<form-property name="multiobjects" type="views.MultiObjects[]"/>


In my Action class, I am populating this object in a for loop - the values are coming from the database.

------------------------------------------------------------------
int listSize = dataList.size();
view = new MultiObjects[listSize];

for(int i = 0; i <listSize; i++)
{
UserData uData = (UserData) dataList.get(i);

view[i] = new MultiObjects();
logger.debug(2,"about to populate view");
view[i].setConf(uData.conf);
view[i].setDisplay(uData.display);
view[i].setId(uData.id);
}

PropertyUtils.setIndexedProperty(form, "multiobjects", view);
------------------------------------------------------------------

But when I try to access this form property in my jsp page, I get the error;
java.lang.IllegalArgumentException: Invalid indexed property 'multiobjects'
at org.apache.commons.beanutils.PropertyUtils.setIndexedProperty(PropertyUtils.java:1353)

What am I missing here ?

Thanks for your response,
Mallika.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Show us the JSP code that references the multiobjects property.
 
Mallika R Kumar
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I actually get this error when I get to the jsp page, I haven't even started accessing the multiobjects yet. I have to create dynamic select boxes, and store user-entered values for them in the multiobjects property. But setting the indexed property in my action class is giving me the error.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you are setting the entire MultiObjects[] array at one time, you should not use setIndexedProperty. This method is only for setting a single element of the array. I'd recommend you set the property in this way:

form.set("multiobjects", view);
 
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!