|
From: Benjamin P. <bpo...@us...> - 2006-09-20 12:51:42
|
Update of /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv29205/src/main/java/org/swixat/databinding Modified Files: Tag: B0_5_5 AbstractPropertySetter.java JComboBoxModelPropertySetter.java JRenderer.java JTableModel.java JTreeNode.java TreeNodeWrapper.java Log Message: Use XPathUtil.applyXPath in all swixat project, this permit to intercept jxpath exception and log real exception. Very useful to debug application. Index: TreeNodeWrapper.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding/TreeNodeWrapper.java,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -C2 -d -r1.2.2.5 -r1.2.2.6 *** TreeNodeWrapper.java 18 Sep 2006 13:07:28 -0000 1.2.2.5 --- TreeNodeWrapper.java 20 Sep 2006 12:51:34 -0000 1.2.2.6 *************** *** 44,47 **** --- 44,48 ---- import org.apache.commons.collections.IteratorUtils; import org.apache.commons.jxpath.JXPathContext; + import org.apache.commons.jxpath.JXPathException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; *************** *** 147,154 **** if (node != null) { uo = node.getUserObject(); - JXPathContext xpath = XPathUtil.newContext(uo); String pathProperty = jnode.getChildsPropertyName(); ! uo = xpath.getValue(pathProperty); } } else { // in last take name --- 148,157 ---- if (node != null) { uo = node.getUserObject(); String pathProperty = jnode.getChildsPropertyName(); ! uo = XPathUtil.applyXPath(pathProperty, uo, null, false); } + } else if (jnode.getUserObject() != null) { + String path = jnode.getUserObject(); + uo = XPathUtil.applyXPath(path, this, null, false); } else { // in last take name Index: AbstractPropertySetter.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding/Attic/AbstractPropertySetter.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** AbstractPropertySetter.java 6 Apr 2006 19:04:24 -0000 1.1.2.4 --- AbstractPropertySetter.java 20 Sep 2006 12:51:33 -0000 1.1.2.5 *************** *** 37,40 **** --- 37,41 ---- import org.swixat.framework.SwiXMLEngine; import org.swixat.framework.SwiXRequest; + import org.swixat.framework.XPathUtil; public abstract class AbstractPropertySetter implements PropertySetter { *************** *** 56,69 **** String defaultValue = (String)jc.getClientProperty("default"); if (defaultValue != null) { - Object data = null; // NOTE: i don't know if for default we must used iterate or no // or perhaps look for defaultIterate ? i found this bad :( ! String iterate = (String)jc.getClientProperty("iterate"); ! if ((iterate != null) && (iterate.equalsIgnoreCase("true"))) { ! data = jxpathContext.iterate(defaultValue); ! } else { ! data = jxpathContext.getValue(defaultValue); ! } log.debug("use default value: '" + data + "'"); setProperty(jc, data); result = true; --- 57,68 ---- String defaultValue = (String)jc.getClientProperty("default"); if (defaultValue != null) { // NOTE: i don't know if for default we must used iterate or no // or perhaps look for defaultIterate ? i found this bad :( ! String iterateString = (String)jc.getClientProperty("iterate"); ! boolean iterate = (iterateString != null) && (iterateString.equalsIgnoreCase("true")); ! Object data = XPathUtil.applyXPath(defaultValue, null, jxpathContext, iterate); ! log.debug("use default value: '" + data + "'"); + setProperty(jc, data); result = true; Index: JTreeNode.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding/JTreeNode.java,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -C2 -d -r1.2.2.5 -r1.2.2.6 *** JTreeNode.java 18 Sep 2006 13:07:28 -0000 1.2.2.5 --- JTreeNode.java 20 Sep 2006 12:51:34 -0000 1.2.2.6 *************** *** 47,52 **** // protected TreeNodeWrapper parentTreeNodeWrapper = null; protected String childsPropertyName = null; - protected String type = null; protected String treeOrigin = null; protected Object originData = null; --- 47,53 ---- // protected TreeNodeWrapper parentTreeNodeWrapper = null; protected String childsPropertyName = null; protected String treeOrigin = null; + protected String userObject = null; + protected String type = null; protected Object originData = null; *************** *** 174,177 **** --- 175,192 ---- } + /** + * @return Returns the userObject. + */ + public String getUserObject() { + return this.userObject; + } + + /** + * @param userObject The userObject to set. + */ + public void setUserObject(String userObject) { + this.userObject = userObject; + } + } // JTreeNode Index: JComboBoxModelPropertySetter.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding/JComboBoxModelPropertySetter.java,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** JComboBoxModelPropertySetter.java 28 Aug 2006 11:47:03 -0000 1.2.2.4 --- JComboBoxModelPropertySetter.java 20 Sep 2006 12:51:33 -0000 1.2.2.5 *************** *** 39,42 **** --- 39,43 ---- import org.apache.commons.logging.LogFactory; import org.swixat.framework.SwiXMLEngine; + import org.swixat.framework.XPathUtil; import org.swixat.util.SwiXUtil; *************** *** 57,62 **** String [] arrayValues = SwiXUtil.split(values); Object [] obj = new Object[arrayValues.length]; for (int i=0; i<arrayValues.length; i++) { ! Object o = engine.getSharedContext().getValue(arrayValues[i]); obj[i] = o; } --- 58,65 ---- String [] arrayValues = SwiXUtil.split(values); Object [] obj = new Object[arrayValues.length]; + JXPathContext context = engine.getSharedContext(); for (int i=0; i<arrayValues.length; i++) { ! String path = arrayValues[i]; ! Object o = XPathUtil.applyXPath(path, null, context, false); obj[i] = o; } Index: JTableModel.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding/JTableModel.java,v retrieving revision 1.2.2.10 retrieving revision 1.2.2.11 diff -C2 -d -r1.2.2.10 -r1.2.2.11 *** JTableModel.java 5 Sep 2006 12:28:52 -0000 1.2.2.10 --- JTableModel.java 20 Sep 2006 12:51:33 -0000 1.2.2.11 *************** *** 411,415 **** jx.getVariables().declareVariable("col", new Integer(col)); ! result = jx.getValue(xpath); } else if (o != null && o.getClass().isArray()) { // data is array of array, use 2nd array for columns --- 411,415 ---- jx.getVariables().declareVariable("col", new Integer(col)); ! result = XPathUtil.applyXPath(xpath, null, jx, false); } else if (o != null && o.getClass().isArray()) { // data is array of array, use 2nd array for columns Index: JRenderer.java =================================================================== RCS file: /cvsroot/swixat/swixat/src/main/java/org/swixat/databinding/Attic/JRenderer.java,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -C2 -d -r1.1.2.6 -r1.1.2.7 *** JRenderer.java 8 Sep 2006 22:05:10 -0000 1.1.2.6 --- JRenderer.java 20 Sep 2006 12:51:33 -0000 1.1.2.7 *************** *** 162,167 **** if (value != null && childsPropertyName != null && !"".equals(childsPropertyName)) { ! JXPathContext xpath = XPathUtil.newContext(value); ! value = xpath.getValue(childsPropertyName); } --- 162,166 ---- if (value != null && childsPropertyName != null && !"".equals(childsPropertyName)) { ! value = XPathUtil.applyXPath(childsPropertyName, value, null, false); } *************** *** 187,192 **** if (object != null && tooltips != null && !"".equals(tooltips)) { ! JXPathContext xpath = XPathUtil.newContext(object); ! Object tmp = xpath.getValue(tooltips); if (tmp != null) { result = tmp.toString(); --- 186,190 ---- if (object != null && tooltips != null && !"".equals(tooltips)) { ! Object tmp = XPathUtil.applyXPath(tooltips, object, null, false); if (tmp != null) { result = tmp.toString(); |