FYI, I just found that using setProperty() instead works... is my expectation of setIndexedProperty() incorrect? I suspect it is at this point. Thanks!
Frank -- Frank W. Zammetti Founder and Chief Software Architect Omnytex Technologies http://www.omnytex.com AIM: fzammetti Yahoo: fzammetti MSN: [EMAIL PROTECTED] Java Web Parts - http://javawebparts.sourceforge.net Supplying the wheel, so you don't have to reinvent it! On Thu, June 1, 2006 3:29 pm, Frank W. Zammetti wrote: > Next question :) Because it's related to what I'm doing with the first, I > figured go with the same thread... > > I have an instance of the Test class, which contains the following: > > private List children; > public void setChildren(final List inChildren) { > children = inChildren; > } > public List getChildren() { > return children; > } > > Then, in a class trying to populate this, I have: > > Object obj = new Test(); > List fieldValues = new ArrayList(); > fieldValues.add("test"); > PropertyUtils.setIndexedProperty(obj, "children", fieldValues); > > When I try it, I get: > > java.lang.IllegalArgumentException: Invalid indexed property 'children' > > Not sure what's going on... since this is the version of > setIndexedProperty() without the index, I assume it's going to call > setChildren(List) and not be looking for the setter with the index, > correct? Thanks! > > Frank > > -- > Frank W. Zammetti > Founder and Chief Software Architect > Omnytex Technologies > http://www.omnytex.com > AIM: fzammetti > Yahoo: fzammetti > MSN: [EMAIL PROTECTED] > Java Web Parts - > http://javawebparts.sourceforge.net > Supplying the wheel, so you don't have to reinvent it! > > On Thu, June 1, 2006 2:57 pm, Frank W. Zammetti wrote: >> Yes, that's perfect, didn't know about that. Thanks Craig! >> >> Frank >> >> -- >> Frank W. Zammetti >> Founder and Chief Software Architect >> Omnytex Technologies >> http://www.omnytex.com >> AIM: fzammetti >> Yahoo: fzammetti >> MSN: [EMAIL PROTECTED] >> Java Web Parts - >> http://javawebparts.sourceforge.net >> Supplying the wheel, so you don't have to reinvent it! >> >> On Thu, June 1, 2006 2:36 pm, Craig McClanahan wrote: >>> On 6/1/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: >>>> >>>> Hi, >>>> >>>> I'm struggling a bit with something, and I think I may be making it >>>> harder >>>> than it is. Here's my requirement... >>>> >>>> I need to be able to take an arbitrary bean, and given the name of a >>>> field >>>> in it, determine whether the field is (a) a simple scalar (i.e., >>>> String >>>> for istnance), (b) a subclass of List, (c) a subclass of Map or (d) an >>>> array (of any type). >>>> >>>> I've been playing with PropertyUtils.getPropertyDescriptor(), but I've >>>> kind of gotten stumped where to go after that... I've toyed with >>>> getting >>>> the Class from that, playing with getName() and getInterfaces(), both >>>> of >>>> which get me close, but I'd have to do string comparisons, which isn't >>>> the >>>> right answer I think... I've also thought of getting an instance from >>>> the >>>> Class, then doing a simple instanceof, but of course this won't work >>>> for >>>> Maps and Lists since they can't be instantiated. >>>> >>>> Like I said, I think I may be over-thinking this a bit, hopefully >>>> someone >>>> can quickly set me straight. Also, while I suspect Beanutils will >>>> make >>>> this easier, I don't so much care if I use it or not :) It just >>>> seemed >>>> the natural choice. Thanks! >>> >>> >>> You are probably looking for the isAssignableFrom() method on >>> java.lang.Class, which is the runtime analog to the "instanceof" >>> compile >>> time check. To see if a particular class is a Map (or an impementation >>> of >>> Map), do something like this: >>> >>> Class clazz = ...; >>> if (Map.class.isAssignableFrom(clazz)) { >>> ... yes, this is a Map ... >>> } else { >>> ... no, it is not ... >>> } >>> >>> Craig >>> >>> >>> >>> -- >>>> Frank W. Zammetti >>>> Founder and Chief Software Architect >>>> Omnytex Technologies >>>> http://www.omnytex.com >>>> AIM: fzammetti >>>> Yahoo: fzammetti >>>> MSN: [EMAIL PROTECTED] >>>> Java Web Parts - >>>> http://javawebparts.sourceforge.net >>>> Supplying the wheel, so you don't have to reinvent it! >>>> >>>> --------------------------------------------------------------------- >>>> 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]