0001: /*
0002: * Copyright 2005 Joe Walker
0003: *
0004: * Licensed under the Apache License, Version 2.0 (the "License");
0005: * you may not use this file except in compliance with the License.
0006: * You may obtain a copy of the License at
0007: *
0008: * http://www.apache.org/licenses/LICENSE-2.0
0009: *
0010: * Unless required by applicable law or agreed to in writing, software
0011: * distributed under the License is distributed on an "AS IS" BASIS,
0012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013: * See the License for the specific language governing permissions and
0014: * limitations under the License.
0015: */
0016: package jsx3.chart;
0017:
0018: import org.directwebremoting.ScriptBuffer;
0019: import org.directwebremoting.proxy.ScriptProxy;
0020: import org.directwebremoting.proxy.io.Context;
0021:
0022: /**
0023: * The base class for all charts in this package. Encapsulates common functionality shared by all charts.
0024:
0025: In general, a chart is responsible for managing its children components and handling any coordination
0026: between them. A chart always manages the layout of its children.
0027:
0028: All charts can have the following children:
0029:
0030: {0,1} jsx3.chart.ChartLabel, will render as the chart's title
0031: {0,1} Legend, will render as the chart's legend
0032: {0,n} Series, will render the chart's data series; in general a subclass of Chart will only allow a certain subclass of Series
0033: * @author Joe Walker [joe at getahead dot org]
0034: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0035: */
0036: public class Chart extends jsx3.vector.Block {
0037: /**
0038: * All reverse ajax proxies need context to work from
0039: * @param scriptProxy The place we are writing scripts to
0040: * @param context The script that got us to where we are now
0041: */
0042: public Chart(Context context, String extension,
0043: ScriptProxy scriptProxy) {
0044: super (context, extension, scriptProxy);
0045: }
0046:
0047: /**
0048: * The instance initializer.
0049: * @param name the GI name of the instance
0050: * @param left left position (in pixels) of the chart relative to its parent container
0051: * @param top top position (in pixels) of the chart relative to its parent container
0052: * @param width width (in pixels) of the chart
0053: * @param height height (in pixels) of the chart
0054: */
0055: public Chart(String name, int left, int top, int width, int height) {
0056: super ((Context) null, (String) null, (ScriptProxy) null);
0057: ScriptBuffer script = new ScriptBuffer();
0058: script.appendCall("new Chart", name, left, top, width, height);
0059: setInitScript(script);
0060: }
0061:
0062: /**
0063: * Returns the titlePlacement field, the quadrant in which to place the title.
0064: * @param callback titlePlacement, one of {'top','right','bottom','left'}
0065: */
0066: @SuppressWarnings("unchecked")
0067: public void getTitlePlacement(
0068: org.directwebremoting.proxy.Callback<String> callback) {
0069: ScriptBuffer script = new ScriptBuffer();
0070: String callbackPrefix = "";
0071:
0072: if (callback != null) {
0073: callbackPrefix = "var reply = ";
0074: }
0075:
0076: script.appendCall(callbackPrefix + getContextPath()
0077: + "getTitlePlacement");
0078:
0079: if (callback != null) {
0080: String key = org.directwebremoting.extend.CallbackHelper
0081: .saveCallback(callback, String.class);
0082: script
0083: .appendCall("__System.activateCallback", key,
0084: "reply");
0085: }
0086:
0087: getScriptProxy().addScript(script);
0088: }
0089:
0090: /**
0091: * Sets the titlePlacement field.
0092: * @param titlePlacement the new value for titlePlacement, one of {'top','right','bottom','left'}
0093: */
0094: public void setTitlePlacement(String titlePlacement) {
0095: ScriptBuffer script = new ScriptBuffer();
0096: script.appendCall(getContextPath() + "setTitlePlacement",
0097: titlePlacement);
0098: getScriptProxy().addScript(script);
0099: }
0100:
0101: /**
0102: * Returns the legendPlacement field, the quadrant in which to place the legend.
0103: * @param callback legendPlacement, one of {'top','right','bottom','left'}
0104: */
0105: @SuppressWarnings("unchecked")
0106: public void getLegendPlacement(
0107: org.directwebremoting.proxy.Callback<String> callback) {
0108: ScriptBuffer script = new ScriptBuffer();
0109: String callbackPrefix = "";
0110:
0111: if (callback != null) {
0112: callbackPrefix = "var reply = ";
0113: }
0114:
0115: script.appendCall(callbackPrefix + getContextPath()
0116: + "getLegendPlacement");
0117:
0118: if (callback != null) {
0119: String key = org.directwebremoting.extend.CallbackHelper
0120: .saveCallback(callback, String.class);
0121: script
0122: .appendCall("__System.activateCallback", key,
0123: "reply");
0124: }
0125:
0126: getScriptProxy().addScript(script);
0127: }
0128:
0129: /**
0130: * Sets the legendPlacement field.
0131: * @param legendPlacement the new value for legendPlacement, one of {'top','right','bottom','left'}
0132: */
0133: public void setLegendPlacement(String legendPlacement) {
0134: ScriptBuffer script = new ScriptBuffer();
0135: script.appendCall(getContextPath() + "setLegendPlacement",
0136: legendPlacement);
0137: getScriptProxy().addScript(script);
0138: }
0139:
0140: /**
0141: * Returns the dataPadding field, the CSS padding value that determines the padding around the data area, ie "10" or "5 0 5 0".
0142: * @param callback dataPadding
0143: */
0144: @SuppressWarnings("unchecked")
0145: public void getDataPadding(
0146: org.directwebremoting.proxy.Callback<String> callback) {
0147: ScriptBuffer script = new ScriptBuffer();
0148: String callbackPrefix = "";
0149:
0150: if (callback != null) {
0151: callbackPrefix = "var reply = ";
0152: }
0153:
0154: script.appendCall(callbackPrefix + getContextPath()
0155: + "getDataPadding");
0156:
0157: if (callback != null) {
0158: String key = org.directwebremoting.extend.CallbackHelper
0159: .saveCallback(callback, String.class);
0160: script
0161: .appendCall("__System.activateCallback", key,
0162: "reply");
0163: }
0164:
0165: getScriptProxy().addScript(script);
0166: }
0167:
0168: /**
0169: * Sets the dataPadding field.
0170: * @param dataPadding the new value for dataPadding
0171: */
0172: public void setDataPadding(String dataPadding) {
0173: ScriptBuffer script = new ScriptBuffer();
0174: script.appendCall(getContextPath() + "setDataPadding",
0175: dataPadding);
0176: getScriptProxy().addScript(script);
0177: }
0178:
0179: /**
0180: * Returns the borderColor field, the RGB color to render the chart's border.
0181: * @param callback borderColor
0182: */
0183: @SuppressWarnings("unchecked")
0184: public void getBorderColor(
0185: org.directwebremoting.proxy.Callback<String> callback) {
0186: ScriptBuffer script = new ScriptBuffer();
0187: String callbackPrefix = "";
0188:
0189: if (callback != null) {
0190: callbackPrefix = "var reply = ";
0191: }
0192:
0193: script.appendCall(callbackPrefix + getContextPath()
0194: + "getBorderColor");
0195:
0196: if (callback != null) {
0197: String key = org.directwebremoting.extend.CallbackHelper
0198: .saveCallback(callback, String.class);
0199: script
0200: .appendCall("__System.activateCallback", key,
0201: "reply");
0202: }
0203:
0204: getScriptProxy().addScript(script);
0205: }
0206:
0207: /**
0208: * Sets the borderColor field.
0209: * @param borderColor the new value for borderColor
0210: */
0211: public void setBorderColor(Integer borderColor) {
0212: ScriptBuffer script = new ScriptBuffer();
0213: script.appendCall(getContextPath() + "setBorderColor",
0214: borderColor);
0215: getScriptProxy().addScript(script);
0216: }
0217:
0218: /**
0219: * Sets the borderColor field.
0220: * @param borderColor the new value for borderColor
0221: */
0222: public void setBorderColor(String borderColor) {
0223: ScriptBuffer script = new ScriptBuffer();
0224: script.appendCall(getContextPath() + "setBorderColor",
0225: borderColor);
0226: getScriptProxy().addScript(script);
0227: }
0228:
0229: /**
0230: * Returns the borderWidth field, the pixel width of the chart's border.
0231: * @param callback borderWidth
0232: */
0233: @SuppressWarnings("unchecked")
0234: public void getBorderWidth(
0235: org.directwebremoting.proxy.Callback<Integer> callback) {
0236: ScriptBuffer script = new ScriptBuffer();
0237: String callbackPrefix = "";
0238:
0239: if (callback != null) {
0240: callbackPrefix = "var reply = ";
0241: }
0242:
0243: script.appendCall(callbackPrefix + getContextPath()
0244: + "getBorderWidth");
0245:
0246: if (callback != null) {
0247: String key = org.directwebremoting.extend.CallbackHelper
0248: .saveCallback(callback, Integer.class);
0249: script
0250: .appendCall("__System.activateCallback", key,
0251: "reply");
0252: }
0253:
0254: getScriptProxy().addScript(script);
0255: }
0256:
0257: /**
0258: * Sets the borderWidth field.
0259: * @param borderWidth the new value for borderWidth
0260: */
0261: public void setBorderWidth(int borderWidth) {
0262: ScriptBuffer script = new ScriptBuffer();
0263: script.appendCall(getContextPath() + "setBorderWidth",
0264: borderWidth);
0265: getScriptProxy().addScript(script);
0266: }
0267:
0268: /**
0269: * Returns the borderAlpha field, the opacity to render the chart's border.
0270: * @param callback borderAlpha
0271: */
0272: @SuppressWarnings("unchecked")
0273: public void getBorderAlpha(
0274: org.directwebremoting.proxy.Callback<Float> callback) {
0275: ScriptBuffer script = new ScriptBuffer();
0276: String callbackPrefix = "";
0277:
0278: if (callback != null) {
0279: callbackPrefix = "var reply = ";
0280: }
0281:
0282: script.appendCall(callbackPrefix + getContextPath()
0283: + "getBorderAlpha");
0284:
0285: if (callback != null) {
0286: String key = org.directwebremoting.extend.CallbackHelper
0287: .saveCallback(callback, Float.class);
0288: script
0289: .appendCall("__System.activateCallback", key,
0290: "reply");
0291: }
0292:
0293: getScriptProxy().addScript(script);
0294: }
0295:
0296: /**
0297: * Sets the borderAlpha field.
0298: * @param borderAlpha the new value for borderAlpha
0299: */
0300: public void setBorderAlpha(float borderAlpha) {
0301: ScriptBuffer script = new ScriptBuffer();
0302: script.appendCall(getContextPath() + "setBorderAlpha",
0303: borderAlpha);
0304: getScriptProxy().addScript(script);
0305: }
0306:
0307: /**
0308: * Returns the alpha field, the opacity to render the chart's background.
0309: * @param callback alpha
0310: */
0311: @SuppressWarnings("unchecked")
0312: public void getAlpha(
0313: org.directwebremoting.proxy.Callback<Float> callback) {
0314: ScriptBuffer script = new ScriptBuffer();
0315: String callbackPrefix = "";
0316:
0317: if (callback != null) {
0318: callbackPrefix = "var reply = ";
0319: }
0320:
0321: script.appendCall(callbackPrefix + getContextPath()
0322: + "getAlpha");
0323:
0324: if (callback != null) {
0325: String key = org.directwebremoting.extend.CallbackHelper
0326: .saveCallback(callback, Float.class);
0327: script
0328: .appendCall("__System.activateCallback", key,
0329: "reply");
0330: }
0331:
0332: getScriptProxy().addScript(script);
0333: }
0334:
0335: /**
0336: * Sets the alpha field.
0337: * @param alpha the new value for alpha
0338: */
0339: public void setAlpha(float alpha) {
0340: ScriptBuffer script = new ScriptBuffer();
0341: script.appendCall(getContextPath() + "setAlpha", alpha);
0342: getScriptProxy().addScript(script);
0343: }
0344:
0345: /**
0346: * Returns the list of Series children.
0347: */
0348: @SuppressWarnings("unchecked")
0349: public void getSeries(
0350: org.directwebremoting.proxy.Callback<Object[]> callback) {
0351: ScriptBuffer script = new ScriptBuffer();
0352: String callbackPrefix = "";
0353:
0354: if (callback != null) {
0355: callbackPrefix = "var reply = ";
0356: }
0357:
0358: script.appendCall(callbackPrefix + getContextPath()
0359: + "getSeries");
0360:
0361: if (callback != null) {
0362: String key = org.directwebremoting.extend.CallbackHelper
0363: .saveCallback(callback, Object[].class);
0364: script
0365: .appendCall("__System.activateCallback", key,
0366: "reply");
0367: }
0368:
0369: getScriptProxy().addScript(script);
0370: }
0371:
0372: /**
0373: * Returns the index of a series in the list of series children.
0374: * @param s
0375: * @param callback the index or -1 if not found
0376: */
0377: @SuppressWarnings("unchecked")
0378: public void getSeriesIndex(jsx3.chart.Series s,
0379: org.directwebremoting.proxy.Callback<Integer> callback) {
0380: ScriptBuffer script = new ScriptBuffer();
0381: String callbackPrefix = "";
0382:
0383: if (callback != null) {
0384: callbackPrefix = "var reply = ";
0385: }
0386:
0387: script.appendCall(callbackPrefix + getContextPath()
0388: + "getSeriesIndex", s);
0389:
0390: if (callback != null) {
0391: String key = org.directwebremoting.extend.CallbackHelper
0392: .saveCallback(callback, Integer.class);
0393: script
0394: .appendCall("__System.activateCallback", key,
0395: "reply");
0396: }
0397:
0398: getScriptProxy().addScript(script);
0399: }
0400:
0401: /**
0402: * Find the first jsx3.chart.ChartLabel child
0403: */
0404: @SuppressWarnings("unchecked")
0405: public jsx3.chart.ChartLabel getChartTitle() {
0406: String extension = "getChartTitle().";
0407: try {
0408: java.lang.reflect.Constructor<jsx3.chart.ChartLabel> ctor = jsx3.chart.ChartLabel.class
0409: .getConstructor(Context.class, String.class,
0410: ScriptProxy.class);
0411: return ctor.newInstance(this , extension, getScriptProxy());
0412: } catch (Exception ex) {
0413: throw new IllegalArgumentException("Unsupported type: "
0414: + jsx3.chart.ChartLabel.class.getName());
0415: }
0416: }
0417:
0418: /**
0419: * Find the first Legend child
0420: */
0421: @SuppressWarnings("unchecked")
0422: public jsx3.chart.Legend getLegend() {
0423: String extension = "getLegend().";
0424: try {
0425: java.lang.reflect.Constructor<jsx3.chart.Legend> ctor = jsx3.chart.Legend.class
0426: .getConstructor(Context.class, String.class,
0427: ScriptProxy.class);
0428: return ctor.newInstance(this , extension, getScriptProxy());
0429: } catch (Exception ex) {
0430: throw new IllegalArgumentException("Unsupported type: "
0431: + jsx3.chart.Legend.class.getName());
0432: }
0433: }
0434:
0435: /**
0436: * in general the chart legend renders one entry for every series in the chart, override this method to show categories in the legend
0437: * @param callback <code>jsx3.chart.Legend.SHOW_SERIES</code>
0438: */
0439: @SuppressWarnings("unchecked")
0440: public void getLegendEntryType(
0441: org.directwebremoting.proxy.Callback<Integer> callback) {
0442: ScriptBuffer script = new ScriptBuffer();
0443: String callbackPrefix = "";
0444:
0445: if (callback != null) {
0446: callbackPrefix = "var reply = ";
0447: }
0448:
0449: script.appendCall(callbackPrefix + getContextPath()
0450: + "getLegendEntryType");
0451:
0452: if (callback != null) {
0453: String key = org.directwebremoting.extend.CallbackHelper
0454: .saveCallback(callback, Integer.class);
0455: script
0456: .appendCall("__System.activateCallback", key,
0457: "reply");
0458: }
0459:
0460: getScriptProxy().addScript(script);
0461: }
0462:
0463: /**
0464: * Note that this method is very expensive because it causes the entire chart to be redrawn. It is recommended that
0465: the methods in the CDF interface which cause this method to be called, be passed bRedraw=false to prevent this
0466: method from being called.
0467: */
0468: public void redrawRecord() {
0469: ScriptBuffer script = new ScriptBuffer();
0470: script.appendCall(getContextPath() + "redrawRecord");
0471: getScriptProxy().addScript(script);
0472: }
0473:
0474: /**
0475: * Resets the XML source document stored in the server cache under the XML ID of this object to an empty CDF
0476: document.
0477: */
0478: public void clearXmlData() {
0479: ScriptBuffer script = new ScriptBuffer();
0480: script.appendCall(getContextPath() + "clearXmlData");
0481: getScriptProxy().addScript(script);
0482: }
0483:
0484: /**
0485: * Returns whether this object removes its XML and XSL source documents from the cache of its server when it
0486: is destroyed.
0487: * @param callback <code>CLEANUPRESOURCES</code> or <code>SHARERESOURCES</code>.
0488: */
0489: @SuppressWarnings("unchecked")
0490: public void getShareResources(
0491: org.directwebremoting.proxy.Callback<Integer> callback) {
0492: ScriptBuffer script = new ScriptBuffer();
0493: String callbackPrefix = "";
0494:
0495: if (callback != null) {
0496: callbackPrefix = "var reply = ";
0497: }
0498:
0499: script.appendCall(callbackPrefix + getContextPath()
0500: + "getShareResources");
0501:
0502: if (callback != null) {
0503: String key = org.directwebremoting.extend.CallbackHelper
0504: .saveCallback(callback, Integer.class);
0505: script
0506: .appendCall("__System.activateCallback", key,
0507: "reply");
0508: }
0509:
0510: getScriptProxy().addScript(script);
0511: }
0512:
0513: /**
0514: * Returns the XML source document of this object. The XML document is determined by the following steps:
0515:
0516: If an XML document exists in the server cache under an ID equal to the XML ID of this object, that
0517: document is returned.
0518: If the XML string of this object is not empty, a new document is created by parsing this string.
0519: If the XML URL of this object is not empty, a new document is created by parsing the file at the location
0520: specified by the URL resolved against the server owning this object.
0521: Otherwise, an empty CDF document is returned.
0522:
0523: If a new document is created for this object (any of the steps listed above except for the first one), the
0524: following actions are also taken:
0525:
0526: If creating the document resulted in an error (XML parsing error, file not found error, etc) the offending
0527: document is returned immediately.
0528: Otherwise, setSourceXML is called on this object, passing in the created document.
0529: */
0530: @SuppressWarnings("unchecked")
0531: public jsx3.xml.CdfDocument getXML() {
0532: String extension = "getXML().";
0533: try {
0534: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0535: .getConstructor(Context.class, String.class,
0536: ScriptProxy.class);
0537: return ctor.newInstance(this , extension, getScriptProxy());
0538: } catch (Exception ex) {
0539: throw new IllegalArgumentException("Unsupported type: "
0540: + jsx3.xml.CdfDocument.class.getName());
0541: }
0542: }
0543:
0544: /**
0545: * Returns the XML source document of this object. The XML document is determined by the following steps:
0546:
0547: If an XML document exists in the server cache under an ID equal to the XML ID of this object, that
0548: document is returned.
0549: If the XML string of this object is not empty, a new document is created by parsing this string.
0550: If the XML URL of this object is not empty, a new document is created by parsing the file at the location
0551: specified by the URL resolved against the server owning this object.
0552: Otherwise, an empty CDF document is returned.
0553:
0554: If a new document is created for this object (any of the steps listed above except for the first one), the
0555: following actions are also taken:
0556:
0557: If creating the document resulted in an error (XML parsing error, file not found error, etc) the offending
0558: document is returned immediately.
0559: Otherwise, setSourceXML is called on this object, passing in the created document.
0560: * @param returnType The expected return type
0561: */
0562: @SuppressWarnings("unchecked")
0563: public <T> T getXML(Class<T> returnType) {
0564: String extension = "getXML().";
0565: try {
0566: java.lang.reflect.Constructor<T> ctor = returnType
0567: .getConstructor(Context.class, String.class,
0568: ScriptProxy.class);
0569: return ctor.newInstance(this , extension, getScriptProxy());
0570: } catch (Exception ex) {
0571: throw new IllegalArgumentException(
0572: "Unsupported return type: " + returnType.getName());
0573: }
0574: }
0575:
0576: /**
0577: * Returns the XML ID of this object.
0578: * @param callback the XML ID.
0579: */
0580: @SuppressWarnings("unchecked")
0581: public void getXMLId(
0582: org.directwebremoting.proxy.Callback<String> callback) {
0583: ScriptBuffer script = new ScriptBuffer();
0584: String callbackPrefix = "";
0585:
0586: if (callback != null) {
0587: callbackPrefix = "var reply = ";
0588: }
0589:
0590: script.appendCall(callbackPrefix + getContextPath()
0591: + "getXMLId");
0592:
0593: if (callback != null) {
0594: String key = org.directwebremoting.extend.CallbackHelper
0595: .saveCallback(callback, String.class);
0596: script
0597: .appendCall("__System.activateCallback", key,
0598: "reply");
0599: }
0600:
0601: getScriptProxy().addScript(script);
0602: }
0603:
0604: /**
0605: * Returns the XML string of this object.
0606: */
0607: @SuppressWarnings("unchecked")
0608: public void getXMLString(
0609: org.directwebremoting.proxy.Callback<String> callback) {
0610: ScriptBuffer script = new ScriptBuffer();
0611: String callbackPrefix = "";
0612:
0613: if (callback != null) {
0614: callbackPrefix = "var reply = ";
0615: }
0616:
0617: script.appendCall(callbackPrefix + getContextPath()
0618: + "getXMLString");
0619:
0620: if (callback != null) {
0621: String key = org.directwebremoting.extend.CallbackHelper
0622: .saveCallback(callback, String.class);
0623: script
0624: .appendCall("__System.activateCallback", key,
0625: "reply");
0626: }
0627:
0628: getScriptProxy().addScript(script);
0629: }
0630:
0631: /**
0632: * Returns the list of XML transformers of this object.
0633: */
0634: @SuppressWarnings("unchecked")
0635: public void getXMLTransformers(
0636: org.directwebremoting.proxy.Callback<Object[]> callback) {
0637: ScriptBuffer script = new ScriptBuffer();
0638: String callbackPrefix = "";
0639:
0640: if (callback != null) {
0641: callbackPrefix = "var reply = ";
0642: }
0643:
0644: script.appendCall(callbackPrefix + getContextPath()
0645: + "getXMLTransformers");
0646:
0647: if (callback != null) {
0648: String key = org.directwebremoting.extend.CallbackHelper
0649: .saveCallback(callback, Object[].class);
0650: script
0651: .appendCall("__System.activateCallback", key,
0652: "reply");
0653: }
0654:
0655: getScriptProxy().addScript(script);
0656: }
0657:
0658: /**
0659: * Returns the XML URL of this object.
0660: */
0661: @SuppressWarnings("unchecked")
0662: public void getXMLURL(
0663: org.directwebremoting.proxy.Callback<String> callback) {
0664: ScriptBuffer script = new ScriptBuffer();
0665: String callbackPrefix = "";
0666:
0667: if (callback != null) {
0668: callbackPrefix = "var reply = ";
0669: }
0670:
0671: script.appendCall(callbackPrefix + getContextPath()
0672: + "getXMLURL");
0673:
0674: if (callback != null) {
0675: String key = org.directwebremoting.extend.CallbackHelper
0676: .saveCallback(callback, String.class);
0677: script
0678: .appendCall("__System.activateCallback", key,
0679: "reply");
0680: }
0681:
0682: getScriptProxy().addScript(script);
0683: }
0684:
0685: /**
0686: * Returns the XSL source document of this object. The XSL document is determined by the following steps:
0687:
0688: If an XSL document exists in the server cache under an ID equal to the XSL ID of this object, that
0689: document is returned.
0690: (Deprecated) If the XSL string of this object is not null, a new document is created by parsing this string.
0691: (Deprecated) If the XSL URL of this object is not null, a new document is created by parsing the file at the location
0692: specified by the URL resolved against the server owning this object.
0693: Otherwise, the default stylesheet (Cacheable.DEFAULTSTYLESHEET) is returned.
0694: * @return the XSL source document.
0695: */
0696: @SuppressWarnings("unchecked")
0697: public jsx3.xml.CdfDocument getXSL() {
0698: String extension = "getXSL().";
0699: try {
0700: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0701: .getConstructor(Context.class, String.class,
0702: ScriptProxy.class);
0703: return ctor.newInstance(this , extension, getScriptProxy());
0704: } catch (Exception ex) {
0705: throw new IllegalArgumentException("Unsupported type: "
0706: + jsx3.xml.CdfDocument.class.getName());
0707: }
0708: }
0709:
0710: /**
0711: * Returns the XSL source document of this object. The XSL document is determined by the following steps:
0712:
0713: If an XSL document exists in the server cache under an ID equal to the XSL ID of this object, that
0714: document is returned.
0715: (Deprecated) If the XSL string of this object is not null, a new document is created by parsing this string.
0716: (Deprecated) If the XSL URL of this object is not null, a new document is created by parsing the file at the location
0717: specified by the URL resolved against the server owning this object.
0718: Otherwise, the default stylesheet (Cacheable.DEFAULTSTYLESHEET) is returned.
0719: * @param returnType The expected return type
0720: * @return the XSL source document.
0721: */
0722: @SuppressWarnings("unchecked")
0723: public <T> T getXSL(Class<T> returnType) {
0724: String extension = "getXSL().";
0725: try {
0726: java.lang.reflect.Constructor<T> ctor = returnType
0727: .getConstructor(Context.class, String.class,
0728: ScriptProxy.class);
0729: return ctor.newInstance(this , extension, getScriptProxy());
0730: } catch (Exception ex) {
0731: throw new IllegalArgumentException(
0732: "Unsupported return type: " + returnType.getName());
0733: }
0734: }
0735:
0736: /**
0737: * Returns the XSL ID of this object.
0738: */
0739: @SuppressWarnings("unchecked")
0740: public void getXSLId(
0741: org.directwebremoting.proxy.Callback<String> callback) {
0742: ScriptBuffer script = new ScriptBuffer();
0743: String callbackPrefix = "";
0744:
0745: if (callback != null) {
0746: callbackPrefix = "var reply = ";
0747: }
0748:
0749: script.appendCall(callbackPrefix + getContextPath()
0750: + "getXSLId");
0751:
0752: if (callback != null) {
0753: String key = org.directwebremoting.extend.CallbackHelper
0754: .saveCallback(callback, String.class);
0755: script
0756: .appendCall("__System.activateCallback", key,
0757: "reply");
0758: }
0759:
0760: getScriptProxy().addScript(script);
0761: }
0762:
0763: /**
0764: * Returns a map containing all the parameters to pass to the XSL stylesheet during transformation.
0765: */
0766: @SuppressWarnings("unchecked")
0767: public jsx3.lang.Object getXSLParams() {
0768: String extension = "getXSLParams().";
0769: try {
0770: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
0771: .getConstructor(Context.class, String.class,
0772: ScriptProxy.class);
0773: return ctor.newInstance(this , extension, getScriptProxy());
0774: } catch (Exception ex) {
0775: throw new IllegalArgumentException("Unsupported type: "
0776: + jsx3.lang.Object.class.getName());
0777: }
0778: }
0779:
0780: /**
0781: * Returns a map containing all the parameters to pass to the XSL stylesheet during transformation.
0782: * @param returnType The expected return type
0783: */
0784: @SuppressWarnings("unchecked")
0785: public <T> T getXSLParams(Class<T> returnType) {
0786: String extension = "getXSLParams().";
0787: try {
0788: java.lang.reflect.Constructor<T> ctor = returnType
0789: .getConstructor(Context.class, String.class,
0790: ScriptProxy.class);
0791: return ctor.newInstance(this , extension, getScriptProxy());
0792: } catch (Exception ex) {
0793: throw new IllegalArgumentException(
0794: "Unsupported return type: " + returnType.getName());
0795: }
0796: }
0797:
0798: /**
0799: * Returns whether the XML data source of this object is loaded asynchronously.
0800: * @param callback <code>0</code> or <code>1</code>.
0801: */
0802: @SuppressWarnings("unchecked")
0803: public void getXmlAsync(
0804: org.directwebremoting.proxy.Callback<Integer> callback) {
0805: ScriptBuffer script = new ScriptBuffer();
0806: String callbackPrefix = "";
0807:
0808: if (callback != null) {
0809: callbackPrefix = "var reply = ";
0810: }
0811:
0812: script.appendCall(callbackPrefix + getContextPath()
0813: + "getXmlAsync");
0814:
0815: if (callback != null) {
0816: String key = org.directwebremoting.extend.CallbackHelper
0817: .saveCallback(callback, Integer.class);
0818: script
0819: .appendCall("__System.activateCallback", key,
0820: "reply");
0821: }
0822:
0823: getScriptProxy().addScript(script);
0824: }
0825:
0826: /**
0827: * Returns whether this object is bound to the XML document stored in the data cache.
0828: * @param callback <code>0</code> or <code>1</code>.
0829: */
0830: @SuppressWarnings("unchecked")
0831: public void getXmlBind(
0832: org.directwebremoting.proxy.Callback<Integer> callback) {
0833: ScriptBuffer script = new ScriptBuffer();
0834: String callbackPrefix = "";
0835:
0836: if (callback != null) {
0837: callbackPrefix = "var reply = ";
0838: }
0839:
0840: script.appendCall(callbackPrefix + getContextPath()
0841: + "getXmlBind");
0842:
0843: if (callback != null) {
0844: String key = org.directwebremoting.extend.CallbackHelper
0845: .saveCallback(callback, Integer.class);
0846: script
0847: .appendCall("__System.activateCallback", key,
0848: "reply");
0849: }
0850:
0851: getScriptProxy().addScript(script);
0852: }
0853:
0854: /**
0855: * This method is called in two situations:
0856:
0857: When the datasource of this object finishes loading (success, error, or timeout), if the
0858: xmlAsync property of this object is true, its datasource is specified as an
0859: XML URL, and the first time doTransform() was called the datasource was still loading.
0860: Any time the value stored in the server XML cache under the key equal to the XML Id of this object
0861: changes, if the xmlBind property of this object is true.
0862:
0863: Any methods overriding this method should begin with a call to jsxsupermix().
0864: * @param objEvent the event published by the cache.
0865: */
0866: public void onXmlBinding(jsx3.lang.Object objEvent) {
0867: ScriptBuffer script = new ScriptBuffer();
0868: script.appendCall(getContextPath() + "onXmlBinding", objEvent);
0869: getScriptProxy().addScript(script);
0870: }
0871:
0872: /**
0873: * Removes a parameter from the list of parameters to pass to the XSL stylesheet during transformation.
0874: * @param strName the name of the XSL parameter to remove.
0875: * @return this object.
0876: */
0877: @SuppressWarnings("unchecked")
0878: public jsx3.xml.Cacheable removeXSLParam(String strName) {
0879: String extension = "removeXSLParam(\"" + strName + "\").";
0880: try {
0881: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
0882: .getConstructor(Context.class, String.class,
0883: ScriptProxy.class);
0884: return ctor.newInstance(this , extension, getScriptProxy());
0885: } catch (Exception ex) {
0886: throw new IllegalArgumentException("Unsupported type: "
0887: + jsx3.xml.Cacheable.class.getName());
0888: }
0889: }
0890:
0891: /**
0892: * Removes a parameter from the list of parameters to pass to the XSL stylesheet during transformation.
0893: * @param strName the name of the XSL parameter to remove.
0894: * @param returnType The expected return type
0895: * @return this object.
0896: */
0897: @SuppressWarnings("unchecked")
0898: public <T> T removeXSLParam(String strName, Class<T> returnType) {
0899: String extension = "removeXSLParam(\"" + strName + "\").";
0900: try {
0901: java.lang.reflect.Constructor<T> ctor = returnType
0902: .getConstructor(Context.class, String.class,
0903: ScriptProxy.class);
0904: return ctor.newInstance(this , extension, getScriptProxy());
0905: } catch (Exception ex) {
0906: throw new IllegalArgumentException(
0907: "Unsupported return type: " + returnType.getName());
0908: }
0909: }
0910:
0911: /**
0912: * Removes all parameters from the list of parameters to pass to the XSL stylesheet during transformation.
0913: * @return this object.
0914: */
0915: @SuppressWarnings("unchecked")
0916: public jsx3.xml.Cacheable removeXSLParams() {
0917: String extension = "removeXSLParams().";
0918: try {
0919: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
0920: .getConstructor(Context.class, String.class,
0921: ScriptProxy.class);
0922: return ctor.newInstance(this , extension, getScriptProxy());
0923: } catch (Exception ex) {
0924: throw new IllegalArgumentException("Unsupported type: "
0925: + jsx3.xml.Cacheable.class.getName());
0926: }
0927: }
0928:
0929: /**
0930: * Removes all parameters from the list of parameters to pass to the XSL stylesheet during transformation.
0931: * @param returnType The expected return type
0932: * @return this object.
0933: */
0934: @SuppressWarnings("unchecked")
0935: public <T> T removeXSLParams(Class<T> returnType) {
0936: String extension = "removeXSLParams().";
0937: try {
0938: java.lang.reflect.Constructor<T> ctor = returnType
0939: .getConstructor(Context.class, String.class,
0940: ScriptProxy.class);
0941: return ctor.newInstance(this , extension, getScriptProxy());
0942: } catch (Exception ex) {
0943: throw new IllegalArgumentException(
0944: "Unsupported return type: " + returnType.getName());
0945: }
0946: }
0947:
0948: /**
0949: * Removes the XML and XSL source documents from the server cache.
0950: * @param objServer the server owning the cache to modify. This is a required argument only if
0951: <code>this.getServer()</code> does not returns a server instance.
0952: */
0953: public void resetCacheData(jsx3.app.Server objServer) {
0954: ScriptBuffer script = new ScriptBuffer();
0955: script.appendCall(getContextPath() + "resetCacheData",
0956: objServer);
0957: getScriptProxy().addScript(script);
0958: }
0959:
0960: /**
0961: * Removes the XML source document stored under the XML ID of this object from the server cache.
0962: * @param objServer the server owning the cache to modify. This is a required argument only if
0963: <code>this.getServer()</code> does not returns a server instance.
0964: */
0965: public void resetXmlCacheData(jsx3.app.Server objServer) {
0966: ScriptBuffer script = new ScriptBuffer();
0967: script.appendCall(getContextPath() + "resetXmlCacheData",
0968: objServer);
0969: getScriptProxy().addScript(script);
0970: }
0971:
0972: /**
0973: * Sets whether this object removes its XML and XSL source documents from the cache of its server when it
0974: is destroyed.
0975: * @param intShare <code>CLEANUPRESOURCES</code> or <code>SHARERESOURCES</code>. <code>CLEANUPRESOURCES</code>
0976: is the default value if the property is <code>null</code>.
0977: * @return this object.
0978: */
0979: @SuppressWarnings("unchecked")
0980: public jsx3.xml.Cacheable setShareResources(int intShare) {
0981: String extension = "setShareResources(\"" + intShare + "\").";
0982: try {
0983: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
0984: .getConstructor(Context.class, String.class,
0985: ScriptProxy.class);
0986: return ctor.newInstance(this , extension, getScriptProxy());
0987: } catch (Exception ex) {
0988: throw new IllegalArgumentException("Unsupported type: "
0989: + jsx3.xml.Cacheable.class.getName());
0990: }
0991: }
0992:
0993: /**
0994: * Sets whether this object removes its XML and XSL source documents from the cache of its server when it
0995: is destroyed.
0996: * @param intShare <code>CLEANUPRESOURCES</code> or <code>SHARERESOURCES</code>. <code>CLEANUPRESOURCES</code>
0997: is the default value if the property is <code>null</code>.
0998: * @param returnType The expected return type
0999: * @return this object.
1000: */
1001: @SuppressWarnings("unchecked")
1002: public <T> T setShareResources(int intShare, Class<T> returnType) {
1003: String extension = "setShareResources(\"" + intShare + "\").";
1004: try {
1005: java.lang.reflect.Constructor<T> ctor = returnType
1006: .getConstructor(Context.class, String.class,
1007: ScriptProxy.class);
1008: return ctor.newInstance(this , extension, getScriptProxy());
1009: } catch (Exception ex) {
1010: throw new IllegalArgumentException(
1011: "Unsupported return type: " + returnType.getName());
1012: }
1013: }
1014:
1015: /**
1016: * Sets the source document of this object as though objDoc were retrieved from the XML URL or XML
1017: string of this object. This method executes the following steps:
1018:
1019: The document is transformed serially by each XML transformers of this object.
1020: The XML document is saved in the server cache under the XML ID of this object.
1021: If this object is an instance of jsx3.xml.CDF and the root node is a <data> element
1022: and its jsxassignids attribute is equal to 1, all <record> elements without a
1023: jsxid attribute are assigned a unique jsxid.
1024: If this object is an instance of jsx3.xml.CDF, convertProperties() is called
1025: on this object.
1026: * @param objDoc
1027: * @param objCache
1028: * @return the document stored in the server cache as the data source of this object. If
1029: transformers were run, this value will not be equal to the <code>objDoc</code> parameter.
1030: */
1031: @SuppressWarnings("unchecked")
1032: public jsx3.xml.CdfDocument setSourceXML(
1033: jsx3.xml.CdfDocument objDoc, jsx3.app.Cache objCache) {
1034: String extension = "setSourceXML(\"" + objDoc + "\", \""
1035: + objCache + "\").";
1036: try {
1037: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
1038: .getConstructor(Context.class, String.class,
1039: ScriptProxy.class);
1040: return ctor.newInstance(this , extension, getScriptProxy());
1041: } catch (Exception ex) {
1042: throw new IllegalArgumentException("Unsupported type: "
1043: + jsx3.xml.CdfDocument.class.getName());
1044: }
1045: }
1046:
1047: /**
1048: * Sets the source document of this object as though objDoc were retrieved from the XML URL or XML
1049: string of this object. This method executes the following steps:
1050:
1051: The document is transformed serially by each XML transformers of this object.
1052: The XML document is saved in the server cache under the XML ID of this object.
1053: If this object is an instance of jsx3.xml.CDF and the root node is a <data> element
1054: and its jsxassignids attribute is equal to 1, all <record> elements without a
1055: jsxid attribute are assigned a unique jsxid.
1056: If this object is an instance of jsx3.xml.CDF, convertProperties() is called
1057: on this object.
1058: * @param objDoc
1059: * @param objCache
1060: * @param returnType The expected return type
1061: * @return the document stored in the server cache as the data source of this object. If
1062: transformers were run, this value will not be equal to the <code>objDoc</code> parameter.
1063: */
1064: @SuppressWarnings("unchecked")
1065: public <T> T setSourceXML(jsx3.xml.CdfDocument objDoc,
1066: jsx3.app.Cache objCache, Class<T> returnType) {
1067: String extension = "setSourceXML(\"" + objDoc + "\", \""
1068: + objCache + "\").";
1069: try {
1070: java.lang.reflect.Constructor<T> ctor = returnType
1071: .getConstructor(Context.class, String.class,
1072: ScriptProxy.class);
1073: return ctor.newInstance(this , extension, getScriptProxy());
1074: } catch (Exception ex) {
1075: throw new IllegalArgumentException(
1076: "Unsupported return type: " + returnType.getName());
1077: }
1078: }
1079:
1080: /**
1081: * Sets the XML ID of this object. This value is the key under which the XML source document of this object is
1082: saved in the cache of the server owning this object. The developer may specify either a unique or shared value.
1083: If no value is specified, a unique id is generated.
1084: * @param strXMLId
1085: * @return this object.
1086: */
1087: @SuppressWarnings("unchecked")
1088: public jsx3.xml.Cacheable setXMLId(String strXMLId) {
1089: String extension = "setXMLId(\"" + strXMLId + "\").";
1090: try {
1091: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1092: .getConstructor(Context.class, String.class,
1093: ScriptProxy.class);
1094: return ctor.newInstance(this , extension, getScriptProxy());
1095: } catch (Exception ex) {
1096: throw new IllegalArgumentException("Unsupported type: "
1097: + jsx3.xml.Cacheable.class.getName());
1098: }
1099: }
1100:
1101: /**
1102: * Sets the XML ID of this object. This value is the key under which the XML source document of this object is
1103: saved in the cache of the server owning this object. The developer may specify either a unique or shared value.
1104: If no value is specified, a unique id is generated.
1105: * @param strXMLId
1106: * @param returnType The expected return type
1107: * @return this object.
1108: */
1109: @SuppressWarnings("unchecked")
1110: public <T> T setXMLId(String strXMLId, Class<T> returnType) {
1111: String extension = "setXMLId(\"" + strXMLId + "\").";
1112: try {
1113: java.lang.reflect.Constructor<T> ctor = returnType
1114: .getConstructor(Context.class, String.class,
1115: ScriptProxy.class);
1116: return ctor.newInstance(this , extension, getScriptProxy());
1117: } catch (Exception ex) {
1118: throw new IllegalArgumentException(
1119: "Unsupported return type: " + returnType.getName());
1120: }
1121: }
1122:
1123: /**
1124: * Sets the XML string of this object. Setting this value to the string serialization of an XML document is one
1125: way of specifying the source XML document of this object.
1126: * @param strXML <code>null</code> or a well-formed serialized XML element.
1127: * @return this object.
1128: */
1129: @SuppressWarnings("unchecked")
1130: public jsx3.xml.Cacheable setXMLString(String strXML) {
1131: String extension = "setXMLString(\"" + strXML + "\").";
1132: try {
1133: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1134: .getConstructor(Context.class, String.class,
1135: ScriptProxy.class);
1136: return ctor.newInstance(this , extension, getScriptProxy());
1137: } catch (Exception ex) {
1138: throw new IllegalArgumentException("Unsupported type: "
1139: + jsx3.xml.Cacheable.class.getName());
1140: }
1141: }
1142:
1143: /**
1144: * Sets the XML string of this object. Setting this value to the string serialization of an XML document is one
1145: way of specifying the source XML document of this object.
1146: * @param strXML <code>null</code> or a well-formed serialized XML element.
1147: * @param returnType The expected return type
1148: * @return this object.
1149: */
1150: @SuppressWarnings("unchecked")
1151: public <T> T setXMLString(String strXML, Class<T> returnType) {
1152: String extension = "setXMLString(\"" + strXML + "\").";
1153: try {
1154: java.lang.reflect.Constructor<T> ctor = returnType
1155: .getConstructor(Context.class, String.class,
1156: ScriptProxy.class);
1157: return ctor.newInstance(this , extension, getScriptProxy());
1158: } catch (Exception ex) {
1159: throw new IllegalArgumentException(
1160: "Unsupported return type: " + returnType.getName());
1161: }
1162: }
1163:
1164: /**
1165: * Sets the list of XML transformers of this object. The XML source document of this object is transformed
1166: serially by each of these transformers before it is placed in the XML cache.
1167:
1168: Each transformer is either the URI of an XSLT document (which will be resolved against the
1169: the server of this object) or the cache id of a XSLT document in the XML cache of the server
1170: of this object. When any transformer is loaded from a URI it is placed in the server cache under the id
1171: equal to its resolved URI. Any transformer that does not correspond to a valid XSLT document will be skipped
1172: without throwing an error.
1173: * @param arrTrans
1174: */
1175: public void setXMLTransformers(Object[] arrTrans) {
1176: ScriptBuffer script = new ScriptBuffer();
1177: script.appendCall(getContextPath() + "setXMLTransformers",
1178: arrTrans);
1179: getScriptProxy().addScript(script);
1180: }
1181:
1182: /**
1183: * Sets the XML URL of this object. Settings this value to the URI of an XML document is one way of specifying the
1184: source XML document of this object.
1185: * @param strXMLURL <code>null</code> or a URI that when resolved against the server owning this object
1186: specifies a valid XML document.
1187: * @return this object.
1188: */
1189: @SuppressWarnings("unchecked")
1190: public jsx3.xml.Cacheable setXMLURL(String strXMLURL) {
1191: String extension = "setXMLURL(\"" + strXMLURL + "\").";
1192: try {
1193: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1194: .getConstructor(Context.class, String.class,
1195: ScriptProxy.class);
1196: return ctor.newInstance(this , extension, getScriptProxy());
1197: } catch (Exception ex) {
1198: throw new IllegalArgumentException("Unsupported type: "
1199: + jsx3.xml.Cacheable.class.getName());
1200: }
1201: }
1202:
1203: /**
1204: * Sets the XML URL of this object. Settings this value to the URI of an XML document is one way of specifying the
1205: source XML document of this object.
1206: * @param strXMLURL <code>null</code> or a URI that when resolved against the server owning this object
1207: specifies a valid XML document.
1208: * @param returnType The expected return type
1209: * @return this object.
1210: */
1211: @SuppressWarnings("unchecked")
1212: public <T> T setXMLURL(String strXMLURL, Class<T> returnType) {
1213: String extension = "setXMLURL(\"" + strXMLURL + "\").";
1214: try {
1215: java.lang.reflect.Constructor<T> ctor = returnType
1216: .getConstructor(Context.class, String.class,
1217: ScriptProxy.class);
1218: return ctor.newInstance(this , extension, getScriptProxy());
1219: } catch (Exception ex) {
1220: throw new IllegalArgumentException(
1221: "Unsupported return type: " + returnType.getName());
1222: }
1223: }
1224:
1225: /**
1226: * Adds a name/value pair to the list of parameters to pass to the XSL stylesheet during transformation. If
1227: strValue is null the parameter is removed.
1228: * @param strName the name of the XSL parameter to add.
1229: * @param strValue the value of the XSL parameter to add.
1230: * @return this object.
1231: */
1232: @SuppressWarnings("unchecked")
1233: public jsx3.xml.Cacheable setXSLParam(String strName,
1234: String strValue) {
1235: String extension = "setXSLParam(\"" + strName + "\", \""
1236: + strValue + "\").";
1237: try {
1238: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1239: .getConstructor(Context.class, String.class,
1240: ScriptProxy.class);
1241: return ctor.newInstance(this , extension, getScriptProxy());
1242: } catch (Exception ex) {
1243: throw new IllegalArgumentException("Unsupported type: "
1244: + jsx3.xml.Cacheable.class.getName());
1245: }
1246: }
1247:
1248: /**
1249: * Adds a name/value pair to the list of parameters to pass to the XSL stylesheet during transformation. If
1250: strValue is null the parameter is removed.
1251: * @param strName the name of the XSL parameter to add.
1252: * @param strValue the value of the XSL parameter to add.
1253: * @param returnType The expected return type
1254: * @return this object.
1255: */
1256: @SuppressWarnings("unchecked")
1257: public <T> T setXSLParam(String strName, String strValue,
1258: Class<T> returnType) {
1259: String extension = "setXSLParam(\"" + strName + "\", \""
1260: + strValue + "\").";
1261: try {
1262: java.lang.reflect.Constructor<T> ctor = returnType
1263: .getConstructor(Context.class, String.class,
1264: ScriptProxy.class);
1265: return ctor.newInstance(this , extension, getScriptProxy());
1266: } catch (Exception ex) {
1267: throw new IllegalArgumentException(
1268: "Unsupported return type: " + returnType.getName());
1269: }
1270: }
1271:
1272: /**
1273: * Sets whether the XML data source of this object is loaded asynchronously. This setting only applies to
1274: data sources loaded from an XML URL.
1275: * @param bAsync
1276: * @return this object.
1277: */
1278: @SuppressWarnings("unchecked")
1279: public jsx3.xml.Cacheable setXmlAsync(boolean bAsync) {
1280: String extension = "setXmlAsync(\"" + bAsync + "\").";
1281: try {
1282: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1283: .getConstructor(Context.class, String.class,
1284: ScriptProxy.class);
1285: return ctor.newInstance(this , extension, getScriptProxy());
1286: } catch (Exception ex) {
1287: throw new IllegalArgumentException("Unsupported type: "
1288: + jsx3.xml.Cacheable.class.getName());
1289: }
1290: }
1291:
1292: /**
1293: * Sets whether the XML data source of this object is loaded asynchronously. This setting only applies to
1294: data sources loaded from an XML URL.
1295: * @param bAsync
1296: * @param returnType The expected return type
1297: * @return this object.
1298: */
1299: @SuppressWarnings("unchecked")
1300: public <T> T setXmlAsync(boolean bAsync, Class<T> returnType) {
1301: String extension = "setXmlAsync(\"" + bAsync + "\").";
1302: try {
1303: java.lang.reflect.Constructor<T> ctor = returnType
1304: .getConstructor(Context.class, String.class,
1305: ScriptProxy.class);
1306: return ctor.newInstance(this , extension, getScriptProxy());
1307: } catch (Exception ex) {
1308: throw new IllegalArgumentException(
1309: "Unsupported return type: " + returnType.getName());
1310: }
1311: }
1312:
1313: /**
1314: * Sets whether this object is bound to the XML document stored in the data cache. If this object is bound to the
1315: cache, then the onXmlBinding() method of this object is called any time the document stored in
1316: the cache under the XML Id of this object changes.
1317: * @param bBind
1318: * @param callback <code>0</code> or <code>1</code>.
1319: */
1320: @SuppressWarnings("unchecked")
1321: public void setXmlBind(boolean bBind,
1322: org.directwebremoting.proxy.Callback<Integer> callback) {
1323: ScriptBuffer script = new ScriptBuffer();
1324: String callbackPrefix = "";
1325:
1326: if (callback != null) {
1327: callbackPrefix = "var reply = ";
1328: }
1329:
1330: script.appendCall(callbackPrefix + getContextPath()
1331: + "setXmlBind", bBind);
1332:
1333: if (callback != null) {
1334: String key = org.directwebremoting.extend.CallbackHelper
1335: .saveCallback(callback, Integer.class);
1336: script
1337: .appendCall("__System.activateCallback", key,
1338: "reply");
1339: }
1340:
1341: getScriptProxy().addScript(script);
1342: }
1343:
1344: /**
1345: * Transfers a CDF record from another object to this object. If no XML data source exists
1346: yet for this object, an empty one is created before adding the new record. This method always updates the
1347: on-screen view of both the source and destination objects.
1348:
1349: This method fails quietly if any of the following conditions apply:
1350:
1351: there is no object with id equal to strSourceId
1352:
1353: there is no record in the source object with jsxid equal to strRecordId
1354:
1355:
1356: strParentRecordId is specified and there is no record in this object with
1357: jsxid equal to strParentRecordId
1358:
1359: the this object already has a record with jsxid equal to the record to adopt
1360: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1361: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1362: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1363: is provided, the adopted record will be added as a child of this record. Otherwise, the adopted record will
1364: be added to the root <code>data</code> element.
1365: * @param bRedraw forces suppression of the insert event
1366: * @return the adopted record.
1367: */
1368: @SuppressWarnings("unchecked")
1369: public jsx3.xml.Node adoptRecord(jsx3.xml.CdfDocument strSourceId,
1370: String strRecordId, String strParentRecordId,
1371: boolean bRedraw) {
1372: String extension = "adoptRecord(\"" + strSourceId + "\", \""
1373: + strRecordId + "\", \"" + strParentRecordId + "\", \""
1374: + bRedraw + "\").";
1375: try {
1376: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1377: .getConstructor(Context.class, String.class,
1378: ScriptProxy.class);
1379: return ctor.newInstance(this , extension, getScriptProxy());
1380: } catch (Exception ex) {
1381: throw new IllegalArgumentException("Unsupported type: "
1382: + jsx3.xml.Node.class.getName());
1383: }
1384: }
1385:
1386: /**
1387: * Transfers a CDF record from another object to this object. If no XML data source exists
1388: yet for this object, an empty one is created before adding the new record. This method always updates the
1389: on-screen view of both the source and destination objects.
1390:
1391: This method fails quietly if any of the following conditions apply:
1392:
1393: there is no object with id equal to strSourceId
1394:
1395: there is no record in the source object with jsxid equal to strRecordId
1396:
1397:
1398: strParentRecordId is specified and there is no record in this object with
1399: jsxid equal to strParentRecordId
1400:
1401: the this object already has a record with jsxid equal to the record to adopt
1402: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1403: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1404: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1405: is provided, the adopted record will be added as a child of this record. Otherwise, the adopted record will
1406: be added to the root <code>data</code> element.
1407: * @param bRedraw forces suppression of the insert event
1408: * @return the adopted record.
1409: */
1410: @SuppressWarnings("unchecked")
1411: public jsx3.xml.Node adoptRecord(String strSourceId,
1412: String strRecordId, String strParentRecordId,
1413: boolean bRedraw) {
1414: String extension = "adoptRecord(\"" + strSourceId + "\", \""
1415: + strRecordId + "\", \"" + strParentRecordId + "\", \""
1416: + bRedraw + "\").";
1417: try {
1418: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1419: .getConstructor(Context.class, String.class,
1420: ScriptProxy.class);
1421: return ctor.newInstance(this , extension, getScriptProxy());
1422: } catch (Exception ex) {
1423: throw new IllegalArgumentException("Unsupported type: "
1424: + jsx3.xml.Node.class.getName());
1425: }
1426: }
1427:
1428: /**
1429: * Equivalent to adoptRecord, except that the to-be relationship is as a previousSibling to the CDF record identified by the parameter, strSiblingRecordId
1430:
1431: This method fails quietly if any of the following conditions apply:
1432:
1433: there is no record with a jsxid equal to strSourceId
1434:
1435: there is no record in the source object with a jsxid equal to strRecordId
1436:
1437:
1438: strSiblingRecordId is specified and there is no record in this object with a
1439: jsxid equal to strParentRecordId
1440:
1441: this object already has a record with jsxid equal to the record to adopt
1442: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1443: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1444: * @param strSiblingRecordId the unique <code>jsxid</code> of an existing record in front of
1445: which the record identified by strSourceId will be placed
1446: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1447: immediately updated to reflect the deleted record.
1448: * @return the adopted record.
1449: */
1450: @SuppressWarnings("unchecked")
1451: public jsx3.xml.Node adoptRecordBefore(
1452: jsx3.xml.CdfDocument strSourceId, String strRecordId,
1453: String strSiblingRecordId, boolean bRedraw) {
1454: String extension = "adoptRecordBefore(\"" + strSourceId
1455: + "\", \"" + strRecordId + "\", \""
1456: + strSiblingRecordId + "\", \"" + bRedraw + "\").";
1457: try {
1458: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1459: .getConstructor(Context.class, String.class,
1460: ScriptProxy.class);
1461: return ctor.newInstance(this , extension, getScriptProxy());
1462: } catch (Exception ex) {
1463: throw new IllegalArgumentException("Unsupported type: "
1464: + jsx3.xml.Node.class.getName());
1465: }
1466: }
1467:
1468: /**
1469: * Equivalent to adoptRecord, except that the to-be relationship is as a previousSibling to the CDF record identified by the parameter, strSiblingRecordId
1470:
1471: This method fails quietly if any of the following conditions apply:
1472:
1473: there is no record with a jsxid equal to strSourceId
1474:
1475: there is no record in the source object with a jsxid equal to strRecordId
1476:
1477:
1478: strSiblingRecordId is specified and there is no record in this object with a
1479: jsxid equal to strParentRecordId
1480:
1481: this object already has a record with jsxid equal to the record to adopt
1482: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1483: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1484: * @param strSiblingRecordId the unique <code>jsxid</code> of an existing record in front of
1485: which the record identified by strSourceId will be placed
1486: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1487: immediately updated to reflect the deleted record.
1488: * @return the adopted record.
1489: */
1490: @SuppressWarnings("unchecked")
1491: public jsx3.xml.Node adoptRecordBefore(String strSourceId,
1492: String strRecordId, String strSiblingRecordId,
1493: boolean bRedraw) {
1494: String extension = "adoptRecordBefore(\"" + strSourceId
1495: + "\", \"" + strRecordId + "\", \""
1496: + strSiblingRecordId + "\", \"" + bRedraw + "\").";
1497: try {
1498: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1499: .getConstructor(Context.class, String.class,
1500: ScriptProxy.class);
1501: return ctor.newInstance(this , extension, getScriptProxy());
1502: } catch (Exception ex) {
1503: throw new IllegalArgumentException("Unsupported type: "
1504: + jsx3.xml.Node.class.getName());
1505: }
1506: }
1507:
1508: /**
1509: * Converts all attributes in this CDF document that are property keys of the form {key} to
1510: the value of the property.
1511: * @param objProps the properties repository to query.
1512: * @param arrProps if provided, these attributes are converted rather than the default set of
1513: attributes.
1514: * @param bUnion if <code>true</code>, <code>arrProps</code> is combined with the default set of
1515: attributes and those attributes are converted.
1516: */
1517: public void convertProperties(java.util.Properties objProps,
1518: Object[] arrProps, boolean bUnion) {
1519: ScriptBuffer script = new ScriptBuffer();
1520: script.appendCall(getContextPath() + "convertProperties",
1521: objProps, arrProps, bUnion);
1522: getScriptProxy().addScript(script);
1523: }
1524:
1525: /**
1526: * Removes a record from the XML data source of this object.
1527: * @param strRecordId the <code>jsxid</code> attribute of the data record to remove.
1528: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1529: immediately updated to reflect the deleted record.
1530: * @return the record removed from the data source or <code>null</code> if no such record found.
1531: */
1532: @SuppressWarnings("unchecked")
1533: public jsx3.xml.Node deleteRecord(String strRecordId,
1534: boolean bRedraw) {
1535: String extension = "deleteRecord(\"" + strRecordId + "\", \""
1536: + bRedraw + "\").";
1537: try {
1538: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1539: .getConstructor(Context.class, String.class,
1540: ScriptProxy.class);
1541: return ctor.newInstance(this , extension, getScriptProxy());
1542: } catch (Exception ex) {
1543: throw new IllegalArgumentException("Unsupported type: "
1544: + jsx3.xml.Node.class.getName());
1545: }
1546: }
1547:
1548: /**
1549: * Removes a specific property from a record. If no such record exists in the XML document, this method fails quietly.
1550: * @param strRecordId the <code>jsxid</code> attribute of the data record to modify.
1551: * @param strPropName the name of the property to remove from the record.
1552: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1553: immediately updated to reflect the deleted property.
1554: */
1555: public void deleteRecordProperty(String strRecordId,
1556: String strPropName, boolean bRedraw) {
1557: ScriptBuffer script = new ScriptBuffer();
1558: script.appendCall(getContextPath() + "deleteRecordProperty",
1559: strRecordId, strPropName, bRedraw);
1560: getScriptProxy().addScript(script);
1561: }
1562:
1563: /**
1564: * Returns an object containing the attributes of a particular CDF record as property/value pairs. The object returned by this
1565: method is a copy of the underlying data. Therefore, updates to this object will not affect the underlying data.
1566:
1567: The following two lines of code evaluate to the same value:
1568:
1569: objCDF.getRecord(strId).propName;
1570: objCDF.getRecordNode(strId).getAttribute("propName");
1571: * @param strRecordId the <code>jsxid</code> attribute of the data record to return.
1572: * @return the object representation of a CDF node or <code>null</code> if no such record found.
1573: */
1574: @SuppressWarnings("unchecked")
1575: public jsx3.lang.Object getRecord(String strRecordId) {
1576: String extension = "getRecord(\"" + strRecordId + "\").";
1577: try {
1578: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
1579: .getConstructor(Context.class, String.class,
1580: ScriptProxy.class);
1581: return ctor.newInstance(this , extension, getScriptProxy());
1582: } catch (Exception ex) {
1583: throw new IllegalArgumentException("Unsupported type: "
1584: + jsx3.lang.Object.class.getName());
1585: }
1586: }
1587:
1588: /**
1589: * Returns an object containing the attributes of a particular CDF record as property/value pairs. The object returned by this
1590: method is a copy of the underlying data. Therefore, updates to this object will not affect the underlying data.
1591:
1592: The following two lines of code evaluate to the same value:
1593:
1594: objCDF.getRecord(strId).propName;
1595: objCDF.getRecordNode(strId).getAttribute("propName");
1596: * @param strRecordId the <code>jsxid</code> attribute of the data record to return.
1597: * @param returnType The expected return type
1598: * @return the object representation of a CDF node or <code>null</code> if no such record found.
1599: */
1600: @SuppressWarnings("unchecked")
1601: public <T> T getRecord(String strRecordId, Class<T> returnType) {
1602: String extension = "getRecord(\"" + strRecordId + "\").";
1603: try {
1604: java.lang.reflect.Constructor<T> ctor = returnType
1605: .getConstructor(Context.class, String.class,
1606: ScriptProxy.class);
1607: return ctor.newInstance(this , extension, getScriptProxy());
1608: } catch (Exception ex) {
1609: throw new IllegalArgumentException(
1610: "Unsupported return type: " + returnType.getName());
1611: }
1612: }
1613:
1614: /**
1615: * Returns a record from the XML data source of this object. This returned value is a handle to the record and
1616: not a clone. Therefore, any updates made to the returned value with update the XML document of this object.
1617: To reflect such changes in the on-screen view of this object, call
1618: redrawRecord(strRecordId, jsx3.xml.CDF.UPDATE); on this object.
1619: * @param strRecordId the <code>jsxid</code> attribute of the data record to return.
1620: * @return the record node or <code>null</code> if none exists with a <code>jsxid</code>
1621: attribute equal to <code>strRecordId</code>.
1622: */
1623: @SuppressWarnings("unchecked")
1624: public jsx3.xml.Node getRecordNode(String strRecordId) {
1625: String extension = "getRecordNode(\"" + strRecordId + "\").";
1626: try {
1627: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1628: .getConstructor(Context.class, String.class,
1629: ScriptProxy.class);
1630: return ctor.newInstance(this , extension, getScriptProxy());
1631: } catch (Exception ex) {
1632: throw new IllegalArgumentException("Unsupported type: "
1633: + jsx3.xml.Node.class.getName());
1634: }
1635: }
1636:
1637: /**
1638: * Inserts a new record into the XML data source of this object. If no XML data source exists
1639: yet for this object, an empty one is created before adding the new record.
1640: If a record already exists with an id equal to the jsxid property of objRecord,
1641: the operation is treated as an update, meaning the existing record is completely removed and a new record with
1642: the given jsxid is inserted.
1643: * @param objRecord a JavaScript object containing property/value pairs that define the
1644: attributes of the XML entity to create. Note that most classes that implement this interface require that all
1645: records have an attribute named <code>jsxid</code> that is unique across all records in the XML document.
1646: All property values will be treated as strings. Additionally, the following 3 characters are escaped:
1647: <code>" > <</code>.
1648: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1649: is provided and a record exists with a matching <code>jsxid</code> attribute, the new record will be added as a child of
1650: this record. Otherwise, the new record will be added to the root <code>data</code> element. However, if a
1651: record already exists with a <code>jsxid</code> attribute equal to the <code>jsxid</code> property of
1652: <code>objRecord</code>, this parameter will be ignored. In this case <code>adoptRecord()</code> must be called
1653: to change the parent of the record.
1654: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1655: immediately updated to reflect the additional record.
1656: * @return the newly created or updated entity.
1657: */
1658: @SuppressWarnings("unchecked")
1659: public jsx3.xml.Node insertRecord(jsx3.lang.Object objRecord,
1660: String strParentRecordId, boolean bRedraw) {
1661: String extension = "insertRecord(\"" + objRecord + "\", \""
1662: + strParentRecordId + "\", \"" + bRedraw + "\").";
1663: try {
1664: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1665: .getConstructor(Context.class, String.class,
1666: ScriptProxy.class);
1667: return ctor.newInstance(this , extension, getScriptProxy());
1668: } catch (Exception ex) {
1669: throw new IllegalArgumentException("Unsupported type: "
1670: + jsx3.xml.Node.class.getName());
1671: }
1672: }
1673:
1674: /**
1675: * Creates a new CDF record and inserts it into the CDF data source of this object, before the record identified by strSiblingRecordId.
1676:
1677: This method fails quietly if any of the following conditions apply:
1678:
1679: there is no existing record with a jsxid equal to strSiblingRecordId
1680:
1681: there is an existing record with jsxid equal to objRecord.jsxid
1682: * @param objRecord a JavaScript object containing property/value pairs that define the
1683: attributes of the XML entity to create. Note that most classes that implement this interface require that all
1684: records have an attribute named <code>jsxid</code> that is unique across all records in the XML document.
1685: All property values will be treated as strings. Additionally, the following 3 characters are escaped:
1686: <code>" > <</code>.
1687: * @param strSiblingRecordId the unique <code>jsxid</code> of an existing record before which the new record will be inserted.
1688: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1689: immediately updated to reflect the additional record.
1690: * @return the newly created entity.
1691: */
1692: @SuppressWarnings("unchecked")
1693: public jsx3.xml.Node insertRecordBefore(jsx3.lang.Object objRecord,
1694: String strSiblingRecordId, boolean bRedraw) {
1695: String extension = "insertRecordBefore(\"" + objRecord
1696: + "\", \"" + strSiblingRecordId + "\", \"" + bRedraw
1697: + "\").";
1698: try {
1699: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1700: .getConstructor(Context.class, String.class,
1701: ScriptProxy.class);
1702: return ctor.newInstance(this , extension, getScriptProxy());
1703: } catch (Exception ex) {
1704: throw new IllegalArgumentException("Unsupported type: "
1705: + jsx3.xml.Node.class.getName());
1706: }
1707: }
1708:
1709: /**
1710: * Inserts a new record into the XML data source of this object. This method is the same as
1711: insertRecord() except that its first parameter is of type jsx3.xml.Entity rather than
1712: Object.
1713: * @param objRecordNode an XML element of name <code>record</code>. Note that most classes that
1714: implement this interface require that all records have an attribute named <code>jsxid</code> that is unique
1715: across all records in the XML document.
1716: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1717: is provided and a record exists with a matching <code>jsxid</code> attribute, the new record will be added as a child of
1718: this record. Otherwise, the new record will be added to the root <code>data</code> element.
1719: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1720: immediately updated to reflect the additional record.
1721: */
1722: public void insertRecordNode(jsx3.xml.Node objRecordNode,
1723: String strParentRecordId, boolean bRedraw) {
1724: ScriptBuffer script = new ScriptBuffer();
1725: script.appendCall(getContextPath() + "insertRecordNode",
1726: objRecordNode, strParentRecordId, bRedraw);
1727: getScriptProxy().addScript(script);
1728: }
1729:
1730: /**
1731: * Inserts a new property into an existing record with jsxid equal to strRecordId.
1732: If the property already exists, the existing property value will be updated. If no such record exists
1733: in the XML document, this method fails quietly.
1734: * @param strRecordId the <code>jsxid</code> attribute of the data record to modify.
1735: * @param strPropName the name of the property to insert into the record.
1736: * @param strPropValue the value of the property to insert.
1737: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1738: immediately updated to reflect the inserted property.
1739: * @return this object.
1740: */
1741: @SuppressWarnings("unchecked")
1742: public jsx3.xml.CdfDocument insertRecordProperty(
1743: String strRecordId, String strPropName,
1744: String strPropValue, boolean bRedraw) {
1745: String extension = "insertRecordProperty(\"" + strRecordId
1746: + "\", \"" + strPropName + "\", \"" + strPropValue
1747: + "\", \"" + bRedraw + "\").";
1748: try {
1749: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
1750: .getConstructor(Context.class, String.class,
1751: ScriptProxy.class);
1752: return ctor.newInstance(this , extension, getScriptProxy());
1753: } catch (Exception ex) {
1754: throw new IllegalArgumentException("Unsupported type: "
1755: + jsx3.xml.CdfDocument.class.getName());
1756: }
1757: }
1758:
1759: /**
1760: * Inserts a new property into an existing record with jsxid equal to strRecordId.
1761: If the property already exists, the existing property value will be updated. If no such record exists
1762: in the XML document, this method fails quietly.
1763: * @param strRecordId the <code>jsxid</code> attribute of the data record to modify.
1764: * @param strPropName the name of the property to insert into the record.
1765: * @param strPropValue the value of the property to insert.
1766: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1767: immediately updated to reflect the inserted property.
1768: * @param returnType The expected return type
1769: * @return this object.
1770: */
1771: @SuppressWarnings("unchecked")
1772: public <T> T insertRecordProperty(String strRecordId,
1773: String strPropName, String strPropValue, boolean bRedraw,
1774: Class<T> returnType) {
1775: String extension = "insertRecordProperty(\"" + strRecordId
1776: + "\", \"" + strPropName + "\", \"" + strPropValue
1777: + "\", \"" + bRedraw + "\").";
1778: try {
1779: java.lang.reflect.Constructor<T> ctor = returnType
1780: .getConstructor(Context.class, String.class,
1781: ScriptProxy.class);
1782: return ctor.newInstance(this , extension, getScriptProxy());
1783: } catch (Exception ex) {
1784: throw new IllegalArgumentException(
1785: "Unsupported return type: " + returnType.getName());
1786: }
1787: }
1788:
1789: }
|