commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francois Swiegers <FSwieg...@RUBICO.COM>
Subject [JXPath] Accessing and setting multidimensional arrays
Date Thu, 09 Jan 2003 08:31:46 GMT
How do you access and modify properties that are multidimensional arrays
using JXPath?

Here is my bean:

public Person {
public int[][] getMatrix();
public void setMatrix(int[][] matrix);
}

To access the value of an element [x,y] in the array, I use:

ctx.getValue("person/matrix[x]/.[y]");

This works fine, but is there a better way of doing it?

How can I set the value of element in the Bean?

ctx.setValue("person/matrix[x]/.[y]", "10");

causes:

     [java] org.apache.commons.jxpath.JXPathException: Exception trying to
set value with xpath person/matrix[4]/.[1]; Cannot setValue of an object
that is not some other object's property
     [java] 	at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.setValue(JXPathConte
xtReferenceImpl.java:318)
     [java] 	at
org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.setValue(JXPathConte
xtReferenceImpl.java:309)

Any help/suggestions would be greatly appreciated.

Francois Swiegers
CONFIDENTIALITY NOTICE
This e-mail message (and attachments) contains confidential information
intended only for the person/s to whom it is addressed. It is subject to
legal privilege and any copying or unauthorised disclosure of the contents
other than to the addressee is prohibited. If you have received this e-mail
in error please notify us by telephone and erase all copies of the message
and attachments. Thank you for your assistance.


Mime
View raw message