You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "KARR, DAVID" <dk...@att.com> on 2017/06/13 18:10:48 UTC

[jxpath] How to add an entry to a list?

If a property in a bean I'm trying to manipulate with jxpath is a List, how do I set a value in an entry of that list?

I read the info at "Modifying Object Graphs", but it's still not clear from this how I would do this.

I've figured out how to get the list created, either with an explicit "setValue()", or with a "createPathAndSetValue()" along with a factory and createObject() method set to look for that property, but if I try to set a value into the list, it fails apparently because the list is still zero size.

The only way I can hack this to work is to initialize the list property to an ArrayList with the required number of dummy elements already added to it, so the subscript reference works.

I'm using JXPath so that I can write tests with a little less boilerplate and focus on pure business logic.  Ideally, I'd like JXPath (or perhaps a factory) to do the "obvious stuff".


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: [jxpath] How to add an entry to a list?

Posted by "KARR, DAVID" <dk...@att.com>.
> -----Original Message-----
> From: Bruno P. Kinoshita [mailto:brunodepaulak@yahoo.com.br.INVALID]
> Sent: Wednesday, June 14, 2017 3:18 AM
> To: Commons Users List <us...@commons.apache.org>
> Subject: Re: [jxpath] How to add an entry to a list?
> 
> Hi David,
> 
> Do you have some code you could share? Maybe looking at your code others
> (I would try as well, but can't promise will know how to help) might be
> able to help.

Thanks for replying.  I posted more detailed code samples on SO: https://stackoverflow.com/questions/44530112/how-to-get-jxpath-to-cleanly-set-list-collection-entries .

> ________________________________
> From: "KARR, DAVID" <dk...@att.com>
> To: Commons Users List <us...@commons.apache.org>
> Sent: Wednesday, 14 June 2017 6:11 AM
> Subject: [jxpath] How to add an entry to a list?
> 
> 
> 
> If a property in a bean I'm trying to manipulate with jxpath is a List,
> how do I set a value in an entry of that list?
> 
> 
> I read the info at "Modifying Object Graphs", but it's still not clear
> from this how I would do this.
> 
> 
> I've figured out how to get the list created, either with an explicit
> "setValue()", or with a "createPathAndSetValue()" along with a factory
> and createObject() method set to look for that property, but if I try to
> set a value into the list, it fails apparently because the list is still
> zero size.
> 
> 
> The only way I can hack this to work is to initialize the list property
> to an ArrayList with the required number of dummy elements already added
> to it, so the subscript reference works.
> 
> 
> I'm using JXPath so that I can write tests with a little less
> boilerplate and focus on pure business logic.  Ideally, I'd like JXPath
> (or perhaps a factory) to do the "obvious stuff".
> 
> 
> 
> ---------------------------------------------------------------------
> 
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> 
> For additional commands, e-mail: user-help@commons.apache.org
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org


Re: [jxpath] How to add an entry to a list?

Posted by "Bruno P. Kinoshita" <br...@yahoo.com.br.INVALID>.
Hi David,

Do you have some code you could share? Maybe looking at your code others (I would try as well, but can't promise will know how to help) might be able to help.

Cheers
Bruno


________________________________
From: "KARR, DAVID" <dk...@att.com>
To: Commons Users List <us...@commons.apache.org> 
Sent: Wednesday, 14 June 2017 6:11 AM
Subject: [jxpath] How to add an entry to a list?



If a property in a bean I'm trying to manipulate with jxpath is a List, how do I set a value in an entry of that list?


I read the info at "Modifying Object Graphs", but it's still not clear from this how I would do this.


I've figured out how to get the list created, either with an explicit "setValue()", or with a "createPathAndSetValue()" along with a factory and createObject() method set to look for that property, but if I try to set a value into the list, it fails apparently because the list is still zero size.


The only way I can hack this to work is to initialize the list property to an ArrayList with the required number of dummy elements already added to it, so the subscript reference works.


I'm using JXPath so that I can write tests with a little less boilerplate and focus on pure business logic.  Ideally, I'd like JXPath (or perhaps a factory) to do the "obvious stuff".



---------------------------------------------------------------------

To unsubscribe, e-mail: user-unsubscribe@commons.apache.org

For additional commands, e-mail: user-help@commons.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org