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.gui;
0017:
0018: import org.directwebremoting.ScriptBuffer;
0019: import org.directwebremoting.proxy.ScriptProxy;
0020: import org.directwebremoting.proxy.io.Context;
0021:
0022: /**
0023: * Create GUI menus, similar in functionality to system menus (File, Edit, etc) created by the host OS.
0024:
0025: This class implements the CDF interface. Each record represents an item in the rendered menu.
0026: The following CDF attributes are supported by default:
0027:
0028: jsxid Ð the required CDF record id
0029: jsxtext Ð the text displayed in the menu option
0030: jsxtip Ð the tip displayed when the mouse hovers over the menu option
0031: jsximg Ð the optional image to display at the far left of the option
0032: jsxexecute Ð arbitrary JavaScript code to execute when the record is selected
0033: jsxkeycode Ð the optional key code to use as the hot key for the record. The format of this
0034: attribute is according to the method Form.doKeyBinding(). If this attribute is of the
0035: form {.*}, then the text between the curly brackets is interpreted as the key of a
0036: dynamic property.
0037: jsxdisabled Ð if "1" the option is disabled, the hot key is disabled and the option may not be
0038: selected with the mouse
0039: jsxdivider Ð if "1" a visual separator is rendered above the option
0040: jsxgroupname Ð if not empty, the option is grouped with other options with the same value for this
0041: attribute. Only one member of the group can be selected at one time.
0042: jsxselected Ð if "1" a the option is selected and check mark appears on the left side
0043: jsxstyle Ð additional CSS styles to apply to the option text
0044: * @author Joe Walker [joe at getahead dot org]
0045: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0046: */
0047: public class Menu extends jsx3.gui.Block {
0048: /**
0049: * All reverse ajax proxies need context to work from
0050: * @param scriptProxy The place we are writing scripts to
0051: * @param context The script that got us to where we are now
0052: */
0053: public Menu(Context context, String extension,
0054: ScriptProxy scriptProxy) {
0055: super (context, extension, scriptProxy);
0056: }
0057:
0058: /**
0059: * The instance initializer.
0060: * @param strName unique name distinguishing this object from all other JSX GUI objects in the JSX application
0061: * @param strText text for the menu (the persistent on-screen anchor that one would click to expand the menu); if the menu is only used as a context menu, this can be left null and the display property for the menu should be set to null
0062: */
0063: public Menu(String strName, String strText) {
0064: super ((Context) null, (String) null, (ScriptProxy) null);
0065: ScriptBuffer script = new ScriptBuffer();
0066: script.appendCall("new Menu", strName, strText);
0067: setInitScript(script);
0068: }
0069:
0070: /**
0071: * background-image:url(JSX/images/menu/bg.gif);backround-repeat:repeat-y; (default)
0072: */
0073: public static final String DEFAULTBACKGROUND = "background-image:url(";
0074:
0075: /**
0076: * #ffffff (default)
0077: */
0078: public static final String DEFAULTBACKGROUNDCOLOR = "#ffffff";
0079:
0080: /**
0081: *
0082: */
0083: public static final String DEFAULTXSLURL = null;
0084:
0085: /**
0086: *
0087: */
0088: public static final int DEFAULTCONTEXTLEFTOFFSET = 10;
0089:
0090: /**
0091: * Returns url for 16x16 pixel image (preferably a gif with a transparent background); returns null if no image specified or an empty string
0092: * @param callback valid URL
0093: */
0094: @SuppressWarnings("unchecked")
0095: public void getImage(
0096: org.directwebremoting.proxy.Callback<String> callback) {
0097: ScriptBuffer script = new ScriptBuffer();
0098: String callbackPrefix = "";
0099:
0100: if (callback != null) {
0101: callbackPrefix = "var reply = ";
0102: }
0103:
0104: script.appendCall(callbackPrefix + getContextPath()
0105: + "getImage");
0106:
0107: if (callback != null) {
0108: String key = org.directwebremoting.extend.CallbackHelper
0109: .saveCallback(callback, String.class);
0110: script
0111: .appendCall("__System.activateCallback", key,
0112: "reply");
0113: }
0114:
0115: getScriptProxy().addScript(script);
0116: }
0117:
0118: /**
0119: * Sets url for 16x16 pixel image (preferably a gif with a transparent background);
0120: returns a reference to self to facilitate method chaining
0121: * @param strURL valid URL
0122: * @return this object
0123: */
0124: public jsx3.gui.Menu setImage(String strURL) {
0125: ScriptBuffer script = new ScriptBuffer();
0126: script.appendCall(getContextPath() + "setImage", strURL);
0127: getScriptProxy().addScript(script);
0128: return this ;
0129: }
0130:
0131: /**
0132: * disables a menu item with the given id; this ID is the jsxid attribute on the record adhereing to the JSX Common Data Format (CDF);
0133: * @param strRecordId the jsxid property on the record node corresponding to the menu item to be disabled
0134: * @return this object.
0135: */
0136: @SuppressWarnings("unchecked")
0137: public jsx3.gui.Menu disableItem(String strRecordId) {
0138: String extension = "disableItem(\"" + strRecordId + "\").";
0139: try {
0140: java.lang.reflect.Constructor<jsx3.gui.Menu> ctor = jsx3.gui.Menu.class
0141: .getConstructor(Context.class, String.class,
0142: ScriptProxy.class);
0143: return ctor.newInstance(this , extension, getScriptProxy());
0144: } catch (Exception ex) {
0145: throw new IllegalArgumentException("Unsupported type: "
0146: + jsx3.gui.Menu.class.getName());
0147: }
0148: }
0149:
0150: /**
0151: * enables a menu item with the given id by removing its 'jsxselected'; this ID is the jsxid attribute on the record adhereing to the JSX Common Data Format (CDF);
0152: * @param strRecordId the jsxid property on the record node corresponding to the menu item to be enabled
0153: * @param bEnabled if false then disable the item
0154: * @return this object.
0155: */
0156: @SuppressWarnings("unchecked")
0157: public jsx3.gui.Menu enableItem(String strRecordId, boolean bEnabled) {
0158: String extension = "enableItem(\"" + strRecordId + "\", \""
0159: + bEnabled + "\").";
0160: try {
0161: java.lang.reflect.Constructor<jsx3.gui.Menu> ctor = jsx3.gui.Menu.class
0162: .getConstructor(Context.class, String.class,
0163: ScriptProxy.class);
0164: return ctor.newInstance(this , extension, getScriptProxy());
0165: } catch (Exception ex) {
0166: throw new IllegalArgumentException("Unsupported type: "
0167: + jsx3.gui.Menu.class.getName());
0168: }
0169: }
0170:
0171: /**
0172: * Returns whether a record is enabled.
0173: * @param strRecordId the jsxid property on the record node to query
0174: */
0175: @SuppressWarnings("unchecked")
0176: public void isItemEnabled(String strRecordId,
0177: org.directwebremoting.proxy.Callback<Boolean> callback) {
0178: ScriptBuffer script = new ScriptBuffer();
0179: String callbackPrefix = "";
0180:
0181: if (callback != null) {
0182: callbackPrefix = "var reply = ";
0183: }
0184:
0185: script.appendCall(callbackPrefix + getContextPath()
0186: + "isItemEnabled", strRecordId);
0187:
0188: if (callback != null) {
0189: String key = org.directwebremoting.extend.CallbackHelper
0190: .saveCallback(callback, Boolean.class);
0191: script
0192: .appendCall("__System.activateCallback", key,
0193: "reply");
0194: }
0195:
0196: getScriptProxy().addScript(script);
0197: }
0198:
0199: /**
0200: * flags a a menu item as being selected; if the menu item is part of a group (e.g., when the record node has an attribute called 'jsxgroupname'), all other menu
0201: items belonging to that group will be deselected
0202: * @param strRecordId the jsxid property on the record node corresponding to the menu item to be selected
0203: * @param bSelected if false then deselect the item
0204: * @return this object.
0205: */
0206: @SuppressWarnings("unchecked")
0207: public jsx3.gui.Menu selectItem(String strRecordId,
0208: boolean bSelected) {
0209: String extension = "selectItem(\"" + strRecordId + "\", \""
0210: + bSelected + "\").";
0211: try {
0212: java.lang.reflect.Constructor<jsx3.gui.Menu> ctor = jsx3.gui.Menu.class
0213: .getConstructor(Context.class, String.class,
0214: ScriptProxy.class);
0215: return ctor.newInstance(this , extension, getScriptProxy());
0216: } catch (Exception ex) {
0217: throw new IllegalArgumentException("Unsupported type: "
0218: + jsx3.gui.Menu.class.getName());
0219: }
0220: }
0221:
0222: /**
0223: * flags a a menu item as being unselected (the default state)
0224: * @param strRecordId the jsxid property on the record node corresponding to the menu item to be deselected
0225: * @return this object.
0226: */
0227: @SuppressWarnings("unchecked")
0228: public jsx3.gui.Menu deselectItem(String strRecordId) {
0229: String extension = "deselectItem(\"" + strRecordId + "\").";
0230: try {
0231: java.lang.reflect.Constructor<jsx3.gui.Menu> ctor = jsx3.gui.Menu.class
0232: .getConstructor(Context.class, String.class,
0233: ScriptProxy.class);
0234: return ctor.newInstance(this , extension, getScriptProxy());
0235: } catch (Exception ex) {
0236: throw new IllegalArgumentException("Unsupported type: "
0237: + jsx3.gui.Menu.class.getName());
0238: }
0239: }
0240:
0241: /**
0242: * Returns whether a record is selected.
0243: * @param strRecordId the jsxid property on the record node to query.
0244: */
0245: @SuppressWarnings("unchecked")
0246: public void isItemSelected(String strRecordId,
0247: org.directwebremoting.proxy.Callback<Boolean> callback) {
0248: ScriptBuffer script = new ScriptBuffer();
0249: String callbackPrefix = "";
0250:
0251: if (callback != null) {
0252: callbackPrefix = "var reply = ";
0253: }
0254:
0255: script.appendCall(callbackPrefix + getContextPath()
0256: + "isItemSelected", strRecordId);
0257:
0258: if (callback != null) {
0259: String key = org.directwebremoting.extend.CallbackHelper
0260: .saveCallback(callback, Boolean.class);
0261: script
0262: .appendCall("__System.activateCallback", key,
0263: "reply");
0264: }
0265:
0266: getScriptProxy().addScript(script);
0267: }
0268:
0269: /**
0270: * Returns the JSX GUI object that owns (contains) the context item (a CDF record) being acted upon. For example, when a context menu is shown by right-clicking on a list tree, a ref to the tree/list is persisted as this value.
0271: */
0272: public void getContextParent() {
0273: ScriptBuffer script = new ScriptBuffer();
0274: script.appendCall(getContextPath() + "getContextParent");
0275: getScriptProxy().addScript(script);
0276: }
0277:
0278: /**
0279: * Returns the CDF record ID for the context item being acted upon. For example, when a context menu is shown by right-clicking on a row in a list or a node in a tree, the CDF record ID corresponding to the clicked item is persisted as this value.
0280: */
0281: public void getContextRecordId() {
0282: ScriptBuffer script = new ScriptBuffer();
0283: script.appendCall(getContextPath() + "getContextRecordId");
0284: getScriptProxy().addScript(script);
0285: }
0286:
0287: /**
0288: * Executes the specific jsxexecute code for the menu record. This method also fires
0289: EXECUTE event for this menu but only under the deprecated 3.0 model event protocol.
0290: * @param strRecordId id for the record whose code will be fire/execute
0291: * @return this object
0292: */
0293: @SuppressWarnings("unchecked")
0294: public jsx3.gui.Menu executeRecord(String strRecordId) {
0295: String extension = "executeRecord(\"" + strRecordId + "\").";
0296: try {
0297: java.lang.reflect.Constructor<jsx3.gui.Menu> ctor = jsx3.gui.Menu.class
0298: .getConstructor(Context.class, String.class,
0299: ScriptProxy.class);
0300: return ctor.newInstance(this , extension, getScriptProxy());
0301: } catch (Exception ex) {
0302: throw new IllegalArgumentException("Unsupported type: "
0303: + jsx3.gui.Menu.class.getName());
0304: }
0305: }
0306:
0307: /**
0308: * resets the cached DHTML content; hides any open menu; when the menu is next expanded (repainted), the update will be relected
0309: * @return this object
0310: */
0311: @SuppressWarnings("unchecked")
0312: public jsx3.gui.Menu redrawRecord() {
0313: String extension = "redrawRecord().";
0314: try {
0315: java.lang.reflect.Constructor<jsx3.gui.Menu> ctor = jsx3.gui.Menu.class
0316: .getConstructor(Context.class, String.class,
0317: ScriptProxy.class);
0318: return ctor.newInstance(this , extension, getScriptProxy());
0319: } catch (Exception ex) {
0320: throw new IllegalArgumentException("Unsupported type: "
0321: + jsx3.gui.Menu.class.getName());
0322: }
0323: }
0324:
0325: /**
0326: * Returns the jsxid value in the CDF for the menu item last executed; returns null if unavailable
0327: */
0328: @SuppressWarnings("unchecked")
0329: public void getValue(
0330: org.directwebremoting.proxy.Callback<String> callback) {
0331: ScriptBuffer script = new ScriptBuffer();
0332: String callbackPrefix = "";
0333:
0334: if (callback != null) {
0335: callbackPrefix = "var reply = ";
0336: }
0337:
0338: script.appendCall(callbackPrefix + getContextPath()
0339: + "getValue");
0340:
0341: if (callback != null) {
0342: String key = org.directwebremoting.extend.CallbackHelper
0343: .saveCallback(callback, String.class);
0344: script
0345: .appendCall("__System.activateCallback", key,
0346: "reply");
0347: }
0348:
0349: getScriptProxy().addScript(script);
0350: }
0351:
0352: /**
0353: * Sets the validation state for the menu and returns the validation state.
0354: * @param callback jsx3.gui.Form.STATEVALID
0355: */
0356: @SuppressWarnings("unchecked")
0357: public void doValidate(
0358: org.directwebremoting.proxy.Callback<Integer> callback) {
0359: ScriptBuffer script = new ScriptBuffer();
0360: String callbackPrefix = "";
0361:
0362: if (callback != null) {
0363: callbackPrefix = "var reply = ";
0364: }
0365:
0366: script.appendCall(callbackPrefix + getContextPath()
0367: + "doValidate");
0368:
0369: if (callback != null) {
0370: String key = org.directwebremoting.extend.CallbackHelper
0371: .saveCallback(callback, Integer.class);
0372: script
0373: .appendCall("__System.activateCallback", key,
0374: "reply");
0375: }
0376:
0377: getScriptProxy().addScript(script);
0378: }
0379:
0380: /**
0381: * Returns whether this menu renders a visual divider on its left side.
0382: * @param callback <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>.
0383: */
0384: @SuppressWarnings("unchecked")
0385: public void getDivider(
0386: org.directwebremoting.proxy.Callback<Integer> callback) {
0387: ScriptBuffer script = new ScriptBuffer();
0388: String callbackPrefix = "";
0389:
0390: if (callback != null) {
0391: callbackPrefix = "var reply = ";
0392: }
0393:
0394: script.appendCall(callbackPrefix + getContextPath()
0395: + "getDivider");
0396:
0397: if (callback != null) {
0398: String key = org.directwebremoting.extend.CallbackHelper
0399: .saveCallback(callback, Integer.class);
0400: script
0401: .appendCall("__System.activateCallback", key,
0402: "reply");
0403: }
0404:
0405: getScriptProxy().addScript(script);
0406: }
0407:
0408: /**
0409: * Sets whether this menu renders a visual divider on its left side. The divider is useful for
0410: visually separating this menu from the next menu to the left.
0411: * @param intDivider <code>jsx3.Boolean.TRUE</code> or <code>jsx3.Boolean.FALSE</code>.
0412: * @param bRecalc
0413: * @return this objectt.
0414: */
0415: public jsx3.gui.Menu setDivider(int intDivider, boolean bRecalc) {
0416: ScriptBuffer script = new ScriptBuffer();
0417: script.appendCall(getContextPath() + "setDivider", intDivider,
0418: bRecalc);
0419: getScriptProxy().addScript(script);
0420: return this ;
0421: }
0422:
0423: /**
0424: * Resets the XML source document stored in the server cache under the XML ID of this object to an empty CDF
0425: document.
0426: */
0427: public void clearXmlData() {
0428: ScriptBuffer script = new ScriptBuffer();
0429: script.appendCall(getContextPath() + "clearXmlData");
0430: getScriptProxy().addScript(script);
0431: }
0432:
0433: /**
0434: * Returns whether this object removes its XML and XSL source documents from the cache of its server when it
0435: is destroyed.
0436: * @param callback <code>CLEANUPRESOURCES</code> or <code>SHARERESOURCES</code>.
0437: */
0438: @SuppressWarnings("unchecked")
0439: public void getShareResources(
0440: org.directwebremoting.proxy.Callback<Integer> callback) {
0441: ScriptBuffer script = new ScriptBuffer();
0442: String callbackPrefix = "";
0443:
0444: if (callback != null) {
0445: callbackPrefix = "var reply = ";
0446: }
0447:
0448: script.appendCall(callbackPrefix + getContextPath()
0449: + "getShareResources");
0450:
0451: if (callback != null) {
0452: String key = org.directwebremoting.extend.CallbackHelper
0453: .saveCallback(callback, Integer.class);
0454: script
0455: .appendCall("__System.activateCallback", key,
0456: "reply");
0457: }
0458:
0459: getScriptProxy().addScript(script);
0460: }
0461:
0462: /**
0463: * Returns the XML source document of this object. The XML document is determined by the following steps:
0464:
0465: If an XML document exists in the server cache under an ID equal to the XML ID of this object, that
0466: document is returned.
0467: If the XML string of this object is not empty, a new document is created by parsing this string.
0468: If the XML URL of this object is not empty, a new document is created by parsing the file at the location
0469: specified by the URL resolved against the server owning this object.
0470: Otherwise, an empty CDF document is returned.
0471:
0472: If a new document is created for this object (any of the steps listed above except for the first one), the
0473: following actions are also taken:
0474:
0475: If creating the document resulted in an error (XML parsing error, file not found error, etc) the offending
0476: document is returned immediately.
0477: Otherwise, setSourceXML is called on this object, passing in the created document.
0478: */
0479: @SuppressWarnings("unchecked")
0480: public jsx3.xml.CdfDocument getXML() {
0481: String extension = "getXML().";
0482: try {
0483: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0484: .getConstructor(Context.class, String.class,
0485: ScriptProxy.class);
0486: return ctor.newInstance(this , extension, getScriptProxy());
0487: } catch (Exception ex) {
0488: throw new IllegalArgumentException("Unsupported type: "
0489: + jsx3.xml.CdfDocument.class.getName());
0490: }
0491: }
0492:
0493: /**
0494: * Returns the XML source document of this object. The XML document is determined by the following steps:
0495:
0496: If an XML document exists in the server cache under an ID equal to the XML ID of this object, that
0497: document is returned.
0498: If the XML string of this object is not empty, a new document is created by parsing this string.
0499: If the XML URL of this object is not empty, a new document is created by parsing the file at the location
0500: specified by the URL resolved against the server owning this object.
0501: Otherwise, an empty CDF document is returned.
0502:
0503: If a new document is created for this object (any of the steps listed above except for the first one), the
0504: following actions are also taken:
0505:
0506: If creating the document resulted in an error (XML parsing error, file not found error, etc) the offending
0507: document is returned immediately.
0508: Otherwise, setSourceXML is called on this object, passing in the created document.
0509: * @param returnType The expected return type
0510: */
0511: @SuppressWarnings("unchecked")
0512: public <T> T getXML(Class<T> returnType) {
0513: String extension = "getXML().";
0514: try {
0515: java.lang.reflect.Constructor<T> ctor = returnType
0516: .getConstructor(Context.class, String.class,
0517: ScriptProxy.class);
0518: return ctor.newInstance(this , extension, getScriptProxy());
0519: } catch (Exception ex) {
0520: throw new IllegalArgumentException(
0521: "Unsupported return type: " + returnType.getName());
0522: }
0523: }
0524:
0525: /**
0526: * Returns the XML ID of this object.
0527: * @param callback the XML ID.
0528: */
0529: @SuppressWarnings("unchecked")
0530: public void getXMLId(
0531: org.directwebremoting.proxy.Callback<String> callback) {
0532: ScriptBuffer script = new ScriptBuffer();
0533: String callbackPrefix = "";
0534:
0535: if (callback != null) {
0536: callbackPrefix = "var reply = ";
0537: }
0538:
0539: script.appendCall(callbackPrefix + getContextPath()
0540: + "getXMLId");
0541:
0542: if (callback != null) {
0543: String key = org.directwebremoting.extend.CallbackHelper
0544: .saveCallback(callback, String.class);
0545: script
0546: .appendCall("__System.activateCallback", key,
0547: "reply");
0548: }
0549:
0550: getScriptProxy().addScript(script);
0551: }
0552:
0553: /**
0554: * Returns the XML string of this object.
0555: */
0556: @SuppressWarnings("unchecked")
0557: public void getXMLString(
0558: org.directwebremoting.proxy.Callback<String> callback) {
0559: ScriptBuffer script = new ScriptBuffer();
0560: String callbackPrefix = "";
0561:
0562: if (callback != null) {
0563: callbackPrefix = "var reply = ";
0564: }
0565:
0566: script.appendCall(callbackPrefix + getContextPath()
0567: + "getXMLString");
0568:
0569: if (callback != null) {
0570: String key = org.directwebremoting.extend.CallbackHelper
0571: .saveCallback(callback, String.class);
0572: script
0573: .appendCall("__System.activateCallback", key,
0574: "reply");
0575: }
0576:
0577: getScriptProxy().addScript(script);
0578: }
0579:
0580: /**
0581: * Returns the list of XML transformers of this object.
0582: */
0583: @SuppressWarnings("unchecked")
0584: public void getXMLTransformers(
0585: org.directwebremoting.proxy.Callback<Object[]> callback) {
0586: ScriptBuffer script = new ScriptBuffer();
0587: String callbackPrefix = "";
0588:
0589: if (callback != null) {
0590: callbackPrefix = "var reply = ";
0591: }
0592:
0593: script.appendCall(callbackPrefix + getContextPath()
0594: + "getXMLTransformers");
0595:
0596: if (callback != null) {
0597: String key = org.directwebremoting.extend.CallbackHelper
0598: .saveCallback(callback, Object[].class);
0599: script
0600: .appendCall("__System.activateCallback", key,
0601: "reply");
0602: }
0603:
0604: getScriptProxy().addScript(script);
0605: }
0606:
0607: /**
0608: * Returns the XML URL of this object.
0609: */
0610: @SuppressWarnings("unchecked")
0611: public void getXMLURL(
0612: org.directwebremoting.proxy.Callback<String> callback) {
0613: ScriptBuffer script = new ScriptBuffer();
0614: String callbackPrefix = "";
0615:
0616: if (callback != null) {
0617: callbackPrefix = "var reply = ";
0618: }
0619:
0620: script.appendCall(callbackPrefix + getContextPath()
0621: + "getXMLURL");
0622:
0623: if (callback != null) {
0624: String key = org.directwebremoting.extend.CallbackHelper
0625: .saveCallback(callback, String.class);
0626: script
0627: .appendCall("__System.activateCallback", key,
0628: "reply");
0629: }
0630:
0631: getScriptProxy().addScript(script);
0632: }
0633:
0634: /**
0635: * Returns the XSL source document of this object. The XSL document is determined by the following steps:
0636:
0637: If an XSL document exists in the server cache under an ID equal to the XSL ID of this object, that
0638: document is returned.
0639: (Deprecated) If the XSL string of this object is not null, a new document is created by parsing this string.
0640: (Deprecated) If the XSL URL of this object is not null, a new document is created by parsing the file at the location
0641: specified by the URL resolved against the server owning this object.
0642: Otherwise, the default stylesheet (Cacheable.DEFAULTSTYLESHEET) is returned.
0643: * @return the XSL source document.
0644: */
0645: @SuppressWarnings("unchecked")
0646: public jsx3.xml.CdfDocument getXSL() {
0647: String extension = "getXSL().";
0648: try {
0649: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0650: .getConstructor(Context.class, String.class,
0651: ScriptProxy.class);
0652: return ctor.newInstance(this , extension, getScriptProxy());
0653: } catch (Exception ex) {
0654: throw new IllegalArgumentException("Unsupported type: "
0655: + jsx3.xml.CdfDocument.class.getName());
0656: }
0657: }
0658:
0659: /**
0660: * Returns the XSL source document of this object. The XSL document is determined by the following steps:
0661:
0662: If an XSL document exists in the server cache under an ID equal to the XSL ID of this object, that
0663: document is returned.
0664: (Deprecated) If the XSL string of this object is not null, a new document is created by parsing this string.
0665: (Deprecated) If the XSL URL of this object is not null, a new document is created by parsing the file at the location
0666: specified by the URL resolved against the server owning this object.
0667: Otherwise, the default stylesheet (Cacheable.DEFAULTSTYLESHEET) is returned.
0668: * @param returnType The expected return type
0669: * @return the XSL source document.
0670: */
0671: @SuppressWarnings("unchecked")
0672: public <T> T getXSL(Class<T> returnType) {
0673: String extension = "getXSL().";
0674: try {
0675: java.lang.reflect.Constructor<T> ctor = returnType
0676: .getConstructor(Context.class, String.class,
0677: ScriptProxy.class);
0678: return ctor.newInstance(this , extension, getScriptProxy());
0679: } catch (Exception ex) {
0680: throw new IllegalArgumentException(
0681: "Unsupported return type: " + returnType.getName());
0682: }
0683: }
0684:
0685: /**
0686: * Returns the XSL ID of this object.
0687: */
0688: @SuppressWarnings("unchecked")
0689: public void getXSLId(
0690: org.directwebremoting.proxy.Callback<String> callback) {
0691: ScriptBuffer script = new ScriptBuffer();
0692: String callbackPrefix = "";
0693:
0694: if (callback != null) {
0695: callbackPrefix = "var reply = ";
0696: }
0697:
0698: script.appendCall(callbackPrefix + getContextPath()
0699: + "getXSLId");
0700:
0701: if (callback != null) {
0702: String key = org.directwebremoting.extend.CallbackHelper
0703: .saveCallback(callback, String.class);
0704: script
0705: .appendCall("__System.activateCallback", key,
0706: "reply");
0707: }
0708:
0709: getScriptProxy().addScript(script);
0710: }
0711:
0712: /**
0713: * Returns a map containing all the parameters to pass to the XSL stylesheet during transformation.
0714: */
0715: @SuppressWarnings("unchecked")
0716: public jsx3.lang.Object getXSLParams() {
0717: String extension = "getXSLParams().";
0718: try {
0719: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
0720: .getConstructor(Context.class, String.class,
0721: ScriptProxy.class);
0722: return ctor.newInstance(this , extension, getScriptProxy());
0723: } catch (Exception ex) {
0724: throw new IllegalArgumentException("Unsupported type: "
0725: + jsx3.lang.Object.class.getName());
0726: }
0727: }
0728:
0729: /**
0730: * Returns a map containing all the parameters to pass to the XSL stylesheet during transformation.
0731: * @param returnType The expected return type
0732: */
0733: @SuppressWarnings("unchecked")
0734: public <T> T getXSLParams(Class<T> returnType) {
0735: String extension = "getXSLParams().";
0736: try {
0737: java.lang.reflect.Constructor<T> ctor = returnType
0738: .getConstructor(Context.class, String.class,
0739: ScriptProxy.class);
0740: return ctor.newInstance(this , extension, getScriptProxy());
0741: } catch (Exception ex) {
0742: throw new IllegalArgumentException(
0743: "Unsupported return type: " + returnType.getName());
0744: }
0745: }
0746:
0747: /**
0748: * Returns whether the XML data source of this object is loaded asynchronously.
0749: * @param callback <code>0</code> or <code>1</code>.
0750: */
0751: @SuppressWarnings("unchecked")
0752: public void getXmlAsync(
0753: org.directwebremoting.proxy.Callback<Integer> callback) {
0754: ScriptBuffer script = new ScriptBuffer();
0755: String callbackPrefix = "";
0756:
0757: if (callback != null) {
0758: callbackPrefix = "var reply = ";
0759: }
0760:
0761: script.appendCall(callbackPrefix + getContextPath()
0762: + "getXmlAsync");
0763:
0764: if (callback != null) {
0765: String key = org.directwebremoting.extend.CallbackHelper
0766: .saveCallback(callback, Integer.class);
0767: script
0768: .appendCall("__System.activateCallback", key,
0769: "reply");
0770: }
0771:
0772: getScriptProxy().addScript(script);
0773: }
0774:
0775: /**
0776: * Returns whether this object is bound to the XML document stored in the data cache.
0777: * @param callback <code>0</code> or <code>1</code>.
0778: */
0779: @SuppressWarnings("unchecked")
0780: public void getXmlBind(
0781: org.directwebremoting.proxy.Callback<Integer> callback) {
0782: ScriptBuffer script = new ScriptBuffer();
0783: String callbackPrefix = "";
0784:
0785: if (callback != null) {
0786: callbackPrefix = "var reply = ";
0787: }
0788:
0789: script.appendCall(callbackPrefix + getContextPath()
0790: + "getXmlBind");
0791:
0792: if (callback != null) {
0793: String key = org.directwebremoting.extend.CallbackHelper
0794: .saveCallback(callback, Integer.class);
0795: script
0796: .appendCall("__System.activateCallback", key,
0797: "reply");
0798: }
0799:
0800: getScriptProxy().addScript(script);
0801: }
0802:
0803: /**
0804: * This method is called in two situations:
0805:
0806: When the datasource of this object finishes loading (success, error, or timeout), if the
0807: xmlAsync property of this object is true, its datasource is specified as an
0808: XML URL, and the first time doTransform() was called the datasource was still loading.
0809: Any time the value stored in the server XML cache under the key equal to the XML Id of this object
0810: changes, if the xmlBind property of this object is true.
0811:
0812: Any methods overriding this method should begin with a call to jsxsupermix().
0813: * @param objEvent the event published by the cache.
0814: */
0815: public void onXmlBinding(jsx3.lang.Object objEvent) {
0816: ScriptBuffer script = new ScriptBuffer();
0817: script.appendCall(getContextPath() + "onXmlBinding", objEvent);
0818: getScriptProxy().addScript(script);
0819: }
0820:
0821: /**
0822: * Removes a parameter from the list of parameters to pass to the XSL stylesheet during transformation.
0823: * @param strName the name of the XSL parameter to remove.
0824: * @return this object.
0825: */
0826: @SuppressWarnings("unchecked")
0827: public jsx3.xml.Cacheable removeXSLParam(String strName) {
0828: String extension = "removeXSLParam(\"" + strName + "\").";
0829: try {
0830: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
0831: .getConstructor(Context.class, String.class,
0832: ScriptProxy.class);
0833: return ctor.newInstance(this , extension, getScriptProxy());
0834: } catch (Exception ex) {
0835: throw new IllegalArgumentException("Unsupported type: "
0836: + jsx3.xml.Cacheable.class.getName());
0837: }
0838: }
0839:
0840: /**
0841: * Removes a parameter from the list of parameters to pass to the XSL stylesheet during transformation.
0842: * @param strName the name of the XSL parameter to remove.
0843: * @param returnType The expected return type
0844: * @return this object.
0845: */
0846: @SuppressWarnings("unchecked")
0847: public <T> T removeXSLParam(String strName, Class<T> returnType) {
0848: String extension = "removeXSLParam(\"" + strName + "\").";
0849: try {
0850: java.lang.reflect.Constructor<T> ctor = returnType
0851: .getConstructor(Context.class, String.class,
0852: ScriptProxy.class);
0853: return ctor.newInstance(this , extension, getScriptProxy());
0854: } catch (Exception ex) {
0855: throw new IllegalArgumentException(
0856: "Unsupported return type: " + returnType.getName());
0857: }
0858: }
0859:
0860: /**
0861: * Removes all parameters from the list of parameters to pass to the XSL stylesheet during transformation.
0862: * @return this object.
0863: */
0864: @SuppressWarnings("unchecked")
0865: public jsx3.xml.Cacheable removeXSLParams() {
0866: String extension = "removeXSLParams().";
0867: try {
0868: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
0869: .getConstructor(Context.class, String.class,
0870: ScriptProxy.class);
0871: return ctor.newInstance(this , extension, getScriptProxy());
0872: } catch (Exception ex) {
0873: throw new IllegalArgumentException("Unsupported type: "
0874: + jsx3.xml.Cacheable.class.getName());
0875: }
0876: }
0877:
0878: /**
0879: * Removes all parameters from the list of parameters to pass to the XSL stylesheet during transformation.
0880: * @param returnType The expected return type
0881: * @return this object.
0882: */
0883: @SuppressWarnings("unchecked")
0884: public <T> T removeXSLParams(Class<T> returnType) {
0885: String extension = "removeXSLParams().";
0886: try {
0887: java.lang.reflect.Constructor<T> ctor = returnType
0888: .getConstructor(Context.class, String.class,
0889: ScriptProxy.class);
0890: return ctor.newInstance(this , extension, getScriptProxy());
0891: } catch (Exception ex) {
0892: throw new IllegalArgumentException(
0893: "Unsupported return type: " + returnType.getName());
0894: }
0895: }
0896:
0897: /**
0898: * Removes the XML and XSL source documents from the server cache.
0899: * @param objServer the server owning the cache to modify. This is a required argument only if
0900: <code>this.getServer()</code> does not returns a server instance.
0901: */
0902: public void resetCacheData(jsx3.app.Server objServer) {
0903: ScriptBuffer script = new ScriptBuffer();
0904: script.appendCall(getContextPath() + "resetCacheData",
0905: objServer);
0906: getScriptProxy().addScript(script);
0907: }
0908:
0909: /**
0910: * Removes the XML source document stored under the XML ID of this object from the server cache.
0911: * @param objServer the server owning the cache to modify. This is a required argument only if
0912: <code>this.getServer()</code> does not returns a server instance.
0913: */
0914: public void resetXmlCacheData(jsx3.app.Server objServer) {
0915: ScriptBuffer script = new ScriptBuffer();
0916: script.appendCall(getContextPath() + "resetXmlCacheData",
0917: objServer);
0918: getScriptProxy().addScript(script);
0919: }
0920:
0921: /**
0922: * Sets whether this object removes its XML and XSL source documents from the cache of its server when it
0923: is destroyed.
0924: * @param intShare <code>CLEANUPRESOURCES</code> or <code>SHARERESOURCES</code>. <code>CLEANUPRESOURCES</code>
0925: is the default value if the property is <code>null</code>.
0926: * @return this object.
0927: */
0928: @SuppressWarnings("unchecked")
0929: public jsx3.xml.Cacheable setShareResources(int intShare) {
0930: String extension = "setShareResources(\"" + intShare + "\").";
0931: try {
0932: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
0933: .getConstructor(Context.class, String.class,
0934: ScriptProxy.class);
0935: return ctor.newInstance(this , extension, getScriptProxy());
0936: } catch (Exception ex) {
0937: throw new IllegalArgumentException("Unsupported type: "
0938: + jsx3.xml.Cacheable.class.getName());
0939: }
0940: }
0941:
0942: /**
0943: * Sets whether this object removes its XML and XSL source documents from the cache of its server when it
0944: is destroyed.
0945: * @param intShare <code>CLEANUPRESOURCES</code> or <code>SHARERESOURCES</code>. <code>CLEANUPRESOURCES</code>
0946: is the default value if the property is <code>null</code>.
0947: * @param returnType The expected return type
0948: * @return this object.
0949: */
0950: @SuppressWarnings("unchecked")
0951: public <T> T setShareResources(int intShare, Class<T> returnType) {
0952: String extension = "setShareResources(\"" + intShare + "\").";
0953: try {
0954: java.lang.reflect.Constructor<T> ctor = returnType
0955: .getConstructor(Context.class, String.class,
0956: ScriptProxy.class);
0957: return ctor.newInstance(this , extension, getScriptProxy());
0958: } catch (Exception ex) {
0959: throw new IllegalArgumentException(
0960: "Unsupported return type: " + returnType.getName());
0961: }
0962: }
0963:
0964: /**
0965: * Sets the source document of this object as though objDoc were retrieved from the XML URL or XML
0966: string of this object. This method executes the following steps:
0967:
0968: The document is transformed serially by each XML transformers of this object.
0969: The XML document is saved in the server cache under the XML ID of this object.
0970: If this object is an instance of jsx3.xml.CDF and the root node is a <data> element
0971: and its jsxassignids attribute is equal to 1, all <record> elements without a
0972: jsxid attribute are assigned a unique jsxid.
0973: If this object is an instance of jsx3.xml.CDF, convertProperties() is called
0974: on this object.
0975: * @param objDoc
0976: * @param objCache
0977: * @return the document stored in the server cache as the data source of this object. If
0978: transformers were run, this value will not be equal to the <code>objDoc</code> parameter.
0979: */
0980: @SuppressWarnings("unchecked")
0981: public jsx3.xml.CdfDocument setSourceXML(
0982: jsx3.xml.CdfDocument objDoc, jsx3.app.Cache objCache) {
0983: String extension = "setSourceXML(\"" + objDoc + "\", \""
0984: + objCache + "\").";
0985: try {
0986: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
0987: .getConstructor(Context.class, String.class,
0988: ScriptProxy.class);
0989: return ctor.newInstance(this , extension, getScriptProxy());
0990: } catch (Exception ex) {
0991: throw new IllegalArgumentException("Unsupported type: "
0992: + jsx3.xml.CdfDocument.class.getName());
0993: }
0994: }
0995:
0996: /**
0997: * Sets the source document of this object as though objDoc were retrieved from the XML URL or XML
0998: string of this object. This method executes the following steps:
0999:
1000: The document is transformed serially by each XML transformers of this object.
1001: The XML document is saved in the server cache under the XML ID of this object.
1002: If this object is an instance of jsx3.xml.CDF and the root node is a <data> element
1003: and its jsxassignids attribute is equal to 1, all <record> elements without a
1004: jsxid attribute are assigned a unique jsxid.
1005: If this object is an instance of jsx3.xml.CDF, convertProperties() is called
1006: on this object.
1007: * @param objDoc
1008: * @param objCache
1009: * @param returnType The expected return type
1010: * @return the document stored in the server cache as the data source of this object. If
1011: transformers were run, this value will not be equal to the <code>objDoc</code> parameter.
1012: */
1013: @SuppressWarnings("unchecked")
1014: public <T> T setSourceXML(jsx3.xml.CdfDocument objDoc,
1015: jsx3.app.Cache objCache, Class<T> returnType) {
1016: String extension = "setSourceXML(\"" + objDoc + "\", \""
1017: + objCache + "\").";
1018: try {
1019: java.lang.reflect.Constructor<T> ctor = returnType
1020: .getConstructor(Context.class, String.class,
1021: ScriptProxy.class);
1022: return ctor.newInstance(this , extension, getScriptProxy());
1023: } catch (Exception ex) {
1024: throw new IllegalArgumentException(
1025: "Unsupported return type: " + returnType.getName());
1026: }
1027: }
1028:
1029: /**
1030: * Sets the XML ID of this object. This value is the key under which the XML source document of this object is
1031: saved in the cache of the server owning this object. The developer may specify either a unique or shared value.
1032: If no value is specified, a unique id is generated.
1033: * @param strXMLId
1034: * @return this object.
1035: */
1036: @SuppressWarnings("unchecked")
1037: public jsx3.xml.Cacheable setXMLId(String strXMLId) {
1038: String extension = "setXMLId(\"" + strXMLId + "\").";
1039: try {
1040: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1041: .getConstructor(Context.class, String.class,
1042: ScriptProxy.class);
1043: return ctor.newInstance(this , extension, getScriptProxy());
1044: } catch (Exception ex) {
1045: throw new IllegalArgumentException("Unsupported type: "
1046: + jsx3.xml.Cacheable.class.getName());
1047: }
1048: }
1049:
1050: /**
1051: * Sets the XML ID of this object. This value is the key under which the XML source document of this object is
1052: saved in the cache of the server owning this object. The developer may specify either a unique or shared value.
1053: If no value is specified, a unique id is generated.
1054: * @param strXMLId
1055: * @param returnType The expected return type
1056: * @return this object.
1057: */
1058: @SuppressWarnings("unchecked")
1059: public <T> T setXMLId(String strXMLId, Class<T> returnType) {
1060: String extension = "setXMLId(\"" + strXMLId + "\").";
1061: try {
1062: java.lang.reflect.Constructor<T> ctor = returnType
1063: .getConstructor(Context.class, String.class,
1064: ScriptProxy.class);
1065: return ctor.newInstance(this , extension, getScriptProxy());
1066: } catch (Exception ex) {
1067: throw new IllegalArgumentException(
1068: "Unsupported return type: " + returnType.getName());
1069: }
1070: }
1071:
1072: /**
1073: * Sets the XML string of this object. Setting this value to the string serialization of an XML document is one
1074: way of specifying the source XML document of this object.
1075: * @param strXML <code>null</code> or a well-formed serialized XML element.
1076: * @return this object.
1077: */
1078: @SuppressWarnings("unchecked")
1079: public jsx3.xml.Cacheable setXMLString(String strXML) {
1080: String extension = "setXMLString(\"" + strXML + "\").";
1081: try {
1082: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1083: .getConstructor(Context.class, String.class,
1084: ScriptProxy.class);
1085: return ctor.newInstance(this , extension, getScriptProxy());
1086: } catch (Exception ex) {
1087: throw new IllegalArgumentException("Unsupported type: "
1088: + jsx3.xml.Cacheable.class.getName());
1089: }
1090: }
1091:
1092: /**
1093: * Sets the XML string of this object. Setting this value to the string serialization of an XML document is one
1094: way of specifying the source XML document of this object.
1095: * @param strXML <code>null</code> or a well-formed serialized XML element.
1096: * @param returnType The expected return type
1097: * @return this object.
1098: */
1099: @SuppressWarnings("unchecked")
1100: public <T> T setXMLString(String strXML, Class<T> returnType) {
1101: String extension = "setXMLString(\"" + strXML + "\").";
1102: try {
1103: java.lang.reflect.Constructor<T> ctor = returnType
1104: .getConstructor(Context.class, String.class,
1105: ScriptProxy.class);
1106: return ctor.newInstance(this , extension, getScriptProxy());
1107: } catch (Exception ex) {
1108: throw new IllegalArgumentException(
1109: "Unsupported return type: " + returnType.getName());
1110: }
1111: }
1112:
1113: /**
1114: * Sets the list of XML transformers of this object. The XML source document of this object is transformed
1115: serially by each of these transformers before it is placed in the XML cache.
1116:
1117: Each transformer is either the URI of an XSLT document (which will be resolved against the
1118: the server of this object) or the cache id of a XSLT document in the XML cache of the server
1119: of this object. When any transformer is loaded from a URI it is placed in the server cache under the id
1120: equal to its resolved URI. Any transformer that does not correspond to a valid XSLT document will be skipped
1121: without throwing an error.
1122: * @param arrTrans
1123: */
1124: public void setXMLTransformers(Object[] arrTrans) {
1125: ScriptBuffer script = new ScriptBuffer();
1126: script.appendCall(getContextPath() + "setXMLTransformers",
1127: arrTrans);
1128: getScriptProxy().addScript(script);
1129: }
1130:
1131: /**
1132: * Sets the XML URL of this object. Settings this value to the URI of an XML document is one way of specifying the
1133: source XML document of this object.
1134: * @param strXMLURL <code>null</code> or a URI that when resolved against the server owning this object
1135: specifies a valid XML document.
1136: * @return this object.
1137: */
1138: @SuppressWarnings("unchecked")
1139: public jsx3.xml.Cacheable setXMLURL(String strXMLURL) {
1140: String extension = "setXMLURL(\"" + strXMLURL + "\").";
1141: try {
1142: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1143: .getConstructor(Context.class, String.class,
1144: ScriptProxy.class);
1145: return ctor.newInstance(this , extension, getScriptProxy());
1146: } catch (Exception ex) {
1147: throw new IllegalArgumentException("Unsupported type: "
1148: + jsx3.xml.Cacheable.class.getName());
1149: }
1150: }
1151:
1152: /**
1153: * Sets the XML URL of this object. Settings this value to the URI of an XML document is one way of specifying the
1154: source XML document of this object.
1155: * @param strXMLURL <code>null</code> or a URI that when resolved against the server owning this object
1156: specifies a valid XML document.
1157: * @param returnType The expected return type
1158: * @return this object.
1159: */
1160: @SuppressWarnings("unchecked")
1161: public <T> T setXMLURL(String strXMLURL, Class<T> returnType) {
1162: String extension = "setXMLURL(\"" + strXMLURL + "\").";
1163: try {
1164: java.lang.reflect.Constructor<T> ctor = returnType
1165: .getConstructor(Context.class, String.class,
1166: ScriptProxy.class);
1167: return ctor.newInstance(this , extension, getScriptProxy());
1168: } catch (Exception ex) {
1169: throw new IllegalArgumentException(
1170: "Unsupported return type: " + returnType.getName());
1171: }
1172: }
1173:
1174: /**
1175: * Adds a name/value pair to the list of parameters to pass to the XSL stylesheet during transformation. If
1176: strValue is null the parameter is removed.
1177: * @param strName the name of the XSL parameter to add.
1178: * @param strValue the value of the XSL parameter to add.
1179: * @return this object.
1180: */
1181: @SuppressWarnings("unchecked")
1182: public jsx3.xml.Cacheable setXSLParam(String strName,
1183: String strValue) {
1184: String extension = "setXSLParam(\"" + strName + "\", \""
1185: + strValue + "\").";
1186: try {
1187: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1188: .getConstructor(Context.class, String.class,
1189: ScriptProxy.class);
1190: return ctor.newInstance(this , extension, getScriptProxy());
1191: } catch (Exception ex) {
1192: throw new IllegalArgumentException("Unsupported type: "
1193: + jsx3.xml.Cacheable.class.getName());
1194: }
1195: }
1196:
1197: /**
1198: * Adds a name/value pair to the list of parameters to pass to the XSL stylesheet during transformation. If
1199: strValue is null the parameter is removed.
1200: * @param strName the name of the XSL parameter to add.
1201: * @param strValue the value of the XSL parameter to add.
1202: * @param returnType The expected return type
1203: * @return this object.
1204: */
1205: @SuppressWarnings("unchecked")
1206: public <T> T setXSLParam(String strName, String strValue,
1207: Class<T> returnType) {
1208: String extension = "setXSLParam(\"" + strName + "\", \""
1209: + strValue + "\").";
1210: try {
1211: java.lang.reflect.Constructor<T> ctor = returnType
1212: .getConstructor(Context.class, String.class,
1213: ScriptProxy.class);
1214: return ctor.newInstance(this , extension, getScriptProxy());
1215: } catch (Exception ex) {
1216: throw new IllegalArgumentException(
1217: "Unsupported return type: " + returnType.getName());
1218: }
1219: }
1220:
1221: /**
1222: * Sets whether the XML data source of this object is loaded asynchronously. This setting only applies to
1223: data sources loaded from an XML URL.
1224: * @param bAsync
1225: * @return this object.
1226: */
1227: @SuppressWarnings("unchecked")
1228: public jsx3.xml.Cacheable setXmlAsync(boolean bAsync) {
1229: String extension = "setXmlAsync(\"" + bAsync + "\").";
1230: try {
1231: java.lang.reflect.Constructor<jsx3.xml.Cacheable> ctor = jsx3.xml.Cacheable.class
1232: .getConstructor(Context.class, String.class,
1233: ScriptProxy.class);
1234: return ctor.newInstance(this , extension, getScriptProxy());
1235: } catch (Exception ex) {
1236: throw new IllegalArgumentException("Unsupported type: "
1237: + jsx3.xml.Cacheable.class.getName());
1238: }
1239: }
1240:
1241: /**
1242: * Sets whether the XML data source of this object is loaded asynchronously. This setting only applies to
1243: data sources loaded from an XML URL.
1244: * @param bAsync
1245: * @param returnType The expected return type
1246: * @return this object.
1247: */
1248: @SuppressWarnings("unchecked")
1249: public <T> T setXmlAsync(boolean bAsync, Class<T> returnType) {
1250: String extension = "setXmlAsync(\"" + bAsync + "\").";
1251: try {
1252: java.lang.reflect.Constructor<T> ctor = returnType
1253: .getConstructor(Context.class, String.class,
1254: ScriptProxy.class);
1255: return ctor.newInstance(this , extension, getScriptProxy());
1256: } catch (Exception ex) {
1257: throw new IllegalArgumentException(
1258: "Unsupported return type: " + returnType.getName());
1259: }
1260: }
1261:
1262: /**
1263: * Sets whether this object is bound to the XML document stored in the data cache. If this object is bound to the
1264: cache, then the onXmlBinding() method of this object is called any time the document stored in
1265: the cache under the XML Id of this object changes.
1266: * @param bBind
1267: * @param callback <code>0</code> or <code>1</code>.
1268: */
1269: @SuppressWarnings("unchecked")
1270: public void setXmlBind(boolean bBind,
1271: org.directwebremoting.proxy.Callback<Integer> callback) {
1272: ScriptBuffer script = new ScriptBuffer();
1273: String callbackPrefix = "";
1274:
1275: if (callback != null) {
1276: callbackPrefix = "var reply = ";
1277: }
1278:
1279: script.appendCall(callbackPrefix + getContextPath()
1280: + "setXmlBind", bBind);
1281:
1282: if (callback != null) {
1283: String key = org.directwebremoting.extend.CallbackHelper
1284: .saveCallback(callback, Integer.class);
1285: script
1286: .appendCall("__System.activateCallback", key,
1287: "reply");
1288: }
1289:
1290: getScriptProxy().addScript(script);
1291: }
1292:
1293: /**
1294: * Transfers a CDF record from another object to this object. If no XML data source exists
1295: yet for this object, an empty one is created before adding the new record. This method always updates the
1296: on-screen view of both the source and destination objects.
1297:
1298: This method fails quietly if any of the following conditions apply:
1299:
1300: there is no object with id equal to strSourceId
1301:
1302: there is no record in the source object with jsxid equal to strRecordId
1303:
1304:
1305: strParentRecordId is specified and there is no record in this object with
1306: jsxid equal to strParentRecordId
1307:
1308: the this object already has a record with jsxid equal to the record to adopt
1309: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1310: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1311: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1312: is provided, the adopted record will be added as a child of this record. Otherwise, the adopted record will
1313: be added to the root <code>data</code> element.
1314: * @param bRedraw forces suppression of the insert event
1315: * @return the adopted record.
1316: */
1317: @SuppressWarnings("unchecked")
1318: public jsx3.xml.Node adoptRecord(jsx3.xml.CdfDocument strSourceId,
1319: String strRecordId, String strParentRecordId,
1320: boolean bRedraw) {
1321: String extension = "adoptRecord(\"" + strSourceId + "\", \""
1322: + strRecordId + "\", \"" + strParentRecordId + "\", \""
1323: + bRedraw + "\").";
1324: try {
1325: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1326: .getConstructor(Context.class, String.class,
1327: ScriptProxy.class);
1328: return ctor.newInstance(this , extension, getScriptProxy());
1329: } catch (Exception ex) {
1330: throw new IllegalArgumentException("Unsupported type: "
1331: + jsx3.xml.Node.class.getName());
1332: }
1333: }
1334:
1335: /**
1336: * Transfers a CDF record from another object to this object. If no XML data source exists
1337: yet for this object, an empty one is created before adding the new record. This method always updates the
1338: on-screen view of both the source and destination objects.
1339:
1340: This method fails quietly if any of the following conditions apply:
1341:
1342: there is no object with id equal to strSourceId
1343:
1344: there is no record in the source object with jsxid equal to strRecordId
1345:
1346:
1347: strParentRecordId is specified and there is no record in this object with
1348: jsxid equal to strParentRecordId
1349:
1350: the this object already has a record with jsxid equal to the record to adopt
1351: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1352: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1353: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1354: is provided, the adopted record will be added as a child of this record. Otherwise, the adopted record will
1355: be added to the root <code>data</code> element.
1356: * @param bRedraw forces suppression of the insert event
1357: * @return the adopted record.
1358: */
1359: @SuppressWarnings("unchecked")
1360: public jsx3.xml.Node adoptRecord(String strSourceId,
1361: String strRecordId, String strParentRecordId,
1362: boolean bRedraw) {
1363: String extension = "adoptRecord(\"" + strSourceId + "\", \""
1364: + strRecordId + "\", \"" + strParentRecordId + "\", \""
1365: + bRedraw + "\").";
1366: try {
1367: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1368: .getConstructor(Context.class, String.class,
1369: ScriptProxy.class);
1370: return ctor.newInstance(this , extension, getScriptProxy());
1371: } catch (Exception ex) {
1372: throw new IllegalArgumentException("Unsupported type: "
1373: + jsx3.xml.Node.class.getName());
1374: }
1375: }
1376:
1377: /**
1378: * Equivalent to adoptRecord, except that the to-be relationship is as a previousSibling to the CDF record identified by the parameter, strSiblingRecordId
1379:
1380: This method fails quietly if any of the following conditions apply:
1381:
1382: there is no record with a jsxid equal to strSourceId
1383:
1384: there is no record in the source object with a jsxid equal to strRecordId
1385:
1386:
1387: strSiblingRecordId is specified and there is no record in this object with a
1388: jsxid equal to strParentRecordId
1389:
1390: this object already has a record with jsxid equal to the record to adopt
1391: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1392: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1393: * @param strSiblingRecordId the unique <code>jsxid</code> of an existing record in front of
1394: which the record identified by strSourceId will be placed
1395: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1396: immediately updated to reflect the deleted record.
1397: * @return the adopted record.
1398: */
1399: @SuppressWarnings("unchecked")
1400: public jsx3.xml.Node adoptRecordBefore(String strSourceId,
1401: String strRecordId, String strSiblingRecordId,
1402: boolean bRedraw) {
1403: String extension = "adoptRecordBefore(\"" + strSourceId
1404: + "\", \"" + strRecordId + "\", \""
1405: + strSiblingRecordId + "\", \"" + bRedraw + "\").";
1406: try {
1407: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1408: .getConstructor(Context.class, String.class,
1409: ScriptProxy.class);
1410: return ctor.newInstance(this , extension, getScriptProxy());
1411: } catch (Exception ex) {
1412: throw new IllegalArgumentException("Unsupported type: "
1413: + jsx3.xml.Node.class.getName());
1414: }
1415: }
1416:
1417: /**
1418: * Equivalent to adoptRecord, except that the to-be relationship is as a previousSibling to the CDF record identified by the parameter, strSiblingRecordId
1419:
1420: This method fails quietly if any of the following conditions apply:
1421:
1422: there is no record with a jsxid equal to strSourceId
1423:
1424: there is no record in the source object with a jsxid equal to strRecordId
1425:
1426:
1427: strSiblingRecordId is specified and there is no record in this object with a
1428: jsxid equal to strParentRecordId
1429:
1430: this object already has a record with jsxid equal to the record to adopt
1431: * @param strSourceId <span style="text-decoration: line-through;">either the id of the source object or the</span> source object itself.
1432: * @param strRecordId the <code>jsxid</code> attribute of the data record in the source object to transfer.
1433: * @param strSiblingRecordId the unique <code>jsxid</code> of an existing record in front of
1434: which the record identified by strSourceId will be placed
1435: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1436: immediately updated to reflect the deleted record.
1437: * @return the adopted record.
1438: */
1439: @SuppressWarnings("unchecked")
1440: public jsx3.xml.Node adoptRecordBefore(
1441: jsx3.xml.CdfDocument strSourceId, String strRecordId,
1442: String strSiblingRecordId, boolean bRedraw) {
1443: String extension = "adoptRecordBefore(\"" + strSourceId
1444: + "\", \"" + strRecordId + "\", \""
1445: + strSiblingRecordId + "\", \"" + bRedraw + "\").";
1446: try {
1447: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1448: .getConstructor(Context.class, String.class,
1449: ScriptProxy.class);
1450: return ctor.newInstance(this , extension, getScriptProxy());
1451: } catch (Exception ex) {
1452: throw new IllegalArgumentException("Unsupported type: "
1453: + jsx3.xml.Node.class.getName());
1454: }
1455: }
1456:
1457: /**
1458: * Converts all attributes in this CDF document that are property keys of the form {key} to
1459: the value of the property.
1460: * @param objProps the properties repository to query.
1461: * @param arrProps if provided, these attributes are converted rather than the default set of
1462: attributes.
1463: * @param bUnion if <code>true</code>, <code>arrProps</code> is combined with the default set of
1464: attributes and those attributes are converted.
1465: */
1466: public void convertProperties(java.util.Properties objProps,
1467: Object[] arrProps, boolean bUnion) {
1468: ScriptBuffer script = new ScriptBuffer();
1469: script.appendCall(getContextPath() + "convertProperties",
1470: objProps, arrProps, bUnion);
1471: getScriptProxy().addScript(script);
1472: }
1473:
1474: /**
1475: * Removes a record from the XML data source of this object.
1476: * @param strRecordId the <code>jsxid</code> attribute of the data record to remove.
1477: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1478: immediately updated to reflect the deleted record.
1479: * @return the record removed from the data source or <code>null</code> if no such record found.
1480: */
1481: @SuppressWarnings("unchecked")
1482: public jsx3.xml.Node deleteRecord(String strRecordId,
1483: boolean bRedraw) {
1484: String extension = "deleteRecord(\"" + strRecordId + "\", \""
1485: + bRedraw + "\").";
1486: try {
1487: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1488: .getConstructor(Context.class, String.class,
1489: ScriptProxy.class);
1490: return ctor.newInstance(this , extension, getScriptProxy());
1491: } catch (Exception ex) {
1492: throw new IllegalArgumentException("Unsupported type: "
1493: + jsx3.xml.Node.class.getName());
1494: }
1495: }
1496:
1497: /**
1498: * Removes a specific property from a record. If no such record exists in the XML document, this method fails quietly.
1499: * @param strRecordId the <code>jsxid</code> attribute of the data record to modify.
1500: * @param strPropName the name of the property to remove from the record.
1501: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1502: immediately updated to reflect the deleted property.
1503: */
1504: public void deleteRecordProperty(String strRecordId,
1505: String strPropName, boolean bRedraw) {
1506: ScriptBuffer script = new ScriptBuffer();
1507: script.appendCall(getContextPath() + "deleteRecordProperty",
1508: strRecordId, strPropName, bRedraw);
1509: getScriptProxy().addScript(script);
1510: }
1511:
1512: /**
1513: * Returns an object containing the attributes of a particular CDF record as property/value pairs. The object returned by this
1514: method is a copy of the underlying data. Therefore, updates to this object will not affect the underlying data.
1515:
1516: The following two lines of code evaluate to the same value:
1517:
1518: objCDF.getRecord(strId).propName;
1519: objCDF.getRecordNode(strId).getAttribute("propName");
1520: * @param strRecordId the <code>jsxid</code> attribute of the data record to return.
1521: * @return the object representation of a CDF node or <code>null</code> if no such record found.
1522: */
1523: @SuppressWarnings("unchecked")
1524: public jsx3.lang.Object getRecord(String strRecordId) {
1525: String extension = "getRecord(\"" + strRecordId + "\").";
1526: try {
1527: java.lang.reflect.Constructor<jsx3.lang.Object> ctor = jsx3.lang.Object.class
1528: .getConstructor(Context.class, String.class,
1529: ScriptProxy.class);
1530: return ctor.newInstance(this , extension, getScriptProxy());
1531: } catch (Exception ex) {
1532: throw new IllegalArgumentException("Unsupported type: "
1533: + jsx3.lang.Object.class.getName());
1534: }
1535: }
1536:
1537: /**
1538: * Returns an object containing the attributes of a particular CDF record as property/value pairs. The object returned by this
1539: method is a copy of the underlying data. Therefore, updates to this object will not affect the underlying data.
1540:
1541: The following two lines of code evaluate to the same value:
1542:
1543: objCDF.getRecord(strId).propName;
1544: objCDF.getRecordNode(strId).getAttribute("propName");
1545: * @param strRecordId the <code>jsxid</code> attribute of the data record to return.
1546: * @param returnType The expected return type
1547: * @return the object representation of a CDF node or <code>null</code> if no such record found.
1548: */
1549: @SuppressWarnings("unchecked")
1550: public <T> T getRecord(String strRecordId, Class<T> returnType) {
1551: String extension = "getRecord(\"" + strRecordId + "\").";
1552: try {
1553: java.lang.reflect.Constructor<T> ctor = returnType
1554: .getConstructor(Context.class, String.class,
1555: ScriptProxy.class);
1556: return ctor.newInstance(this , extension, getScriptProxy());
1557: } catch (Exception ex) {
1558: throw new IllegalArgumentException(
1559: "Unsupported return type: " + returnType.getName());
1560: }
1561: }
1562:
1563: /**
1564: * Returns a record from the XML data source of this object. This returned value is a handle to the record and
1565: not a clone. Therefore, any updates made to the returned value with update the XML document of this object.
1566: To reflect such changes in the on-screen view of this object, call
1567: redrawRecord(strRecordId, jsx3.xml.CDF.UPDATE); on this object.
1568: * @param strRecordId the <code>jsxid</code> attribute of the data record to return.
1569: * @return the record node or <code>null</code> if none exists with a <code>jsxid</code>
1570: attribute equal to <code>strRecordId</code>.
1571: */
1572: @SuppressWarnings("unchecked")
1573: public jsx3.xml.Node getRecordNode(String strRecordId) {
1574: String extension = "getRecordNode(\"" + strRecordId + "\").";
1575: try {
1576: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1577: .getConstructor(Context.class, String.class,
1578: ScriptProxy.class);
1579: return ctor.newInstance(this , extension, getScriptProxy());
1580: } catch (Exception ex) {
1581: throw new IllegalArgumentException("Unsupported type: "
1582: + jsx3.xml.Node.class.getName());
1583: }
1584: }
1585:
1586: /**
1587: * Inserts a new record into the XML data source of this object. If no XML data source exists
1588: yet for this object, an empty one is created before adding the new record.
1589: If a record already exists with an id equal to the jsxid property of objRecord,
1590: the operation is treated as an update, meaning the existing record is completely removed and a new record with
1591: the given jsxid is inserted.
1592: * @param objRecord a JavaScript object containing property/value pairs that define the
1593: attributes of the XML entity to create. Note that most classes that implement this interface require that all
1594: records have an attribute named <code>jsxid</code> that is unique across all records in the XML document.
1595: All property values will be treated as strings. Additionally, the following 3 characters are escaped:
1596: <code>" > <</code>.
1597: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1598: is provided and a record exists with a matching <code>jsxid</code> attribute, the new record will be added as a child of
1599: this record. Otherwise, the new record will be added to the root <code>data</code> element. However, if a
1600: record already exists with a <code>jsxid</code> attribute equal to the <code>jsxid</code> property of
1601: <code>objRecord</code>, this parameter will be ignored. In this case <code>adoptRecord()</code> must be called
1602: to change the parent of the record.
1603: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1604: immediately updated to reflect the additional record.
1605: * @return the newly created or updated entity.
1606: */
1607: @SuppressWarnings("unchecked")
1608: public jsx3.xml.Node insertRecord(jsx3.lang.Object objRecord,
1609: String strParentRecordId, boolean bRedraw) {
1610: String extension = "insertRecord(\"" + objRecord + "\", \""
1611: + strParentRecordId + "\", \"" + bRedraw + "\").";
1612: try {
1613: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1614: .getConstructor(Context.class, String.class,
1615: ScriptProxy.class);
1616: return ctor.newInstance(this , extension, getScriptProxy());
1617: } catch (Exception ex) {
1618: throw new IllegalArgumentException("Unsupported type: "
1619: + jsx3.xml.Node.class.getName());
1620: }
1621: }
1622:
1623: /**
1624: * Creates a new CDF record and inserts it into the CDF data source of this object, before the record identified by strSiblingRecordId.
1625:
1626: This method fails quietly if any of the following conditions apply:
1627:
1628: there is no existing record with a jsxid equal to strSiblingRecordId
1629:
1630: there is an existing record with jsxid equal to objRecord.jsxid
1631: * @param objRecord a JavaScript object containing property/value pairs that define the
1632: attributes of the XML entity to create. Note that most classes that implement this interface require that all
1633: records have an attribute named <code>jsxid</code> that is unique across all records in the XML document.
1634: All property values will be treated as strings. Additionally, the following 3 characters are escaped:
1635: <code>" > <</code>.
1636: * @param strSiblingRecordId the unique <code>jsxid</code> of an existing record before which the new record will be inserted.
1637: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1638: immediately updated to reflect the additional record.
1639: * @return the newly created entity.
1640: */
1641: @SuppressWarnings("unchecked")
1642: public jsx3.xml.Node insertRecordBefore(jsx3.lang.Object objRecord,
1643: String strSiblingRecordId, boolean bRedraw) {
1644: String extension = "insertRecordBefore(\"" + objRecord
1645: + "\", \"" + strSiblingRecordId + "\", \"" + bRedraw
1646: + "\").";
1647: try {
1648: java.lang.reflect.Constructor<jsx3.xml.Node> ctor = jsx3.xml.Node.class
1649: .getConstructor(Context.class, String.class,
1650: ScriptProxy.class);
1651: return ctor.newInstance(this , extension, getScriptProxy());
1652: } catch (Exception ex) {
1653: throw new IllegalArgumentException("Unsupported type: "
1654: + jsx3.xml.Node.class.getName());
1655: }
1656: }
1657:
1658: /**
1659: * Inserts a new record into the XML data source of this object. This method is the same as
1660: insertRecord() except that its first parameter is of type jsx3.xml.Entity rather than
1661: Object.
1662: * @param objRecordNode an XML element of name <code>record</code>. Note that most classes that
1663: implement this interface require that all records have an attribute named <code>jsxid</code> that is unique
1664: across all records in the XML document.
1665: * @param strParentRecordId the unique <code>jsxid</code> of an existing record. If this optional parameter
1666: is provided and a record exists with a matching <code>jsxid</code> attribute, the new record will be added as a child of
1667: this record. Otherwise, the new record will be added to the root <code>data</code> element.
1668: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1669: immediately updated to reflect the additional record.
1670: */
1671: public void insertRecordNode(jsx3.xml.Node objRecordNode,
1672: String strParentRecordId, boolean bRedraw) {
1673: ScriptBuffer script = new ScriptBuffer();
1674: script.appendCall(getContextPath() + "insertRecordNode",
1675: objRecordNode, strParentRecordId, bRedraw);
1676: getScriptProxy().addScript(script);
1677: }
1678:
1679: /**
1680: * Inserts a new property into an existing record with jsxid equal to strRecordId.
1681: If the property already exists, the existing property value will be updated. If no such record exists
1682: in the XML document, this method fails quietly.
1683: * @param strRecordId the <code>jsxid</code> attribute of the data record to modify.
1684: * @param strPropName the name of the property to insert into the record.
1685: * @param strPropValue the value of the property to insert.
1686: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1687: immediately updated to reflect the inserted property.
1688: * @return this object.
1689: */
1690: @SuppressWarnings("unchecked")
1691: public jsx3.xml.CdfDocument insertRecordProperty(
1692: String strRecordId, String strPropName,
1693: String strPropValue, boolean bRedraw) {
1694: String extension = "insertRecordProperty(\"" + strRecordId
1695: + "\", \"" + strPropName + "\", \"" + strPropValue
1696: + "\", \"" + bRedraw + "\").";
1697: try {
1698: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
1699: .getConstructor(Context.class, String.class,
1700: ScriptProxy.class);
1701: return ctor.newInstance(this , extension, getScriptProxy());
1702: } catch (Exception ex) {
1703: throw new IllegalArgumentException("Unsupported type: "
1704: + jsx3.xml.CdfDocument.class.getName());
1705: }
1706: }
1707:
1708: /**
1709: * Inserts a new property into an existing record with jsxid equal to strRecordId.
1710: If the property already exists, the existing property value will be updated. If no such record exists
1711: in the XML document, this method fails quietly.
1712: * @param strRecordId the <code>jsxid</code> attribute of the data record to modify.
1713: * @param strPropName the name of the property to insert into the record.
1714: * @param strPropValue the value of the property to insert.
1715: * @param bRedraw if <code>true</code> or <code>null</code>, the on-screen view of this object is
1716: immediately updated to reflect the inserted property.
1717: * @param returnType The expected return type
1718: * @return this object.
1719: */
1720: @SuppressWarnings("unchecked")
1721: public <T> T insertRecordProperty(String strRecordId,
1722: String strPropName, String strPropValue, boolean bRedraw,
1723: Class<T> returnType) {
1724: String extension = "insertRecordProperty(\"" + strRecordId
1725: + "\", \"" + strPropName + "\", \"" + strPropValue
1726: + "\", \"" + bRedraw + "\").";
1727: try {
1728: java.lang.reflect.Constructor<T> ctor = returnType
1729: .getConstructor(Context.class, String.class,
1730: ScriptProxy.class);
1731: return ctor.newInstance(this , extension, getScriptProxy());
1732: } catch (Exception ex) {
1733: throw new IllegalArgumentException(
1734: "Unsupported return type: " + returnType.getName());
1735: }
1736: }
1737:
1738: /**
1739: * Binds the given key sequence to a callback function. Any object that has a key binding (specified with
1740: setKeyBinding()) will call this method when painted to register the key sequence with an appropriate
1741: ancestor of this form control. Any key down event that bubbles up to the ancestor without being intercepted
1742: and matches the given key sequence will invoke the given callback function.
1743:
1744: As of 3.2: The hot key will be registered with the first ancestor found that is either a
1745: jsx3.gui.Window, a jsx3.gui.Dialog, or the root block of a jsx3.app.Server.
1746: * @param fctCallback JavaScript function to execute when the given sequence is keyed by the user.
1747: * @param strKeys a plus-delimited ('+') key sequence such as <code>ctrl+s</code> or
1748: <code>ctrl+shift+alt+h</code> or <code>shift+a</code>, etc. Any combination of shift, ctrl, and alt are
1749: supported, including none. Also supported as the final token are <code>enter</code>, <code>esc</code>,
1750: <code>tab</code>, <code>del</code>, and <code>space</code>. To specify the final token as a key code, the
1751: last token can be the key code contained in brackets, <code>[13]</code>.
1752: * @return the registered hot key.
1753: */
1754: @SuppressWarnings("unchecked")
1755: public jsx3.gui.HotKey doKeyBinding(
1756: org.directwebremoting.proxy.CodeBlock fctCallback,
1757: String strKeys) {
1758: String extension = "doKeyBinding(\"" + fctCallback + "\", \""
1759: + strKeys + "\").";
1760: try {
1761: java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
1762: .getConstructor(Context.class, String.class,
1763: ScriptProxy.class);
1764: return ctor.newInstance(this , extension, getScriptProxy());
1765: } catch (Exception ex) {
1766: throw new IllegalArgumentException("Unsupported type: "
1767: + jsx3.gui.HotKey.class.getName());
1768: }
1769: }
1770:
1771: /**
1772: * Resets the validation state of this control.
1773: * @return this object.
1774: */
1775: @SuppressWarnings("unchecked")
1776: public jsx3.gui.Form doReset() {
1777: String extension = "doReset().";
1778: try {
1779: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
1780: .getConstructor(Context.class, String.class,
1781: ScriptProxy.class);
1782: return ctor.newInstance(this , extension, getScriptProxy());
1783: } catch (Exception ex) {
1784: throw new IllegalArgumentException("Unsupported type: "
1785: + jsx3.gui.Form.class.getName());
1786: }
1787: }
1788:
1789: /**
1790: * Resets the validation state of this control.
1791: * @param returnType The expected return type
1792: * @return this object.
1793: */
1794: @SuppressWarnings("unchecked")
1795: public <T> T doReset(Class<T> returnType) {
1796: String extension = "doReset().";
1797: try {
1798: java.lang.reflect.Constructor<T> ctor = returnType
1799: .getConstructor(Context.class, String.class,
1800: ScriptProxy.class);
1801: return ctor.newInstance(this , extension, getScriptProxy());
1802: } catch (Exception ex) {
1803: throw new IllegalArgumentException(
1804: "Unsupported return type: " + returnType.getName());
1805: }
1806: }
1807:
1808: /**
1809: * Returns the background color of this control when it is disabled.
1810: * @param callback valid CSS property value, (i.e., red, #ff0000)
1811: */
1812: @SuppressWarnings("unchecked")
1813: public void getDisabledBackgroundColor(
1814: org.directwebremoting.proxy.Callback<String> callback) {
1815: ScriptBuffer script = new ScriptBuffer();
1816: String callbackPrefix = "";
1817:
1818: if (callback != null) {
1819: callbackPrefix = "var reply = ";
1820: }
1821:
1822: script.appendCall(callbackPrefix + getContextPath()
1823: + "getDisabledBackgroundColor");
1824:
1825: if (callback != null) {
1826: String key = org.directwebremoting.extend.CallbackHelper
1827: .saveCallback(callback, String.class);
1828: script
1829: .appendCall("__System.activateCallback", key,
1830: "reply");
1831: }
1832:
1833: getScriptProxy().addScript(script);
1834: }
1835:
1836: /**
1837: * Returns the font color to use when this control is disabled.
1838: * @param callback valid CSS property value, (i.e., red, #ff0000)
1839: */
1840: @SuppressWarnings("unchecked")
1841: public void getDisabledColor(
1842: org.directwebremoting.proxy.Callback<String> callback) {
1843: ScriptBuffer script = new ScriptBuffer();
1844: String callbackPrefix = "";
1845:
1846: if (callback != null) {
1847: callbackPrefix = "var reply = ";
1848: }
1849:
1850: script.appendCall(callbackPrefix + getContextPath()
1851: + "getDisabledColor");
1852:
1853: if (callback != null) {
1854: String key = org.directwebremoting.extend.CallbackHelper
1855: .saveCallback(callback, String.class);
1856: script
1857: .appendCall("__System.activateCallback", key,
1858: "reply");
1859: }
1860:
1861: getScriptProxy().addScript(script);
1862: }
1863:
1864: /**
1865: * Returns the state for the form field control. If no enabled state is set, this method returns
1866: STATEENABLED.
1867: * @param callback <code>STATEDISABLED</code> or <code>STATEENABLED</code>.
1868: */
1869: @SuppressWarnings("unchecked")
1870: public void getEnabled(
1871: org.directwebremoting.proxy.Callback<Integer> callback) {
1872: ScriptBuffer script = new ScriptBuffer();
1873: String callbackPrefix = "";
1874:
1875: if (callback != null) {
1876: callbackPrefix = "var reply = ";
1877: }
1878:
1879: script.appendCall(callbackPrefix + getContextPath()
1880: + "getEnabled");
1881:
1882: if (callback != null) {
1883: String key = org.directwebremoting.extend.CallbackHelper
1884: .saveCallback(callback, Integer.class);
1885: script
1886: .appendCall("__System.activateCallback", key,
1887: "reply");
1888: }
1889:
1890: getScriptProxy().addScript(script);
1891: }
1892:
1893: /**
1894: * Returns the key binding that when keyed will fire the execute event for this control.
1895: * @param callback plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
1896: */
1897: @SuppressWarnings("unchecked")
1898: public void getKeyBinding(
1899: org.directwebremoting.proxy.Callback<String> callback) {
1900: ScriptBuffer script = new ScriptBuffer();
1901: String callbackPrefix = "";
1902:
1903: if (callback != null) {
1904: callbackPrefix = "var reply = ";
1905: }
1906:
1907: script.appendCall(callbackPrefix + getContextPath()
1908: + "getKeyBinding");
1909:
1910: if (callback != null) {
1911: String key = org.directwebremoting.extend.CallbackHelper
1912: .saveCallback(callback, String.class);
1913: script
1914: .appendCall("__System.activateCallback", key,
1915: "reply");
1916: }
1917:
1918: getScriptProxy().addScript(script);
1919: }
1920:
1921: /**
1922: * Returns whether or not this control is required. If the required property has never been set, this method returns
1923: OPTIONAL.
1924: * @param callback <code>REQUIRED</code> or <code>OPTIONAL</code>.
1925: */
1926: @SuppressWarnings("unchecked")
1927: public void getRequired(
1928: org.directwebremoting.proxy.Callback<Integer> callback) {
1929: ScriptBuffer script = new ScriptBuffer();
1930: String callbackPrefix = "";
1931:
1932: if (callback != null) {
1933: callbackPrefix = "var reply = ";
1934: }
1935:
1936: script.appendCall(callbackPrefix + getContextPath()
1937: + "getRequired");
1938:
1939: if (callback != null) {
1940: String key = org.directwebremoting.extend.CallbackHelper
1941: .saveCallback(callback, Integer.class);
1942: script
1943: .appendCall("__System.activateCallback", key,
1944: "reply");
1945: }
1946:
1947: getScriptProxy().addScript(script);
1948: }
1949:
1950: /**
1951: * Returns the validation state of this control. If the validationState property has never been set, this method returns
1952: STATEVALID.
1953: * @param callback <code>STATEINVALID</code> or <code>STATEVALID</code>.
1954: */
1955: @SuppressWarnings("unchecked")
1956: public void getValidationState(
1957: org.directwebremoting.proxy.Callback<Integer> callback) {
1958: ScriptBuffer script = new ScriptBuffer();
1959: String callbackPrefix = "";
1960:
1961: if (callback != null) {
1962: callbackPrefix = "var reply = ";
1963: }
1964:
1965: script.appendCall(callbackPrefix + getContextPath()
1966: + "getValidationState");
1967:
1968: if (callback != null) {
1969: String key = org.directwebremoting.extend.CallbackHelper
1970: .saveCallback(callback, Integer.class);
1971: script
1972: .appendCall("__System.activateCallback", key,
1973: "reply");
1974: }
1975:
1976: getScriptProxy().addScript(script);
1977: }
1978:
1979: /**
1980: * Sets the background color of this form control when it is disabled.
1981: * @param strColor valid CSS property value, (i.e., red, #ff0000)
1982: * @return this object.
1983: */
1984: @SuppressWarnings("unchecked")
1985: public jsx3.gui.Form setDisabledBackgroundColor(String strColor) {
1986: String extension = "setDisabledBackgroundColor(\"" + strColor
1987: + "\").";
1988: try {
1989: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
1990: .getConstructor(Context.class, String.class,
1991: ScriptProxy.class);
1992: return ctor.newInstance(this , extension, getScriptProxy());
1993: } catch (Exception ex) {
1994: throw new IllegalArgumentException("Unsupported type: "
1995: + jsx3.gui.Form.class.getName());
1996: }
1997: }
1998:
1999: /**
2000: * Sets the background color of this form control when it is disabled.
2001: * @param strColor valid CSS property value, (i.e., red, #ff0000)
2002: * @param returnType The expected return type
2003: * @return this object.
2004: */
2005: @SuppressWarnings("unchecked")
2006: public <T> T setDisabledBackgroundColor(String strColor,
2007: Class<T> returnType) {
2008: String extension = "setDisabledBackgroundColor(\"" + strColor
2009: + "\").";
2010: try {
2011: java.lang.reflect.Constructor<T> ctor = returnType
2012: .getConstructor(Context.class, String.class,
2013: ScriptProxy.class);
2014: return ctor.newInstance(this , extension, getScriptProxy());
2015: } catch (Exception ex) {
2016: throw new IllegalArgumentException(
2017: "Unsupported return type: " + returnType.getName());
2018: }
2019: }
2020:
2021: /**
2022: * Sets the font color to use when this control is disabled.
2023: * @param strColor valid CSS property value, (i.e., red, #ff0000)
2024: * @return this object.
2025: */
2026: @SuppressWarnings("unchecked")
2027: public jsx3.gui.Form setDisabledColor(String strColor) {
2028: String extension = "setDisabledColor(\"" + strColor + "\").";
2029: try {
2030: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
2031: .getConstructor(Context.class, String.class,
2032: ScriptProxy.class);
2033: return ctor.newInstance(this , extension, getScriptProxy());
2034: } catch (Exception ex) {
2035: throw new IllegalArgumentException("Unsupported type: "
2036: + jsx3.gui.Form.class.getName());
2037: }
2038: }
2039:
2040: /**
2041: * Sets the font color to use when this control is disabled.
2042: * @param strColor valid CSS property value, (i.e., red, #ff0000)
2043: * @param returnType The expected return type
2044: * @return this object.
2045: */
2046: @SuppressWarnings("unchecked")
2047: public <T> T setDisabledColor(String strColor, Class<T> returnType) {
2048: String extension = "setDisabledColor(\"" + strColor + "\").";
2049: try {
2050: java.lang.reflect.Constructor<T> ctor = returnType
2051: .getConstructor(Context.class, String.class,
2052: ScriptProxy.class);
2053: return ctor.newInstance(this , extension, getScriptProxy());
2054: } catch (Exception ex) {
2055: throw new IllegalArgumentException(
2056: "Unsupported return type: " + returnType.getName());
2057: }
2058: }
2059:
2060: /**
2061: * Sets whether this control is enabled. Disabled controls do not respond to user interaction.
2062: * @param intEnabled <code>STATEDISABLED</code> or <code>STATEENABLED</code>. <code>null</code> is
2063: equivalent to <code>STATEENABLED</code>.
2064: * @param bRepaint if <code>true</code> this control is immediately repainted to reflect the new setting.
2065: */
2066: public void setEnabled(int intEnabled, boolean bRepaint) {
2067: ScriptBuffer script = new ScriptBuffer();
2068: script.appendCall(getContextPath() + "setEnabled", intEnabled,
2069: bRepaint);
2070: getScriptProxy().addScript(script);
2071: }
2072:
2073: /**
2074: * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
2075: event for this control.
2076: * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
2077: * @return this object.
2078: */
2079: @SuppressWarnings("unchecked")
2080: public jsx3.gui.Form setKeyBinding(String strSequence) {
2081: String extension = "setKeyBinding(\"" + strSequence + "\").";
2082: try {
2083: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
2084: .getConstructor(Context.class, String.class,
2085: ScriptProxy.class);
2086: return ctor.newInstance(this , extension, getScriptProxy());
2087: } catch (Exception ex) {
2088: throw new IllegalArgumentException("Unsupported type: "
2089: + jsx3.gui.Form.class.getName());
2090: }
2091: }
2092:
2093: /**
2094: * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
2095: event for this control.
2096: * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
2097: * @param returnType The expected return type
2098: * @return this object.
2099: */
2100: @SuppressWarnings("unchecked")
2101: public <T> T setKeyBinding(String strSequence, Class<T> returnType) {
2102: String extension = "setKeyBinding(\"" + strSequence + "\").";
2103: try {
2104: java.lang.reflect.Constructor<T> ctor = returnType
2105: .getConstructor(Context.class, String.class,
2106: ScriptProxy.class);
2107: return ctor.newInstance(this , extension, getScriptProxy());
2108: } catch (Exception ex) {
2109: throw new IllegalArgumentException(
2110: "Unsupported return type: " + returnType.getName());
2111: }
2112: }
2113:
2114: /**
2115: * Sets whether or not this control is required.
2116: * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
2117: * @return this object.
2118: */
2119: @SuppressWarnings("unchecked")
2120: public jsx3.gui.Form setRequired(int required) {
2121: String extension = "setRequired(\"" + required + "\").";
2122: try {
2123: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
2124: .getConstructor(Context.class, String.class,
2125: ScriptProxy.class);
2126: return ctor.newInstance(this , extension, getScriptProxy());
2127: } catch (Exception ex) {
2128: throw new IllegalArgumentException("Unsupported type: "
2129: + jsx3.gui.Form.class.getName());
2130: }
2131: }
2132:
2133: /**
2134: * Sets whether or not this control is required.
2135: * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
2136: * @param returnType The expected return type
2137: * @return this object.
2138: */
2139: @SuppressWarnings("unchecked")
2140: public <T> T setRequired(int required, Class<T> returnType) {
2141: String extension = "setRequired(\"" + required + "\").";
2142: try {
2143: java.lang.reflect.Constructor<T> ctor = returnType
2144: .getConstructor(Context.class, String.class,
2145: ScriptProxy.class);
2146: return ctor.newInstance(this , extension, getScriptProxy());
2147: } catch (Exception ex) {
2148: throw new IllegalArgumentException(
2149: "Unsupported return type: " + returnType.getName());
2150: }
2151: }
2152:
2153: /**
2154: * Sets the validation state of this control. The validation state of a control is not serialized.
2155: * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
2156: * @return this object.
2157: */
2158: @SuppressWarnings("unchecked")
2159: public jsx3.gui.Form setValidationState(int intState) {
2160: String extension = "setValidationState(\"" + intState + "\").";
2161: try {
2162: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
2163: .getConstructor(Context.class, String.class,
2164: ScriptProxy.class);
2165: return ctor.newInstance(this , extension, getScriptProxy());
2166: } catch (Exception ex) {
2167: throw new IllegalArgumentException("Unsupported type: "
2168: + jsx3.gui.Form.class.getName());
2169: }
2170: }
2171:
2172: /**
2173: * Sets the validation state of this control. The validation state of a control is not serialized.
2174: * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
2175: * @param returnType The expected return type
2176: * @return this object.
2177: */
2178: @SuppressWarnings("unchecked")
2179: public <T> T setValidationState(int intState, Class<T> returnType) {
2180: String extension = "setValidationState(\"" + intState + "\").";
2181: try {
2182: java.lang.reflect.Constructor<T> ctor = returnType
2183: .getConstructor(Context.class, String.class,
2184: ScriptProxy.class);
2185: return ctor.newInstance(this , extension, getScriptProxy());
2186: } catch (Exception ex) {
2187: throw new IllegalArgumentException(
2188: "Unsupported return type: " + returnType.getName());
2189: }
2190: }
2191:
2192: /**
2193: * Sets the value of this control.
2194: * @param vntValue string/int value for the component
2195: * @return this object.
2196: */
2197: @SuppressWarnings("unchecked")
2198: public jsx3.gui.Form setValue(String vntValue) {
2199: String extension = "setValue(\"" + vntValue + "\").";
2200: try {
2201: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
2202: .getConstructor(Context.class, String.class,
2203: ScriptProxy.class);
2204: return ctor.newInstance(this , extension, getScriptProxy());
2205: } catch (Exception ex) {
2206: throw new IllegalArgumentException("Unsupported type: "
2207: + jsx3.gui.Form.class.getName());
2208: }
2209: }
2210:
2211: /**
2212: * Sets the value of this control.
2213: * @param vntValue string/int value for the component
2214: * @param returnType The expected return type
2215: * @return this object.
2216: */
2217: @SuppressWarnings("unchecked")
2218: public <T> T setValue(String vntValue, Class<T> returnType) {
2219: String extension = "setValue(\"" + vntValue + "\").";
2220: try {
2221: java.lang.reflect.Constructor<T> ctor = returnType
2222: .getConstructor(Context.class, String.class,
2223: ScriptProxy.class);
2224: return ctor.newInstance(this , extension, getScriptProxy());
2225: } catch (Exception ex) {
2226: throw new IllegalArgumentException(
2227: "Unsupported return type: " + returnType.getName());
2228: }
2229: }
2230:
2231: /**
2232: * Sets the value of this control.
2233: * @param vntValue string/int value for the component
2234: * @return this object.
2235: */
2236: @SuppressWarnings("unchecked")
2237: public jsx3.gui.Form setValue(Integer vntValue) {
2238: String extension = "setValue(\"" + vntValue + "\").";
2239: try {
2240: java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
2241: .getConstructor(Context.class, String.class,
2242: ScriptProxy.class);
2243: return ctor.newInstance(this , extension, getScriptProxy());
2244: } catch (Exception ex) {
2245: throw new IllegalArgumentException("Unsupported type: "
2246: + jsx3.gui.Form.class.getName());
2247: }
2248: }
2249:
2250: /**
2251: * Sets the value of this control.
2252: * @param vntValue string/int value for the component
2253: * @param returnType The expected return type
2254: * @return this object.
2255: */
2256: @SuppressWarnings("unchecked")
2257: public <T> T setValue(Integer vntValue, Class<T> returnType) {
2258: String extension = "setValue(\"" + vntValue + "\").";
2259: try {
2260: java.lang.reflect.Constructor<T> ctor = returnType
2261: .getConstructor(Context.class, String.class,
2262: ScriptProxy.class);
2263: return ctor.newInstance(this , extension, getScriptProxy());
2264: } catch (Exception ex) {
2265: throw new IllegalArgumentException(
2266: "Unsupported return type: " + returnType.getName());
2267: }
2268: }
2269:
2270: }
|