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.app;
0017:
0018: import org.directwebremoting.ScriptBuffer;
0019: import org.directwebremoting.proxy.ScriptProxy;
0020: import org.directwebremoting.proxy.io.Context;
0021:
0022: /**
0023: * The abstract base class that defines the JSX DOM. Instances of this class exist as nodes in a tree, each with
0024: a single parent and multiple children. This class includes all the methods for querying and manipulating the DOM's
0025: tree structure, such as getChild(), adoptChild(), getParent(), etc.
0026: * @author Joe Walker [joe at getahead dot org]
0027: * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
0028: */
0029: public class Model extends jsx3.lang.Object {
0030: /**
0031: * All reverse ajax proxies need context to work from
0032: * @param scriptProxy The place we are writing scripts to
0033: * @param context The script that got us to where we are now
0034: */
0035: public Model(Context context, String extension,
0036: ScriptProxy scriptProxy) {
0037: super (context, extension, scriptProxy);
0038: }
0039:
0040: /**
0041: * The instance initializer.
0042: * @param strName a unique name distinguishing this object from all other JSX GUI objects in the JSX application
0043: * @param strInstanceOf
0044: */
0045: public Model(String strName, String strInstanceOf) {
0046: super ((Context) null, (String) null, (ScriptProxy) null);
0047: ScriptBuffer script = new ScriptBuffer();
0048: script.appendCall("new Model", strName, strInstanceOf);
0049: setInitScript(script);
0050: }
0051:
0052: /**
0053: * Persistance value fora child that is temporarily part of the DOM tree and will not be persisted.
0054: */
0055: public static final int PERSISTNONE = 0;
0056:
0057: /**
0058: * Normal persistance value for a child that will be persisted.
0059: */
0060: public static final int PERSISTEMBED = 1;
0061:
0062: /**
0063: * Persistance value for a child that exists in an external serialization file and is referenced by URI.
0064: */
0065: public static final int PERSISTREF = 2;
0066:
0067: /**
0068: * Persistance value for a child that exists in an external serialization file and is referenced by URI. The
0069: loading of a child with this persistence value will happen asynchronously after the file that references it is
0070: loaded.
0071: */
0072: public static final int PERSISTREFASYNC = 3;
0073:
0074: /**
0075: * The normal load type for a DOM branch. The DOM branch deserializes and paints with its parent.
0076: */
0077: public static final int LT_NORMAL = 0;
0078:
0079: /**
0080: * Load type indicating that the DOM branch will paint after its parent paints and the call stack resets.
0081: */
0082: public static final int LT_SLEEP_PAINT = 1;
0083:
0084: /**
0085: * Load type indicating that the DOM branch will deserialize and paint after its parent deserializes and the
0086: call stack resets.
0087: */
0088: public static final int LT_SLEEP_DESER = 2;
0089:
0090: /**
0091: * Load type indicating that the DOM branch will deserialize after its parent deserializes and the call stack
0092: resets and will paint after its parent paints and the call stack resets.
0093: */
0094: public static final int LT_SLEEP_PD = 3;
0095:
0096: /**
0097: * Load type indicating that the DOM branch will paint as needed when it becomes visible. It is left to
0098: subclasses of Model to implement this functionality.
0099: */
0100: public static final int LT_SHOW_PAINT = 4;
0101:
0102: /**
0103: * Load type indicating that the DOM branch will deserialize and paint as needed when it becomes visible.
0104: It is left to subclasses of Model to implement this functionality.
0105: */
0106: public static final int LT_SHOW_DESER = 5;
0107:
0108: /**
0109: * Minimum supported version for serialization files
0110: */
0111: public static final String CURRENT_VERSION = "urn:tibco.com/v3.0";
0112:
0113: /**
0114: * Minimum supported version CIF formatted serialization files
0115: */
0116: public static final String CIF_VERSION = "http://xsd.tns.tibco.com/gi/cif/2006";
0117:
0118: /**
0119: * The number of milliseconds before asynchronous component loads time out.
0120: */
0121: public static final int ASYNC_LOAD_TIMEOUT = 60000;
0122:
0123: /**
0124: * Returns the child DOM node of this node at the given index or with the given name. If a name is supplied, the
0125: children are searched in order and the first matching child is returned.
0126: * @param vntIndexOrName either the integer index or the string name of the child.
0127: * @return the child at the given index or with the given name, or <code>null</code> if no such
0128: child exists.
0129: */
0130: @SuppressWarnings("unchecked")
0131: public jsx3.app.Model getChild(int vntIndexOrName) {
0132: String extension = "getChild(\"" + vntIndexOrName + "\").";
0133: try {
0134: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0135: .getConstructor(Context.class, String.class,
0136: ScriptProxy.class);
0137: return ctor.newInstance(this , extension, getScriptProxy());
0138: } catch (Exception ex) {
0139: throw new IllegalArgumentException("Unsupported type: "
0140: + jsx3.app.Model.class.getName());
0141: }
0142: }
0143:
0144: /**
0145: * Returns the child DOM node of this node at the given index or with the given name. If a name is supplied, the
0146: children are searched in order and the first matching child is returned.
0147: * @param vntIndexOrName either the integer index or the string name of the child.
0148: * @param returnType The expected return type
0149: * @return the child at the given index or with the given name, or <code>null</code> if no such
0150: child exists.
0151: */
0152: @SuppressWarnings("unchecked")
0153: public <T> T getChild(int vntIndexOrName, Class<T> returnType) {
0154: String extension = "getChild(\"" + vntIndexOrName + "\").";
0155: try {
0156: java.lang.reflect.Constructor<T> ctor = returnType
0157: .getConstructor(Context.class, String.class,
0158: ScriptProxy.class);
0159: return ctor.newInstance(this , extension, getScriptProxy());
0160: } catch (Exception ex) {
0161: throw new IllegalArgumentException(
0162: "Unsupported return type: " + returnType.getName());
0163: }
0164: }
0165:
0166: /**
0167: * Returns the child DOM node of this node at the given index or with the given name. If a name is supplied, the
0168: children are searched in order and the first matching child is returned.
0169: * @param vntIndexOrName either the integer index or the string name of the child.
0170: * @return the child at the given index or with the given name, or <code>null</code> if no such
0171: child exists.
0172: */
0173: @SuppressWarnings("unchecked")
0174: public jsx3.app.Model getChild(String vntIndexOrName) {
0175: String extension = "getChild(\"" + vntIndexOrName + "\").";
0176: try {
0177: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0178: .getConstructor(Context.class, String.class,
0179: ScriptProxy.class);
0180: return ctor.newInstance(this , extension, getScriptProxy());
0181: } catch (Exception ex) {
0182: throw new IllegalArgumentException("Unsupported type: "
0183: + jsx3.app.Model.class.getName());
0184: }
0185: }
0186:
0187: /**
0188: * Returns the child DOM node of this node at the given index or with the given name. If a name is supplied, the
0189: children are searched in order and the first matching child is returned.
0190: * @param vntIndexOrName either the integer index or the string name of the child.
0191: * @param returnType The expected return type
0192: * @return the child at the given index or with the given name, or <code>null</code> if no such
0193: child exists.
0194: */
0195: @SuppressWarnings("unchecked")
0196: public <T> T getChild(String vntIndexOrName, Class<T> returnType) {
0197: String extension = "getChild(\"" + vntIndexOrName + "\").";
0198: try {
0199: java.lang.reflect.Constructor<T> ctor = returnType
0200: .getConstructor(Context.class, String.class,
0201: ScriptProxy.class);
0202: return ctor.newInstance(this , extension, getScriptProxy());
0203: } catch (Exception ex) {
0204: throw new IllegalArgumentException(
0205: "Unsupported return type: " + returnType.getName());
0206: }
0207: }
0208:
0209: /**
0210: * Returns the first child.
0211: */
0212: @SuppressWarnings("unchecked")
0213: public jsx3.app.Model getFirstChild() {
0214: String extension = "getFirstChild().";
0215: try {
0216: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0217: .getConstructor(Context.class, String.class,
0218: ScriptProxy.class);
0219: return ctor.newInstance(this , extension, getScriptProxy());
0220: } catch (Exception ex) {
0221: throw new IllegalArgumentException("Unsupported type: "
0222: + jsx3.app.Model.class.getName());
0223: }
0224: }
0225:
0226: /**
0227: * Returns the first child.
0228: * @param returnType The expected return type
0229: */
0230: @SuppressWarnings("unchecked")
0231: public <T> T getFirstChild(Class<T> returnType) {
0232: String extension = "getFirstChild().";
0233: try {
0234: java.lang.reflect.Constructor<T> ctor = returnType
0235: .getConstructor(Context.class, String.class,
0236: ScriptProxy.class);
0237: return ctor.newInstance(this , extension, getScriptProxy());
0238: } catch (Exception ex) {
0239: throw new IllegalArgumentException(
0240: "Unsupported return type: " + returnType.getName());
0241: }
0242: }
0243:
0244: /**
0245: * Returns the last child.
0246: */
0247: @SuppressWarnings("unchecked")
0248: public jsx3.app.Model getLastChild() {
0249: String extension = "getLastChild().";
0250: try {
0251: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0252: .getConstructor(Context.class, String.class,
0253: ScriptProxy.class);
0254: return ctor.newInstance(this , extension, getScriptProxy());
0255: } catch (Exception ex) {
0256: throw new IllegalArgumentException("Unsupported type: "
0257: + jsx3.app.Model.class.getName());
0258: }
0259: }
0260:
0261: /**
0262: * Returns the last child.
0263: * @param returnType The expected return type
0264: */
0265: @SuppressWarnings("unchecked")
0266: public <T> T getLastChild(Class<T> returnType) {
0267: String extension = "getLastChild().";
0268: try {
0269: java.lang.reflect.Constructor<T> ctor = returnType
0270: .getConstructor(Context.class, String.class,
0271: ScriptProxy.class);
0272: return ctor.newInstance(this , extension, getScriptProxy());
0273: } catch (Exception ex) {
0274: throw new IllegalArgumentException(
0275: "Unsupported return type: " + returnType.getName());
0276: }
0277: }
0278:
0279: /**
0280: * Returns the next sibling.
0281: */
0282: @SuppressWarnings("unchecked")
0283: public jsx3.app.Model getNextSibling() {
0284: String extension = "getNextSibling().";
0285: try {
0286: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0287: .getConstructor(Context.class, String.class,
0288: ScriptProxy.class);
0289: return ctor.newInstance(this , extension, getScriptProxy());
0290: } catch (Exception ex) {
0291: throw new IllegalArgumentException("Unsupported type: "
0292: + jsx3.app.Model.class.getName());
0293: }
0294: }
0295:
0296: /**
0297: * Returns the next sibling.
0298: * @param returnType The expected return type
0299: */
0300: @SuppressWarnings("unchecked")
0301: public <T> T getNextSibling(Class<T> returnType) {
0302: String extension = "getNextSibling().";
0303: try {
0304: java.lang.reflect.Constructor<T> ctor = returnType
0305: .getConstructor(Context.class, String.class,
0306: ScriptProxy.class);
0307: return ctor.newInstance(this , extension, getScriptProxy());
0308: } catch (Exception ex) {
0309: throw new IllegalArgumentException(
0310: "Unsupported return type: " + returnType.getName());
0311: }
0312: }
0313:
0314: /**
0315: * Returns the previous sibling.
0316: */
0317: @SuppressWarnings("unchecked")
0318: public jsx3.app.Model getPreviousSibling() {
0319: String extension = "getPreviousSibling().";
0320: try {
0321: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0322: .getConstructor(Context.class, String.class,
0323: ScriptProxy.class);
0324: return ctor.newInstance(this , extension, getScriptProxy());
0325: } catch (Exception ex) {
0326: throw new IllegalArgumentException("Unsupported type: "
0327: + jsx3.app.Model.class.getName());
0328: }
0329: }
0330:
0331: /**
0332: * Returns the previous sibling.
0333: * @param returnType The expected return type
0334: */
0335: @SuppressWarnings("unchecked")
0336: public <T> T getPreviousSibling(Class<T> returnType) {
0337: String extension = "getPreviousSibling().";
0338: try {
0339: java.lang.reflect.Constructor<T> ctor = returnType
0340: .getConstructor(Context.class, String.class,
0341: ScriptProxy.class);
0342: return ctor.newInstance(this , extension, getScriptProxy());
0343: } catch (Exception ex) {
0344: throw new IllegalArgumentException(
0345: "Unsupported return type: " + returnType.getName());
0346: }
0347: }
0348:
0349: /**
0350: * Returns an array containing all the child DOM nodes of this object. The return value is the original array rather
0351: than a copy and should not be modified.
0352: */
0353: @SuppressWarnings("unchecked")
0354: public void getChildren(
0355: org.directwebremoting.proxy.Callback<Object[]> callback) {
0356: ScriptBuffer script = new ScriptBuffer();
0357: String callbackPrefix = "";
0358:
0359: if (callback != null) {
0360: callbackPrefix = "var reply = ";
0361: }
0362:
0363: script.appendCall(callbackPrefix + getContextPath()
0364: + "getChildren");
0365:
0366: if (callback != null) {
0367: String key = org.directwebremoting.extend.CallbackHelper
0368: .saveCallback(callback, Object[].class);
0369: script
0370: .appendCall("__System.activateCallback", key,
0371: "reply");
0372: }
0373:
0374: getScriptProxy().addScript(script);
0375: }
0376:
0377: /**
0378: * Returns the persistence bit for this model object.
0379: * @param callback one of <code>PERSISTNONE</code>, <code>PERSISTEMBED</code>, <code>PERSISTREF</code>,
0380: <code>PERSISTREFASYNC</code>.
0381: */
0382: @SuppressWarnings("unchecked")
0383: public void getPersistence(
0384: org.directwebremoting.proxy.Callback<Integer> callback) {
0385: ScriptBuffer script = new ScriptBuffer();
0386: String callbackPrefix = "";
0387:
0388: if (callback != null) {
0389: callbackPrefix = "var reply = ";
0390: }
0391:
0392: script.appendCall(callbackPrefix + getContextPath()
0393: + "getPersistence");
0394:
0395: if (callback != null) {
0396: String key = org.directwebremoting.extend.CallbackHelper
0397: .saveCallback(callback, Integer.class);
0398: script
0399: .appendCall("__System.activateCallback", key,
0400: "reply");
0401: }
0402:
0403: getScriptProxy().addScript(script);
0404: }
0405:
0406: /**
0407: * Sets the persistence bit for this model object.
0408: * @param intPersist one of <code>PERSISTNONE</code>, <code>PERSISTEMBED</code>, <code>PERSISTREF</code>,
0409: <code>PERSISTREFASYNC</code>.
0410: * @return this object
0411: */
0412: public jsx3.app.Model setPersistence(int intPersist) {
0413: ScriptBuffer script = new ScriptBuffer();
0414: script.appendCall(getContextPath() + "setPersistence",
0415: intPersist);
0416: getScriptProxy().addScript(script);
0417: return this ;
0418: }
0419:
0420: /**
0421: * Appends a child DOM node to this parent DOM node. If the child already has a parent, adoptChild()
0422: should be used instead to ensure that the child is removed from its current parent.
0423: * @param objChild the root node of a DOM fragment.
0424: * @param intPersist defines how the child will be persisted/serialized. The valid values are the four
0425: persistence values defined as static fields in this class.
0426: * @param strSourceURL the path to the serialization file where the child exists. This parameter is only
0427: relevant if the given <code>intPersist</code> is <code>PERSISTREF</code> or <code>PERSISTREFASYNC</code>.
0428: * @param strNS the namespace of the child to append. This parameter is normally not required but is useful
0429: when sharing DOM nodes between servers with different namespaces.
0430: * @return this object or <code>false</code> if the set was vetoed
0431: */
0432: public jsx3.app.Model setChild(jsx3.app.Model objChild,
0433: int intPersist, java.net.URI strSourceURL, String strNS) {
0434: ScriptBuffer script = new ScriptBuffer();
0435: script.appendCall(getContextPath() + "setChild", objChild,
0436: intPersist, strSourceURL, strNS);
0437: getScriptProxy().addScript(script);
0438: return this ;
0439: }
0440:
0441: /**
0442: * Appends a child DOM node to this parent DOM node. If the child already has a parent, adoptChild()
0443: should be used instead to ensure that the child is removed from its current parent.
0444: * @param objChild the root node of a DOM fragment.
0445: * @param intPersist defines how the child will be persisted/serialized. The valid values are the four
0446: persistence values defined as static fields in this class.
0447: * @param strSourceURL the path to the serialization file where the child exists. This parameter is only
0448: relevant if the given <code>intPersist</code> is <code>PERSISTREF</code> or <code>PERSISTREFASYNC</code>.
0449: * @param strNS the namespace of the child to append. This parameter is normally not required but is useful
0450: when sharing DOM nodes between servers with different namespaces.
0451: * @return this object or <code>false</code> if the set was vetoed
0452: */
0453: public jsx3.app.Model setChild(jsx3.app.Model objChild,
0454: int intPersist, String strSourceURL, String strNS) {
0455: ScriptBuffer script = new ScriptBuffer();
0456: script.appendCall(getContextPath() + "setChild", objChild,
0457: intPersist, strSourceURL, strNS);
0458: getScriptProxy().addScript(script);
0459: return this ;
0460: }
0461:
0462: /**
0463: * Hook that allows for a prospective parent DOM node to veto the adoption of a child.
0464: * @param objChild
0465: * @param callback true to allow the set, false to veto
0466: */
0467: @SuppressWarnings("unchecked")
0468: public void onSetChild(java.lang.Object objChild,
0469: org.directwebremoting.proxy.Callback<Boolean> callback) {
0470: ScriptBuffer script = new ScriptBuffer();
0471: String callbackPrefix = "";
0472:
0473: if (callback != null) {
0474: callbackPrefix = "var reply = ";
0475: }
0476:
0477: script.appendCall(callbackPrefix + getContextPath()
0478: + "onSetChild", objChild);
0479:
0480: if (callback != null) {
0481: String key = org.directwebremoting.extend.CallbackHelper
0482: .saveCallback(callback, Boolean.class);
0483: script
0484: .appendCall("__System.activateCallback", key,
0485: "reply");
0486: }
0487:
0488: getScriptProxy().addScript(script);
0489: }
0490:
0491: /**
0492: * Hook that allows for a prospective child DOM node to veto its adoption by a parent. This method is only called if
0493: the prospective parent has not already vetoed the adoption in the onSetChild() method.
0494: * @param objParent
0495: * @param callback true to allow the set, false to veto
0496: */
0497: @SuppressWarnings("unchecked")
0498: public void onSetParent(java.lang.Object objParent,
0499: org.directwebremoting.proxy.Callback<Boolean> callback) {
0500: ScriptBuffer script = new ScriptBuffer();
0501: String callbackPrefix = "";
0502:
0503: if (callback != null) {
0504: callbackPrefix = "var reply = ";
0505: }
0506:
0507: script.appendCall(callbackPrefix + getContextPath()
0508: + "onSetParent", objParent);
0509:
0510: if (callback != null) {
0511: String key = org.directwebremoting.extend.CallbackHelper
0512: .saveCallback(callback, Boolean.class);
0513: script
0514: .appendCall("__System.activateCallback", key,
0515: "reply");
0516: }
0517:
0518: getScriptProxy().addScript(script);
0519: }
0520:
0521: /**
0522: * Hook that notifies this model object that one of its children has been removed. This hook exists simply to allow
0523: this object to perform cleanup/re-render, and does not provide a veto mechanism. This method is called after
0524: the child has been removed from the model (this.getChildren() does not contain objChild)
0525: and after the child has been removed from the view (objChild.getRendered() is also null).
0526:
0527: This method is only called if the child is being removed from the DOM but this object (the parent) is not
0528: being removed. Therefore, this hook cannot be relied upon for garbage collection.
0529:
0530: If removeChildren() is called on this object, this hook is called exactly once after all children
0531: have been removed. In that case, the first parameter to this method will be the array of children and the
0532: second parameter will be null.
0533:
0534: In general a method overriding this method should begin by calling jsxsuper.
0535: * @param objChild the child that was removed
0536: * @param intIndex the index of the removed child
0537: */
0538: public void onRemoveChild(Object[] objChild, int intIndex) {
0539: ScriptBuffer script = new ScriptBuffer();
0540: script.appendCall(getContextPath() + "onRemoveChild", objChild,
0541: intIndex);
0542: getScriptProxy().addScript(script);
0543: }
0544:
0545: /**
0546: * Hook that notifies this model object that one of its children has been removed. This hook exists simply to allow
0547: this object to perform cleanup/re-render, and does not provide a veto mechanism. This method is called after
0548: the child has been removed from the model (this.getChildren() does not contain objChild)
0549: and after the child has been removed from the view (objChild.getRendered() is also null).
0550:
0551: This method is only called if the child is being removed from the DOM but this object (the parent) is not
0552: being removed. Therefore, this hook cannot be relied upon for garbage collection.
0553:
0554: If removeChildren() is called on this object, this hook is called exactly once after all children
0555: have been removed. In that case, the first parameter to this method will be the array of children and the
0556: second parameter will be null.
0557:
0558: In general a method overriding this method should begin by calling jsxsuper.
0559: * @param objChild the child that was removed
0560: * @param intIndex the index of the removed child
0561: */
0562: public void onRemoveChild(jsx3.app.Model objChild, int intIndex) {
0563: ScriptBuffer script = new ScriptBuffer();
0564: script.appendCall(getContextPath() + "onRemoveChild", objChild,
0565: intIndex);
0566: getScriptProxy().addScript(script);
0567: }
0568:
0569: /**
0570: * Removes a DOM child from this object. This method removes the on-screen DHTML of the removed object. The removed
0571: child will be completely derefenced from the DOM and will be prepped for garbage collection. If a DOM child must
0572: continue to exist after removing it from this parent, adoptChild() should be used instead of this
0573: method.
0574: * @param vntItem either the index of the child to remove or the child itself.
0575: * @return this object
0576: */
0577: @SuppressWarnings("unchecked")
0578: public jsx3.app.Model removeChild(jsx3.app.Model vntItem) {
0579: String extension = "removeChild(\"" + vntItem + "\").";
0580: try {
0581: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0582: .getConstructor(Context.class, String.class,
0583: ScriptProxy.class);
0584: return ctor.newInstance(this , extension, getScriptProxy());
0585: } catch (Exception ex) {
0586: throw new IllegalArgumentException("Unsupported type: "
0587: + jsx3.app.Model.class.getName());
0588: }
0589: }
0590:
0591: /**
0592: * Removes a DOM child from this object. This method removes the on-screen DHTML of the removed object. The removed
0593: child will be completely derefenced from the DOM and will be prepped for garbage collection. If a DOM child must
0594: continue to exist after removing it from this parent, adoptChild() should be used instead of this
0595: method.
0596: * @param vntItem either the index of the child to remove or the child itself.
0597: * @param returnType The expected return type
0598: * @return this object
0599: */
0600: @SuppressWarnings("unchecked")
0601: public <T> T removeChild(jsx3.app.Model vntItem, Class<T> returnType) {
0602: String extension = "removeChild(\"" + vntItem + "\").";
0603: try {
0604: java.lang.reflect.Constructor<T> ctor = returnType
0605: .getConstructor(Context.class, String.class,
0606: ScriptProxy.class);
0607: return ctor.newInstance(this , extension, getScriptProxy());
0608: } catch (Exception ex) {
0609: throw new IllegalArgumentException(
0610: "Unsupported return type: " + returnType.getName());
0611: }
0612: }
0613:
0614: /**
0615: * Removes a DOM child from this object. This method removes the on-screen DHTML of the removed object. The removed
0616: child will be completely derefenced from the DOM and will be prepped for garbage collection. If a DOM child must
0617: continue to exist after removing it from this parent, adoptChild() should be used instead of this
0618: method.
0619: * @param vntItem either the index of the child to remove or the child itself.
0620: * @return this object
0621: */
0622: @SuppressWarnings("unchecked")
0623: public jsx3.app.Model removeChild(int vntItem) {
0624: String extension = "removeChild(\"" + vntItem + "\").";
0625: try {
0626: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0627: .getConstructor(Context.class, String.class,
0628: ScriptProxy.class);
0629: return ctor.newInstance(this , extension, getScriptProxy());
0630: } catch (Exception ex) {
0631: throw new IllegalArgumentException("Unsupported type: "
0632: + jsx3.app.Model.class.getName());
0633: }
0634: }
0635:
0636: /**
0637: * Removes a DOM child from this object. This method removes the on-screen DHTML of the removed object. The removed
0638: child will be completely derefenced from the DOM and will be prepped for garbage collection. If a DOM child must
0639: continue to exist after removing it from this parent, adoptChild() should be used instead of this
0640: method.
0641: * @param vntItem either the index of the child to remove or the child itself.
0642: * @param returnType The expected return type
0643: * @return this object
0644: */
0645: @SuppressWarnings("unchecked")
0646: public <T> T removeChild(int vntItem, Class<T> returnType) {
0647: String extension = "removeChild(\"" + vntItem + "\").";
0648: try {
0649: java.lang.reflect.Constructor<T> ctor = returnType
0650: .getConstructor(Context.class, String.class,
0651: ScriptProxy.class);
0652: return ctor.newInstance(this , extension, getScriptProxy());
0653: } catch (Exception ex) {
0654: throw new IllegalArgumentException(
0655: "Unsupported return type: " + returnType.getName());
0656: }
0657: }
0658:
0659: /**
0660: * Removes some or all children of this object.
0661: * @param arrChildren the children to remove. If this parameter is not provided then all
0662: children are removed.
0663: * @return this object.
0664: */
0665: @SuppressWarnings("unchecked")
0666: public jsx3.app.Model removeChildren(Object[] arrChildren) {
0667: String extension = "removeChildren(\"" + arrChildren + "\").";
0668: try {
0669: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0670: .getConstructor(Context.class, String.class,
0671: ScriptProxy.class);
0672: return ctor.newInstance(this , extension, getScriptProxy());
0673: } catch (Exception ex) {
0674: throw new IllegalArgumentException("Unsupported type: "
0675: + jsx3.app.Model.class.getName());
0676: }
0677: }
0678:
0679: /**
0680: * Removes some or all children of this object.
0681: * @param arrChildren the children to remove. If this parameter is not provided then all
0682: children are removed.
0683: * @param returnType The expected return type
0684: * @return this object.
0685: */
0686: @SuppressWarnings("unchecked")
0687: public <T> T removeChildren(Object[] arrChildren,
0688: Class<T> returnType) {
0689: String extension = "removeChildren(\"" + arrChildren + "\").";
0690: try {
0691: java.lang.reflect.Constructor<T> ctor = returnType
0692: .getConstructor(Context.class, String.class,
0693: ScriptProxy.class);
0694: return ctor.newInstance(this , extension, getScriptProxy());
0695: } catch (Exception ex) {
0696: throw new IllegalArgumentException(
0697: "Unsupported return type: " + returnType.getName());
0698: }
0699: }
0700:
0701: /**
0702: * Returns an object reference to the server that owns this object. This method returns null if this
0703: object is part of a DOM fragment. Until an object is added to a DOM tree by passing it as the parameter to
0704: setChild(), the object will be a DOM fragment.
0705: */
0706: @SuppressWarnings("unchecked")
0707: public jsx3.app.Server getServer() {
0708: String extension = "getServer().";
0709: try {
0710: java.lang.reflect.Constructor<jsx3.app.Server> ctor = jsx3.app.Server.class
0711: .getConstructor(Context.class, String.class,
0712: ScriptProxy.class);
0713: return ctor.newInstance(this , extension, getScriptProxy());
0714: } catch (Exception ex) {
0715: throw new IllegalArgumentException("Unsupported type: "
0716: + jsx3.app.Server.class.getName());
0717: }
0718: }
0719:
0720: /**
0721: * Appends a DOM node to this object after removing the node from its former parent reference. If the node to append
0722: does not already have a DOM parent, setChild() should be used instead of this method.
0723: * @param objChild the child to adopt
0724: * @param bRepaint if <code>true</code> or <code>null</code>, the object being adopted will be added to
0725: the parent's view via the parent's <code>paintChild()</code> method.
0726: This parameter is made available for those situations where a loop is executing and multiple
0727: objects are being adopted. As view operations are the most CPU intensive, passing <code>false</code>
0728: while looping through a collection of child objects to adopt will improve performance. After the
0729: last child is adopted, simply call <code>repaint()</code> on the parent to immediately synchronize the view.
0730: * @param bForce if true, the adoption is forced, even if the parent/child don't accept such adoptions (<code>onSetChild()</code> and <code>onSetParent()</code> will still be called)
0731: */
0732: public void adoptChild(jsx3.app.Model objChild, boolean bRepaint,
0733: boolean bForce) {
0734: ScriptBuffer script = new ScriptBuffer();
0735: script.appendCall(getContextPath() + "adoptChild", objChild,
0736: bRepaint, bForce);
0737: getScriptProxy().addScript(script);
0738: }
0739:
0740: /**
0741: * Assigns objMoveChild as the previousSibling of objPrecedeChild
0742: * @param objMoveChild the one being moved. Can belong to this object, another object, or can be a GUI fragment
0743: * @param objPrecedeChild the one to insert before
0744: * @param bRepaint if <code>false</code> the repaint will be suppressed (useful for multiple obejct updates
0745: that would lead to unnecessary updates to the VIEW)
0746: * @param callback true if successful
0747: */
0748: @SuppressWarnings("unchecked")
0749: public void insertBefore(jsx3.app.Model objMoveChild,
0750: jsx3.app.Model objPrecedeChild, boolean bRepaint,
0751: org.directwebremoting.proxy.Callback<Boolean> callback) {
0752: ScriptBuffer script = new ScriptBuffer();
0753: String callbackPrefix = "";
0754:
0755: if (callback != null) {
0756: callbackPrefix = "var reply = ";
0757: }
0758:
0759: script.appendCall(callbackPrefix + getContextPath()
0760: + "insertBefore", objMoveChild, objPrecedeChild,
0761: bRepaint);
0762:
0763: if (callback != null) {
0764: String key = org.directwebremoting.extend.CallbackHelper
0765: .saveCallback(callback, Boolean.class);
0766: script
0767: .appendCall("__System.activateCallback", key,
0768: "reply");
0769: }
0770:
0771: getScriptProxy().addScript(script);
0772: }
0773:
0774: /**
0775: * Called when the server owning this DOM node changes.
0776: * @param objNewServer
0777: * @param objOldServer
0778: */
0779: public void onChangeServer(jsx3.app.Server objNewServer,
0780: jsx3.app.Server objOldServer) {
0781: ScriptBuffer script = new ScriptBuffer();
0782: script.appendCall(getContextPath() + "onChangeServer",
0783: objNewServer, objOldServer);
0784: getScriptProxy().addScript(script);
0785: }
0786:
0787: /**
0788: * Creates and returns an exact replica of the object. The clone will be appended as a new child node of this
0789: object's parent node.
0790: * @param intPersist the persistance value of the clone.
0791: * @param intMode <code>0</code> for insert as the last child of the parent of this object and paint,
0792: <code>1</code> for insert as the last child of this parent of this object and do not paint, or <code>2</code>
0793: for load as a fragment.
0794: * @return the clone.
0795: */
0796: @SuppressWarnings("unchecked")
0797: public jsx3.app.Model doClone(int intPersist, int intMode) {
0798: String extension = "doClone(\"" + intPersist + "\", \""
0799: + intMode + "\").";
0800: try {
0801: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0802: .getConstructor(Context.class, String.class,
0803: ScriptProxy.class);
0804: return ctor.newInstance(this , extension, getScriptProxy());
0805: } catch (Exception ex) {
0806: throw new IllegalArgumentException("Unsupported type: "
0807: + jsx3.app.Model.class.getName());
0808: }
0809: }
0810:
0811: /**
0812: * Creates and returns an exact replica of the object. The clone will be appended as a new child node of this
0813: object's parent node.
0814: * @param intPersist the persistance value of the clone.
0815: * @param intMode <code>0</code> for insert as the last child of the parent of this object and paint,
0816: <code>1</code> for insert as the last child of this parent of this object and do not paint, or <code>2</code>
0817: for load as a fragment.
0818: * @param returnType The expected return type
0819: * @return the clone.
0820: */
0821: @SuppressWarnings("unchecked")
0822: public <T> T doClone(int intPersist, int intMode,
0823: Class<T> returnType) {
0824: String extension = "doClone(\"" + intPersist + "\", \""
0825: + intMode + "\").";
0826: try {
0827: java.lang.reflect.Constructor<T> ctor = returnType
0828: .getConstructor(Context.class, String.class,
0829: ScriptProxy.class);
0830: return ctor.newInstance(this , extension, getScriptProxy());
0831: } catch (Exception ex) {
0832: throw new IllegalArgumentException(
0833: "Unsupported return type: " + returnType.getName());
0834: }
0835: }
0836:
0837: /**
0838: * Finds the first descendant of this DOM node with a the given name.
0839: * @param strName the name to query on.
0840: * @param bDepthFirst specifies whether to do a depth first or breadth first search.
0841: * @param bChildOnly if <code>true</code>, only search the children of this DOM node.
0842: * @return the descendant with the given name or <code>null</code> if none found.
0843: */
0844: @SuppressWarnings("unchecked")
0845: public jsx3.app.Model getDescendantOfName(String strName,
0846: boolean bDepthFirst, boolean bChildOnly) {
0847: String extension = "getDescendantOfName(\"" + strName
0848: + "\", \"" + bDepthFirst + "\", \"" + bChildOnly
0849: + "\").";
0850: try {
0851: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0852: .getConstructor(Context.class, String.class,
0853: ScriptProxy.class);
0854: return ctor.newInstance(this , extension, getScriptProxy());
0855: } catch (Exception ex) {
0856: throw new IllegalArgumentException("Unsupported type: "
0857: + jsx3.app.Model.class.getName());
0858: }
0859: }
0860:
0861: /**
0862: * Finds the first descendant of this DOM node with a the given name.
0863: * @param strName the name to query on.
0864: * @param bDepthFirst specifies whether to do a depth first or breadth first search.
0865: * @param bChildOnly if <code>true</code>, only search the children of this DOM node.
0866: * @param returnType The expected return type
0867: * @return the descendant with the given name or <code>null</code> if none found.
0868: */
0869: @SuppressWarnings("unchecked")
0870: public <T> T getDescendantOfName(String strName,
0871: boolean bDepthFirst, boolean bChildOnly, Class<T> returnType) {
0872: String extension = "getDescendantOfName(\"" + strName
0873: + "\", \"" + bDepthFirst + "\", \"" + bChildOnly
0874: + "\").";
0875: try {
0876: java.lang.reflect.Constructor<T> ctor = returnType
0877: .getConstructor(Context.class, String.class,
0878: ScriptProxy.class);
0879: return ctor.newInstance(this , extension, getScriptProxy());
0880: } catch (Exception ex) {
0881: throw new IllegalArgumentException(
0882: "Unsupported return type: " + returnType.getName());
0883: }
0884: }
0885:
0886: /**
0887: * Finds the first child of the given type.
0888: * @param strType the fully-qualified class name, class constructor function,
0889: or <code>jsx3.Class</code> instance.
0890: * @param bExact if <code>true</code> then only return objects whose class is exactly <code>strType</code>
0891: (rather than returning subclasses too).
0892: * @return the child of the given type or <code>null</code> if none found.
0893: */
0894: @SuppressWarnings("unchecked")
0895: public jsx3.app.Model getFirstChildOfType(
0896: org.directwebremoting.proxy.CodeBlock strType,
0897: boolean bExact) {
0898: String extension = "getFirstChildOfType(\"" + strType
0899: + "\", \"" + bExact + "\").";
0900: try {
0901: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0902: .getConstructor(Context.class, String.class,
0903: ScriptProxy.class);
0904: return ctor.newInstance(this , extension, getScriptProxy());
0905: } catch (Exception ex) {
0906: throw new IllegalArgumentException("Unsupported type: "
0907: + jsx3.app.Model.class.getName());
0908: }
0909: }
0910:
0911: /**
0912: * Finds the first child of the given type.
0913: * @param strType the fully-qualified class name, class constructor function,
0914: or <code>jsx3.Class</code> instance.
0915: * @param bExact if <code>true</code> then only return objects whose class is exactly <code>strType</code>
0916: (rather than returning subclasses too).
0917: * @param returnType The expected return type
0918: * @return the child of the given type or <code>null</code> if none found.
0919: */
0920: @SuppressWarnings("unchecked")
0921: public <T> T getFirstChildOfType(
0922: org.directwebremoting.proxy.CodeBlock strType,
0923: boolean bExact, Class<T> returnType) {
0924: String extension = "getFirstChildOfType(\"" + strType
0925: + "\", \"" + bExact + "\").";
0926: try {
0927: java.lang.reflect.Constructor<T> ctor = returnType
0928: .getConstructor(Context.class, String.class,
0929: ScriptProxy.class);
0930: return ctor.newInstance(this , extension, getScriptProxy());
0931: } catch (Exception ex) {
0932: throw new IllegalArgumentException(
0933: "Unsupported return type: " + returnType.getName());
0934: }
0935: }
0936:
0937: /**
0938: * Finds the first child of the given type.
0939: * @param strType the fully-qualified class name, class constructor function,
0940: or <code>jsx3.Class</code> instance.
0941: * @param bExact if <code>true</code> then only return objects whose class is exactly <code>strType</code>
0942: (rather than returning subclasses too).
0943: * @return the child of the given type or <code>null</code> if none found.
0944: */
0945: @SuppressWarnings("unchecked")
0946: public jsx3.app.Model getFirstChildOfType(Class strType,
0947: boolean bExact) {
0948: String extension = "getFirstChildOfType(\"" + strType
0949: + "\", \"" + bExact + "\").";
0950: try {
0951: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
0952: .getConstructor(Context.class, String.class,
0953: ScriptProxy.class);
0954: return ctor.newInstance(this , extension, getScriptProxy());
0955: } catch (Exception ex) {
0956: throw new IllegalArgumentException("Unsupported type: "
0957: + jsx3.app.Model.class.getName());
0958: }
0959: }
0960:
0961: /**
0962: * Finds the first child of the given type.
0963: * @param strType the fully-qualified class name, class constructor function,
0964: or <code>jsx3.Class</code> instance.
0965: * @param bExact if <code>true</code> then only return objects whose class is exactly <code>strType</code>
0966: (rather than returning subclasses too).
0967: * @param returnType The expected return type
0968: * @return the child of the given type or <code>null</code> if none found.
0969: */
0970: @SuppressWarnings("unchecked")
0971: public <T> T getFirstChildOfType(Class strType, boolean bExact,
0972: Class<T> returnType) {
0973: String extension = "getFirstChildOfType(\"" + strType
0974: + "\", \"" + bExact + "\").";
0975: try {
0976: java.lang.reflect.Constructor<T> ctor = returnType
0977: .getConstructor(Context.class, String.class,
0978: ScriptProxy.class);
0979: return ctor.newInstance(this , extension, getScriptProxy());
0980: } catch (Exception ex) {
0981: throw new IllegalArgumentException(
0982: "Unsupported return type: " + returnType.getName());
0983: }
0984: }
0985:
0986: /**
0987: * Finds the first child of the given type.
0988: * @param strType the fully-qualified class name, class constructor function,
0989: or <code>jsx3.Class</code> instance.
0990: * @param bExact if <code>true</code> then only return objects whose class is exactly <code>strType</code>
0991: (rather than returning subclasses too).
0992: * @return the child of the given type or <code>null</code> if none found.
0993: */
0994: @SuppressWarnings("unchecked")
0995: public jsx3.app.Model getFirstChildOfType(String strType,
0996: boolean bExact) {
0997: String extension = "getFirstChildOfType(\"" + strType
0998: + "\", \"" + bExact + "\").";
0999: try {
1000: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1001: .getConstructor(Context.class, String.class,
1002: ScriptProxy.class);
1003: return ctor.newInstance(this , extension, getScriptProxy());
1004: } catch (Exception ex) {
1005: throw new IllegalArgumentException("Unsupported type: "
1006: + jsx3.app.Model.class.getName());
1007: }
1008: }
1009:
1010: /**
1011: * Finds the first child of the given type.
1012: * @param strType the fully-qualified class name, class constructor function,
1013: or <code>jsx3.Class</code> instance.
1014: * @param bExact if <code>true</code> then only return objects whose class is exactly <code>strType</code>
1015: (rather than returning subclasses too).
1016: * @param returnType The expected return type
1017: * @return the child of the given type or <code>null</code> if none found.
1018: */
1019: @SuppressWarnings("unchecked")
1020: public <T> T getFirstChildOfType(String strType, boolean bExact,
1021: Class<T> returnType) {
1022: String extension = "getFirstChildOfType(\"" + strType
1023: + "\", \"" + bExact + "\").";
1024: try {
1025: java.lang.reflect.Constructor<T> ctor = returnType
1026: .getConstructor(Context.class, String.class,
1027: ScriptProxy.class);
1028: return ctor.newInstance(this , extension, getScriptProxy());
1029: } catch (Exception ex) {
1030: throw new IllegalArgumentException(
1031: "Unsupported return type: " + returnType.getName());
1032: }
1033: }
1034:
1035: /**
1036: * Finds all descendants of the given type.
1037: * @param strType the fully-qualified class name, class constructor function,
1038: or <code>jsx3.Class</code> instance.
1039: * @param bShallow if <code>true</code>, only search direct children, not all descendants.
1040: * @param callback an array of matching descendants
1041: */
1042: @SuppressWarnings("unchecked")
1043: public void getDescendantsOfType(
1044: org.directwebremoting.proxy.CodeBlock strType,
1045: boolean bShallow,
1046: org.directwebremoting.proxy.Callback<Object[]> callback) {
1047: ScriptBuffer script = new ScriptBuffer();
1048: String callbackPrefix = "";
1049:
1050: if (callback != null) {
1051: callbackPrefix = "var reply = ";
1052: }
1053:
1054: script.appendCall(callbackPrefix + getContextPath()
1055: + "getDescendantsOfType", strType, bShallow);
1056:
1057: if (callback != null) {
1058: String key = org.directwebremoting.extend.CallbackHelper
1059: .saveCallback(callback, Object[].class);
1060: script
1061: .appendCall("__System.activateCallback", key,
1062: "reply");
1063: }
1064:
1065: getScriptProxy().addScript(script);
1066: }
1067:
1068: /**
1069: * Finds all descendants of the given type.
1070: * @param strType the fully-qualified class name, class constructor function,
1071: or <code>jsx3.Class</code> instance.
1072: * @param bShallow if <code>true</code>, only search direct children, not all descendants.
1073: * @param callback an array of matching descendants
1074: */
1075: @SuppressWarnings("unchecked")
1076: public void getDescendantsOfType(String strType, boolean bShallow,
1077: org.directwebremoting.proxy.Callback<Object[]> callback) {
1078: ScriptBuffer script = new ScriptBuffer();
1079: String callbackPrefix = "";
1080:
1081: if (callback != null) {
1082: callbackPrefix = "var reply = ";
1083: }
1084:
1085: script.appendCall(callbackPrefix + getContextPath()
1086: + "getDescendantsOfType", strType, bShallow);
1087:
1088: if (callback != null) {
1089: String key = org.directwebremoting.extend.CallbackHelper
1090: .saveCallback(callback, Object[].class);
1091: script
1092: .appendCall("__System.activateCallback", key,
1093: "reply");
1094: }
1095:
1096: getScriptProxy().addScript(script);
1097: }
1098:
1099: /**
1100: * Finds all descendants of the given type.
1101: * @param strType the fully-qualified class name, class constructor function,
1102: or <code>jsx3.Class</code> instance.
1103: * @param bShallow if <code>true</code>, only search direct children, not all descendants.
1104: * @param callback an array of matching descendants
1105: */
1106: @SuppressWarnings("unchecked")
1107: public void getDescendantsOfType(Class strType, boolean bShallow,
1108: org.directwebremoting.proxy.Callback<Object[]> callback) {
1109: ScriptBuffer script = new ScriptBuffer();
1110: String callbackPrefix = "";
1111:
1112: if (callback != null) {
1113: callbackPrefix = "var reply = ";
1114: }
1115:
1116: script.appendCall(callbackPrefix + getContextPath()
1117: + "getDescendantsOfType", strType, bShallow);
1118:
1119: if (callback != null) {
1120: String key = org.directwebremoting.extend.CallbackHelper
1121: .saveCallback(callback, Object[].class);
1122: script
1123: .appendCall("__System.activateCallback", key,
1124: "reply");
1125: }
1126:
1127: getScriptProxy().addScript(script);
1128: }
1129:
1130: /**
1131: * Finds all DOM nodes descending from this DOM node that pass the given test function. Results are guaranteed to be
1132: returned in order according to the search order used.
1133: * @param fctTest test function, takes a single <code>jsx3.app.Model</code> parameter and returns
1134: <code>true</code> if the node matches.
1135: * @param bDepthFirst specifies whether to do a depth first or breadth first search.
1136: * @param bMultiple if <code>true</code>, return an array of matches, otherwise just the first match.
1137: * @param bShallow if <code>true</code>, only search direct children.
1138: * @param bIncludeSelf if <code>true</code>, include this node in the search.
1139: * @return the match (bMultiple = false) or matches (bMultiple = true).
1140: */
1141: @SuppressWarnings("unchecked")
1142: public jsx3.app.Model findDescendants(
1143: org.directwebremoting.proxy.CodeBlock fctTest,
1144: boolean bDepthFirst, boolean bMultiple, boolean bShallow,
1145: boolean bIncludeSelf) {
1146: String extension = "findDescendants(\"" + fctTest + "\", \""
1147: + bDepthFirst + "\", \"" + bMultiple + "\", \""
1148: + bShallow + "\", \"" + bIncludeSelf + "\").";
1149: try {
1150: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1151: .getConstructor(Context.class, String.class,
1152: ScriptProxy.class);
1153: return ctor.newInstance(this , extension, getScriptProxy());
1154: } catch (Exception ex) {
1155: throw new IllegalArgumentException("Unsupported type: "
1156: + jsx3.app.Model.class.getName());
1157: }
1158: }
1159:
1160: /**
1161: * Finds all DOM nodes descending from this DOM node that pass the given test function. Results are guaranteed to be
1162: returned in order according to the search order used.
1163: * @param fctTest test function, takes a single <code>jsx3.app.Model</code> parameter and returns
1164: <code>true</code> if the node matches.
1165: * @param bDepthFirst specifies whether to do a depth first or breadth first search.
1166: * @param bMultiple if <code>true</code>, return an array of matches, otherwise just the first match.
1167: * @param bShallow if <code>true</code>, only search direct children.
1168: * @param bIncludeSelf if <code>true</code>, include this node in the search.
1169: * @param returnType The expected return type
1170: * @return the match (bMultiple = false) or matches (bMultiple = true).
1171: */
1172: @SuppressWarnings("unchecked")
1173: public <T> T findDescendants(
1174: org.directwebremoting.proxy.CodeBlock fctTest,
1175: boolean bDepthFirst, boolean bMultiple, boolean bShallow,
1176: boolean bIncludeSelf, Class<T> returnType) {
1177: String extension = "findDescendants(\"" + fctTest + "\", \""
1178: + bDepthFirst + "\", \"" + bMultiple + "\", \""
1179: + bShallow + "\", \"" + bIncludeSelf + "\").";
1180: try {
1181: java.lang.reflect.Constructor<T> ctor = returnType
1182: .getConstructor(Context.class, String.class,
1183: ScriptProxy.class);
1184: return ctor.newInstance(this , extension, getScriptProxy());
1185: } catch (Exception ex) {
1186: throw new IllegalArgumentException(
1187: "Unsupported return type: " + returnType.getName());
1188: }
1189: }
1190:
1191: /**
1192: * The finalizer method. This method provides a hook for subclasses of this class to perform custom logic
1193: when an instance of this class is removed from the DOM. Methods that override this method should begin with
1194: a call to jsxsuper().
1195:
1196: Note that this method is called after this object has been removed from the DOM tree. Therefore
1197: this.getParent() and this.getServer() will return null. Use the
1198: objParent parameter for access to the DOM tree.
1199: * @param objParent reference to the former parent
1200: */
1201: public void onDestroy(jsx3.app.Model objParent) {
1202: ScriptBuffer script = new ScriptBuffer();
1203: script.appendCall(getContextPath() + "onDestroy", objParent);
1204: getScriptProxy().addScript(script);
1205: }
1206:
1207: /**
1208: * Returns the custom JSX-generated id for the object (i.e., _jsx2384098324509823049).
1209: * @param callback JSX id
1210: */
1211: @SuppressWarnings("unchecked")
1212: public void getId(
1213: org.directwebremoting.proxy.Callback<String> callback) {
1214: ScriptBuffer script = new ScriptBuffer();
1215: String callbackPrefix = "";
1216:
1217: if (callback != null) {
1218: callbackPrefix = "var reply = ";
1219: }
1220:
1221: script.appendCall(callbackPrefix + getContextPath() + "getId");
1222:
1223: if (callback != null) {
1224: String key = org.directwebremoting.extend.CallbackHelper
1225: .saveCallback(callback, String.class);
1226: script
1227: .appendCall("__System.activateCallback", key,
1228: "reply");
1229: }
1230:
1231: getScriptProxy().addScript(script);
1232: }
1233:
1234: /**
1235: * Returns the zero-based index for this DOM node in relation to its siblings.
1236: * @param callback the index or <code>-1</code> if this object does not have a parent.
1237: */
1238: @SuppressWarnings("unchecked")
1239: public void getChildIndex(
1240: org.directwebremoting.proxy.Callback<Integer> callback) {
1241: ScriptBuffer script = new ScriptBuffer();
1242: String callbackPrefix = "";
1243:
1244: if (callback != null) {
1245: callbackPrefix = "var reply = ";
1246: }
1247:
1248: script.appendCall(callbackPrefix + getContextPath()
1249: + "getChildIndex");
1250:
1251: if (callback != null) {
1252: String key = org.directwebremoting.extend.CallbackHelper
1253: .saveCallback(callback, Integer.class);
1254: script
1255: .appendCall("__System.activateCallback", key,
1256: "reply");
1257: }
1258:
1259: getScriptProxy().addScript(script);
1260: }
1261:
1262: /**
1263: * Returns the custom developer-defined name of this object.
1264: */
1265: @SuppressWarnings("unchecked")
1266: public void getName(
1267: org.directwebremoting.proxy.Callback<String> callback) {
1268: ScriptBuffer script = new ScriptBuffer();
1269: String callbackPrefix = "";
1270:
1271: if (callback != null) {
1272: callbackPrefix = "var reply = ";
1273: }
1274:
1275: script
1276: .appendCall(callbackPrefix + getContextPath()
1277: + "getName");
1278:
1279: if (callback != null) {
1280: String key = org.directwebremoting.extend.CallbackHelper
1281: .saveCallback(callback, String.class);
1282: script
1283: .appendCall("__System.activateCallback", key,
1284: "reply");
1285: }
1286:
1287: getScriptProxy().addScript(script);
1288: }
1289:
1290: /**
1291: * Sets the custom developer-defined name of this object.
1292: * @param strName a name unique among all DOM nodes currently loaded in the application.
1293: */
1294: public void setName(String strName) {
1295: ScriptBuffer script = new ScriptBuffer();
1296: script.appendCall(getContextPath() + "setName", strName);
1297: getScriptProxy().addScript(script);
1298: }
1299:
1300: /**
1301: * Returns the help ID of this object.
1302: */
1303: @SuppressWarnings("unchecked")
1304: public void getHelpId(
1305: org.directwebremoting.proxy.Callback<String> callback) {
1306: ScriptBuffer script = new ScriptBuffer();
1307: String callbackPrefix = "";
1308:
1309: if (callback != null) {
1310: callbackPrefix = "var reply = ";
1311: }
1312:
1313: script.appendCall(callbackPrefix + getContextPath()
1314: + "getHelpId");
1315:
1316: if (callback != null) {
1317: String key = org.directwebremoting.extend.CallbackHelper
1318: .saveCallback(callback, String.class);
1319: script
1320: .appendCall("__System.activateCallback", key,
1321: "reply");
1322: }
1323:
1324: getScriptProxy().addScript(script);
1325: }
1326:
1327: /**
1328: * Sets the help ID of this object.
1329: * @param strId
1330: */
1331: public void setHelpId(String strId) {
1332: ScriptBuffer script = new ScriptBuffer();
1333: script.appendCall(getContextPath() + "setHelpId", strId);
1334: getScriptProxy().addScript(script);
1335: }
1336:
1337: /**
1338: * Returns the load type of this DOM node and the descending branch. The load type determines how this DOM branch
1339: deserializes and paints in relation to its parent DOM node.
1340: * @param callback <code>LT_NORMAL</code>, <code>LT_SLEEP_PAINT</code>, <code>LT_SLEEP_DESER</code>,
1341: <code>LT_SLEEP_PD</code>, <code>LT_SHOW_PAINT</code>, or <code>LT_SHOW_DESER</code>.
1342: */
1343: @SuppressWarnings("unchecked")
1344: public void getLoadType(
1345: org.directwebremoting.proxy.Callback<Integer> callback) {
1346: ScriptBuffer script = new ScriptBuffer();
1347: String callbackPrefix = "";
1348:
1349: if (callback != null) {
1350: callbackPrefix = "var reply = ";
1351: }
1352:
1353: script.appendCall(callbackPrefix + getContextPath()
1354: + "getLoadType");
1355:
1356: if (callback != null) {
1357: String key = org.directwebremoting.extend.CallbackHelper
1358: .saveCallback(callback, Integer.class);
1359: script
1360: .appendCall("__System.activateCallback", key,
1361: "reply");
1362: }
1363:
1364: getScriptProxy().addScript(script);
1365: }
1366:
1367: /**
1368: * Sets the load type of this DOM node and the descending branch.
1369: * @param intLoadType <code>LT_NORMAL</code>, <code>LT_SLEEP_PAINT</code>, <code>LT_SLEEP_DESER</code>,
1370: <code>LT_SLEEP_PD</code>, <code>LT_SHOW_PAINT</code>, or <code>LT_SHOW_DESER</code>.
1371: */
1372: public void setLoadType(int intLoadType) {
1373: ScriptBuffer script = new ScriptBuffer();
1374: script
1375: .appendCall(getContextPath() + "setLoadType",
1376: intLoadType);
1377: getScriptProxy().addScript(script);
1378: }
1379:
1380: /**
1381: * Returns the parent DOM node of this object.
1382: */
1383: @SuppressWarnings("unchecked")
1384: public jsx3.app.Model getParent() {
1385: String extension = "getParent().";
1386: try {
1387: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1388: .getConstructor(Context.class, String.class,
1389: ScriptProxy.class);
1390: return ctor.newInstance(this , extension, getScriptProxy());
1391: } catch (Exception ex) {
1392: throw new IllegalArgumentException("Unsupported type: "
1393: + jsx3.app.Model.class.getName());
1394: }
1395: }
1396:
1397: /**
1398: * Returns the parent DOM node of this object.
1399: * @param returnType The expected return type
1400: */
1401: @SuppressWarnings("unchecked")
1402: public <T> T getParent(Class<T> returnType) {
1403: String extension = "getParent().";
1404: try {
1405: java.lang.reflect.Constructor<T> ctor = returnType
1406: .getConstructor(Context.class, String.class,
1407: ScriptProxy.class);
1408: return ctor.newInstance(this , extension, getScriptProxy());
1409: } catch (Exception ex) {
1410: throw new IllegalArgumentException(
1411: "Unsupported return type: " + returnType.getName());
1412: }
1413: }
1414:
1415: /**
1416: * Returns the first ancestor of the given type.
1417: * @param strType the fully-qualified class name, class constructor function,
1418: or <code>jsx3.Class</code> instance.
1419: * @return the first ancestor of the given type or <code>null</code> if none found.
1420: */
1421: @SuppressWarnings("unchecked")
1422: public jsx3.app.Model getAncestorOfType(String strType) {
1423: String extension = "getAncestorOfType(\"" + strType + "\").";
1424: try {
1425: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1426: .getConstructor(Context.class, String.class,
1427: ScriptProxy.class);
1428: return ctor.newInstance(this , extension, getScriptProxy());
1429: } catch (Exception ex) {
1430: throw new IllegalArgumentException("Unsupported type: "
1431: + jsx3.app.Model.class.getName());
1432: }
1433: }
1434:
1435: /**
1436: * Returns the first ancestor of the given type.
1437: * @param strType the fully-qualified class name, class constructor function,
1438: or <code>jsx3.Class</code> instance.
1439: * @param returnType The expected return type
1440: * @return the first ancestor of the given type or <code>null</code> if none found.
1441: */
1442: @SuppressWarnings("unchecked")
1443: public <T> T getAncestorOfType(String strType, Class<T> returnType) {
1444: String extension = "getAncestorOfType(\"" + strType + "\").";
1445: try {
1446: java.lang.reflect.Constructor<T> ctor = returnType
1447: .getConstructor(Context.class, String.class,
1448: ScriptProxy.class);
1449: return ctor.newInstance(this , extension, getScriptProxy());
1450: } catch (Exception ex) {
1451: throw new IllegalArgumentException(
1452: "Unsupported return type: " + returnType.getName());
1453: }
1454: }
1455:
1456: /**
1457: * Returns the first ancestor of the given type.
1458: * @param strType the fully-qualified class name, class constructor function,
1459: or <code>jsx3.Class</code> instance.
1460: * @return the first ancestor of the given type or <code>null</code> if none found.
1461: */
1462: @SuppressWarnings("unchecked")
1463: public jsx3.app.Model getAncestorOfType(Class strType) {
1464: String extension = "getAncestorOfType(\"" + strType + "\").";
1465: try {
1466: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1467: .getConstructor(Context.class, String.class,
1468: ScriptProxy.class);
1469: return ctor.newInstance(this , extension, getScriptProxy());
1470: } catch (Exception ex) {
1471: throw new IllegalArgumentException("Unsupported type: "
1472: + jsx3.app.Model.class.getName());
1473: }
1474: }
1475:
1476: /**
1477: * Returns the first ancestor of the given type.
1478: * @param strType the fully-qualified class name, class constructor function,
1479: or <code>jsx3.Class</code> instance.
1480: * @param returnType The expected return type
1481: * @return the first ancestor of the given type or <code>null</code> if none found.
1482: */
1483: @SuppressWarnings("unchecked")
1484: public <T> T getAncestorOfType(Class strType, Class<T> returnType) {
1485: String extension = "getAncestorOfType(\"" + strType + "\").";
1486: try {
1487: java.lang.reflect.Constructor<T> ctor = returnType
1488: .getConstructor(Context.class, String.class,
1489: ScriptProxy.class);
1490: return ctor.newInstance(this , extension, getScriptProxy());
1491: } catch (Exception ex) {
1492: throw new IllegalArgumentException(
1493: "Unsupported return type: " + returnType.getName());
1494: }
1495: }
1496:
1497: /**
1498: * Returns the first ancestor of the given type.
1499: * @param strType the fully-qualified class name, class constructor function,
1500: or <code>jsx3.Class</code> instance.
1501: * @return the first ancestor of the given type or <code>null</code> if none found.
1502: */
1503: @SuppressWarnings("unchecked")
1504: public jsx3.app.Model getAncestorOfType(
1505: org.directwebremoting.proxy.CodeBlock strType) {
1506: String extension = "getAncestorOfType(\"" + strType + "\").";
1507: try {
1508: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1509: .getConstructor(Context.class, String.class,
1510: ScriptProxy.class);
1511: return ctor.newInstance(this , extension, getScriptProxy());
1512: } catch (Exception ex) {
1513: throw new IllegalArgumentException("Unsupported type: "
1514: + jsx3.app.Model.class.getName());
1515: }
1516: }
1517:
1518: /**
1519: * Returns the first ancestor of the given type.
1520: * @param strType the fully-qualified class name, class constructor function,
1521: or <code>jsx3.Class</code> instance.
1522: * @param returnType The expected return type
1523: * @return the first ancestor of the given type or <code>null</code> if none found.
1524: */
1525: @SuppressWarnings("unchecked")
1526: public <T> T getAncestorOfType(
1527: org.directwebremoting.proxy.CodeBlock strType,
1528: Class<T> returnType) {
1529: String extension = "getAncestorOfType(\"" + strType + "\").";
1530: try {
1531: java.lang.reflect.Constructor<T> ctor = returnType
1532: .getConstructor(Context.class, String.class,
1533: ScriptProxy.class);
1534: return ctor.newInstance(this , extension, getScriptProxy());
1535: } catch (Exception ex) {
1536: throw new IllegalArgumentException(
1537: "Unsupported return type: " + returnType.getName());
1538: }
1539: }
1540:
1541: /**
1542: * Returns the first ancestor with the given name.
1543: * @param strName the name to query on.
1544: * @return the first ancestor with the given name or <code>null</code> if none found.
1545: */
1546: @SuppressWarnings("unchecked")
1547: public jsx3.app.Model getAncestorOfName(String strName) {
1548: String extension = "getAncestorOfName(\"" + strName + "\").";
1549: try {
1550: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1551: .getConstructor(Context.class, String.class,
1552: ScriptProxy.class);
1553: return ctor.newInstance(this , extension, getScriptProxy());
1554: } catch (Exception ex) {
1555: throw new IllegalArgumentException("Unsupported type: "
1556: + jsx3.app.Model.class.getName());
1557: }
1558: }
1559:
1560: /**
1561: * Returns the first ancestor with the given name.
1562: * @param strName the name to query on.
1563: * @param returnType The expected return type
1564: * @return the first ancestor with the given name or <code>null</code> if none found.
1565: */
1566: @SuppressWarnings("unchecked")
1567: public <T> T getAncestorOfName(String strName, Class<T> returnType) {
1568: String extension = "getAncestorOfName(\"" + strName + "\").";
1569: try {
1570: java.lang.reflect.Constructor<T> ctor = returnType
1571: .getConstructor(Context.class, String.class,
1572: ScriptProxy.class);
1573: return ctor.newInstance(this , extension, getScriptProxy());
1574: } catch (Exception ex) {
1575: throw new IllegalArgumentException(
1576: "Unsupported return type: " + returnType.getName());
1577: }
1578: }
1579:
1580: /**
1581: * Returns the first ancestor passing the given test function.
1582: * @param fctTest test function, takes a single <code>jsx3.app.Model</code> parameter and returns
1583: <code>true</code> if the node matches.
1584: * @param bIncludeSelf if <code>true</code>, include this object in the search
1585: */
1586: @SuppressWarnings("unchecked")
1587: public jsx3.app.Model findAncestor(
1588: org.directwebremoting.proxy.CodeBlock fctTest,
1589: boolean bIncludeSelf) {
1590: String extension = "findAncestor(\"" + fctTest + "\", \""
1591: + bIncludeSelf + "\").";
1592: try {
1593: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1594: .getConstructor(Context.class, String.class,
1595: ScriptProxy.class);
1596: return ctor.newInstance(this , extension, getScriptProxy());
1597: } catch (Exception ex) {
1598: throw new IllegalArgumentException("Unsupported type: "
1599: + jsx3.app.Model.class.getName());
1600: }
1601: }
1602:
1603: /**
1604: * Returns the first ancestor passing the given test function.
1605: * @param fctTest test function, takes a single <code>jsx3.app.Model</code> parameter and returns
1606: <code>true</code> if the node matches.
1607: * @param bIncludeSelf if <code>true</code>, include this object in the search
1608: * @param returnType The expected return type
1609: */
1610: @SuppressWarnings("unchecked")
1611: public <T> T findAncestor(
1612: org.directwebremoting.proxy.CodeBlock fctTest,
1613: boolean bIncludeSelf, Class<T> returnType) {
1614: String extension = "findAncestor(\"" + fctTest + "\", \""
1615: + bIncludeSelf + "\").";
1616: try {
1617: java.lang.reflect.Constructor<T> ctor = returnType
1618: .getConstructor(Context.class, String.class,
1619: ScriptProxy.class);
1620: return ctor.newInstance(this , extension, getScriptProxy());
1621: } catch (Exception ex) {
1622: throw new IllegalArgumentException(
1623: "Unsupported return type: " + returnType.getName());
1624: }
1625: }
1626:
1627: /**
1628: * Returns this object serialized as XML by calling toString() on the result of toXMLDoc()
1629: called on this object.
1630: * @param objProperties name-value pairs that affect the serialization. See
1631: <code>toXMLDoc()</code> for a description.
1632: * @param callback this object serialized as an XML string.
1633: */
1634: @SuppressWarnings("unchecked")
1635: public void toXML(jsx3.lang.Object objProperties,
1636: org.directwebremoting.proxy.Callback<String> callback) {
1637: ScriptBuffer script = new ScriptBuffer();
1638: String callbackPrefix = "";
1639:
1640: if (callback != null) {
1641: callbackPrefix = "var reply = ";
1642: }
1643:
1644: script.appendCall(callbackPrefix + getContextPath() + "toXML",
1645: objProperties);
1646:
1647: if (callback != null) {
1648: String key = org.directwebremoting.extend.CallbackHelper
1649: .saveCallback(callback, String.class);
1650: script
1651: .appendCall("__System.activateCallback", key,
1652: "reply");
1653: }
1654:
1655: getScriptProxy().addScript(script);
1656: }
1657:
1658: /**
1659: * Serializes this object as an XML document.
1660:
1661: The objProperties parameter may include the following keys:
1662:
1663: onafter {String} - the value of the onAfterDeserialize element
1664: onbefore {String} - the value of the onBeforeDeserialize element
1665: name {String} - the value of the name element
1666: icon {String} - the value of the icon element
1667: description {String} - the value of the description element
1668: children {boolean} - if true the children of this object, rather than this object, are
1669: serialized
1670: persistall {boolean} - if true all descendants with persistence PERSISTNONE are included in the
1671: serialization
1672: * @param objProperties name-value pairs that affect the serialization. See above for
1673: valid names and how they affect serialization.
1674: * @return this object serialized as an XML document.
1675: */
1676: @SuppressWarnings("unchecked")
1677: public jsx3.xml.CdfDocument toXMLDoc(jsx3.lang.Object objProperties) {
1678: String extension = "toXMLDoc(\"" + objProperties + "\").";
1679: try {
1680: java.lang.reflect.Constructor<jsx3.xml.CdfDocument> ctor = jsx3.xml.CdfDocument.class
1681: .getConstructor(Context.class, String.class,
1682: ScriptProxy.class);
1683: return ctor.newInstance(this , extension, getScriptProxy());
1684: } catch (Exception ex) {
1685: throw new IllegalArgumentException("Unsupported type: "
1686: + jsx3.xml.CdfDocument.class.getName());
1687: }
1688: }
1689:
1690: /**
1691: * Serializes this object as an XML document.
1692:
1693: The objProperties parameter may include the following keys:
1694:
1695: onafter {String} - the value of the onAfterDeserialize element
1696: onbefore {String} - the value of the onBeforeDeserialize element
1697: name {String} - the value of the name element
1698: icon {String} - the value of the icon element
1699: description {String} - the value of the description element
1700: children {boolean} - if true the children of this object, rather than this object, are
1701: serialized
1702: persistall {boolean} - if true all descendants with persistence PERSISTNONE are included in the
1703: serialization
1704: * @param objProperties name-value pairs that affect the serialization. See above for
1705: valid names and how they affect serialization.
1706: * @param returnType The expected return type
1707: * @return this object serialized as an XML document.
1708: */
1709: @SuppressWarnings("unchecked")
1710: public <T> T toXMLDoc(jsx3.lang.Object objProperties,
1711: Class<T> returnType) {
1712: String extension = "toXMLDoc(\"" + objProperties + "\").";
1713: try {
1714: java.lang.reflect.Constructor<T> ctor = returnType
1715: .getConstructor(Context.class, String.class,
1716: ScriptProxy.class);
1717: return ctor.newInstance(this , extension, getScriptProxy());
1718: } catch (Exception ex) {
1719: throw new IllegalArgumentException(
1720: "Unsupported return type: " + returnType.getName());
1721: }
1722: }
1723:
1724: /**
1725: * Returns the namespace that distinguishes this object's server (owner) from other server instances. The namespace
1726: is set when this object is bound to a DOM tree.
1727: * @param callback the namespace of the server that owns this object instance.
1728: */
1729: @SuppressWarnings("unchecked")
1730: public void getNS(
1731: org.directwebremoting.proxy.Callback<String> callback) {
1732: ScriptBuffer script = new ScriptBuffer();
1733: String callbackPrefix = "";
1734:
1735: if (callback != null) {
1736: callbackPrefix = "var reply = ";
1737: }
1738:
1739: script.appendCall(callbackPrefix + getContextPath() + "getNS");
1740:
1741: if (callback != null) {
1742: String key = org.directwebremoting.extend.CallbackHelper
1743: .saveCallback(callback, String.class);
1744: script
1745: .appendCall("__System.activateCallback", key,
1746: "reply");
1747: }
1748:
1749: getScriptProxy().addScript(script);
1750: }
1751:
1752: /**
1753: * Returns the URI resolver for this DOM node. This method returns the server of this object unless this node
1754: or its ancestor was loaded into the DOM with an explicit URI resolver.
1755: */
1756: @SuppressWarnings("unchecked")
1757: public jsx3.net.URIResolver getUriResolver() {
1758: String extension = "getUriResolver().";
1759: try {
1760: java.lang.reflect.Constructor<jsx3.net.URIResolver> ctor = jsx3.net.URIResolver.class
1761: .getConstructor(Context.class, String.class,
1762: ScriptProxy.class);
1763: return ctor.newInstance(this , extension, getScriptProxy());
1764: } catch (Exception ex) {
1765: throw new IllegalArgumentException("Unsupported type: "
1766: + jsx3.net.URIResolver.class.getName());
1767: }
1768: }
1769:
1770: /**
1771: * Returns the URI resolver for this DOM node. This method returns the server of this object unless this node
1772: or its ancestor was loaded into the DOM with an explicit URI resolver.
1773: * @param returnType The expected return type
1774: */
1775: @SuppressWarnings("unchecked")
1776: public <T> T getUriResolver(Class<T> returnType) {
1777: String extension = "getUriResolver().";
1778: try {
1779: java.lang.reflect.Constructor<T> ctor = returnType
1780: .getConstructor(Context.class, String.class,
1781: ScriptProxy.class);
1782: return ctor.newInstance(this , extension, getScriptProxy());
1783: } catch (Exception ex) {
1784: throw new IllegalArgumentException(
1785: "Unsupported return type: " + returnType.getName());
1786: }
1787: }
1788:
1789: /**
1790: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1791: * @param strURL URL (either relative or absolute) of the serialization file to deserialize.
1792: This URL is resolved relative to <code>objResolver</code>, if provided, or the URI resolver of this DOM node.
1793: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1794: added to the parent's view via the parent object's <code>paintChild()</code> method.
1795: * @param objResolver If this parameter is provided, <code>strURL</code> is resolved
1796: relative to it. Additionally, this resolver is stored as the URI resolver for this DOM node and its descendants.
1797: * @return the deserialized object. A serialization file may specify more than one root
1798: object, in which case this method returns the first deserialized object.
1799: */
1800: @SuppressWarnings("unchecked")
1801: public jsx3.app.Model load(java.net.URI strURL, boolean bRepaint,
1802: jsx3.net.URIResolver objResolver) {
1803: String extension = "load(\"" + strURL + "\", \"" + bRepaint
1804: + "\", \"" + objResolver + "\").";
1805: try {
1806: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1807: .getConstructor(Context.class, String.class,
1808: ScriptProxy.class);
1809: return ctor.newInstance(this , extension, getScriptProxy());
1810: } catch (Exception ex) {
1811: throw new IllegalArgumentException("Unsupported type: "
1812: + jsx3.app.Model.class.getName());
1813: }
1814: }
1815:
1816: /**
1817: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1818: * @param strURL URL (either relative or absolute) of the serialization file to deserialize.
1819: This URL is resolved relative to <code>objResolver</code>, if provided, or the URI resolver of this DOM node.
1820: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1821: added to the parent's view via the parent object's <code>paintChild()</code> method.
1822: * @param objResolver If this parameter is provided, <code>strURL</code> is resolved
1823: relative to it. Additionally, this resolver is stored as the URI resolver for this DOM node and its descendants.
1824: * @param returnType The expected return type
1825: * @return the deserialized object. A serialization file may specify more than one root
1826: object, in which case this method returns the first deserialized object.
1827: */
1828: @SuppressWarnings("unchecked")
1829: public <T> T load(java.net.URI strURL, boolean bRepaint,
1830: jsx3.net.URIResolver objResolver, Class<T> returnType) {
1831: String extension = "load(\"" + strURL + "\", \"" + bRepaint
1832: + "\", \"" + objResolver + "\").";
1833: try {
1834: java.lang.reflect.Constructor<T> ctor = returnType
1835: .getConstructor(Context.class, String.class,
1836: ScriptProxy.class);
1837: return ctor.newInstance(this , extension, getScriptProxy());
1838: } catch (Exception ex) {
1839: throw new IllegalArgumentException(
1840: "Unsupported return type: " + returnType.getName());
1841: }
1842: }
1843:
1844: /**
1845: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1846: * @param strURL URL (either relative or absolute) of the serialization file to deserialize.
1847: This URL is resolved relative to <code>objResolver</code>, if provided, or the URI resolver of this DOM node.
1848: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1849: added to the parent's view via the parent object's <code>paintChild()</code> method.
1850: * @param objResolver If this parameter is provided, <code>strURL</code> is resolved
1851: relative to it. Additionally, this resolver is stored as the URI resolver for this DOM node and its descendants.
1852: * @return the deserialized object. A serialization file may specify more than one root
1853: object, in which case this method returns the first deserialized object.
1854: */
1855: @SuppressWarnings("unchecked")
1856: public jsx3.app.Model load(String strURL, boolean bRepaint,
1857: jsx3.net.URIResolver objResolver) {
1858: String extension = "load(\"" + strURL + "\", \"" + bRepaint
1859: + "\", \"" + objResolver + "\").";
1860: try {
1861: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1862: .getConstructor(Context.class, String.class,
1863: ScriptProxy.class);
1864: return ctor.newInstance(this , extension, getScriptProxy());
1865: } catch (Exception ex) {
1866: throw new IllegalArgumentException("Unsupported type: "
1867: + jsx3.app.Model.class.getName());
1868: }
1869: }
1870:
1871: /**
1872: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1873: * @param strURL URL (either relative or absolute) of the serialization file to deserialize.
1874: This URL is resolved relative to <code>objResolver</code>, if provided, or the URI resolver of this DOM node.
1875: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1876: added to the parent's view via the parent object's <code>paintChild()</code> method.
1877: * @param objResolver If this parameter is provided, <code>strURL</code> is resolved
1878: relative to it. Additionally, this resolver is stored as the URI resolver for this DOM node and its descendants.
1879: * @param returnType The expected return type
1880: * @return the deserialized object. A serialization file may specify more than one root
1881: object, in which case this method returns the first deserialized object.
1882: */
1883: @SuppressWarnings("unchecked")
1884: public <T> T load(String strURL, boolean bRepaint,
1885: jsx3.net.URIResolver objResolver, Class<T> returnType) {
1886: String extension = "load(\"" + strURL + "\", \"" + bRepaint
1887: + "\", \"" + objResolver + "\").";
1888: try {
1889: java.lang.reflect.Constructor<T> ctor = returnType
1890: .getConstructor(Context.class, String.class,
1891: ScriptProxy.class);
1892: return ctor.newInstance(this , extension, getScriptProxy());
1893: } catch (Exception ex) {
1894: throw new IllegalArgumentException(
1895: "Unsupported return type: " + returnType.getName());
1896: }
1897: }
1898:
1899: /**
1900: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1901: * @param strXML the XML content of a JSX serialization file.
1902: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1903: added to the parent's view via the parent object's <code>paintChild()</code> method.
1904: * @param objResolver
1905: * @return the deserialized object. A serialization file may specify more than one root
1906: object, in which case this method returns the first deserialized object.
1907: */
1908: @SuppressWarnings("unchecked")
1909: public jsx3.app.Model loadXML(jsx3.xml.CdfDocument strXML,
1910: boolean bRepaint, jsx3.net.URIResolver objResolver) {
1911: String extension = "loadXML(\"" + strXML + "\", \"" + bRepaint
1912: + "\", \"" + objResolver + "\").";
1913: try {
1914: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1915: .getConstructor(Context.class, String.class,
1916: ScriptProxy.class);
1917: return ctor.newInstance(this , extension, getScriptProxy());
1918: } catch (Exception ex) {
1919: throw new IllegalArgumentException("Unsupported type: "
1920: + jsx3.app.Model.class.getName());
1921: }
1922: }
1923:
1924: /**
1925: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1926: * @param strXML the XML content of a JSX serialization file.
1927: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1928: added to the parent's view via the parent object's <code>paintChild()</code> method.
1929: * @param objResolver
1930: * @param returnType The expected return type
1931: * @return the deserialized object. A serialization file may specify more than one root
1932: object, in which case this method returns the first deserialized object.
1933: */
1934: @SuppressWarnings("unchecked")
1935: public <T> T loadXML(jsx3.xml.CdfDocument strXML, boolean bRepaint,
1936: jsx3.net.URIResolver objResolver, Class<T> returnType) {
1937: String extension = "loadXML(\"" + strXML + "\", \"" + bRepaint
1938: + "\", \"" + objResolver + "\").";
1939: try {
1940: java.lang.reflect.Constructor<T> ctor = returnType
1941: .getConstructor(Context.class, String.class,
1942: ScriptProxy.class);
1943: return ctor.newInstance(this , extension, getScriptProxy());
1944: } catch (Exception ex) {
1945: throw new IllegalArgumentException(
1946: "Unsupported return type: " + returnType.getName());
1947: }
1948: }
1949:
1950: /**
1951: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1952: * @param strXML the XML content of a JSX serialization file.
1953: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1954: added to the parent's view via the parent object's <code>paintChild()</code> method.
1955: * @param objResolver
1956: * @return the deserialized object. A serialization file may specify more than one root
1957: object, in which case this method returns the first deserialized object.
1958: */
1959: @SuppressWarnings("unchecked")
1960: public jsx3.app.Model loadXML(String strXML, boolean bRepaint,
1961: jsx3.net.URIResolver objResolver) {
1962: String extension = "loadXML(\"" + strXML + "\", \"" + bRepaint
1963: + "\", \"" + objResolver + "\").";
1964: try {
1965: java.lang.reflect.Constructor<jsx3.app.Model> ctor = jsx3.app.Model.class
1966: .getConstructor(Context.class, String.class,
1967: ScriptProxy.class);
1968: return ctor.newInstance(this , extension, getScriptProxy());
1969: } catch (Exception ex) {
1970: throw new IllegalArgumentException("Unsupported type: "
1971: + jsx3.app.Model.class.getName());
1972: }
1973: }
1974:
1975: /**
1976: * Deserializes a JSX serialization file and appends the deserialized objects as children of this DOM node.
1977: * @param strXML the XML content of a JSX serialization file.
1978: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
1979: added to the parent's view via the parent object's <code>paintChild()</code> method.
1980: * @param objResolver
1981: * @param returnType The expected return type
1982: * @return the deserialized object. A serialization file may specify more than one root
1983: object, in which case this method returns the first deserialized object.
1984: */
1985: @SuppressWarnings("unchecked")
1986: public <T> T loadXML(String strXML, boolean bRepaint,
1987: jsx3.net.URIResolver objResolver, Class<T> returnType) {
1988: String extension = "loadXML(\"" + strXML + "\", \"" + bRepaint
1989: + "\", \"" + objResolver + "\").";
1990: try {
1991: java.lang.reflect.Constructor<T> ctor = returnType
1992: .getConstructor(Context.class, String.class,
1993: ScriptProxy.class);
1994: return ctor.newInstance(this , extension, getScriptProxy());
1995: } catch (Exception ex) {
1996: throw new IllegalArgumentException(
1997: "Unsupported return type: " + returnType.getName());
1998: }
1999: }
2000:
2001: /**
2002: * Loads a component file and caches the document in an XML cache. If the component file already exists in the cache
2003: then it is loaded from the cache. All component files loaded as a result of this call (referenced files) are also
2004: cached. This method is a useful replacement for load() when the same URL will be loaded multiple
2005: times in one application.
2006: * @param strURL URL (either relative or absolute) of the serialization file to deserialize.
2007: This URL is resolved relative to <code>objResolver</code>, if provided, or the URI resolver of this DOM node.
2008: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
2009: added to the parent's view via the parent object's <code>paintChild()</code> method.
2010: * @param objCache the cache to store the component XML documents in. If not provided, the cache
2011: of the server of this model object is used.
2012: * @param objResolver If this parameter is provided, <code>strURL</code> is resolved
2013: relative to it. Additionally, this resolver is stored as the URI resolver for this DOM node and its descendants.
2014: */
2015: public void loadAndCache(java.net.URI strURL, boolean bRepaint,
2016: jsx3.app.Cache objCache, jsx3.net.URIResolver objResolver) {
2017: ScriptBuffer script = new ScriptBuffer();
2018: script.appendCall(getContextPath() + "loadAndCache", strURL,
2019: bRepaint, objCache, objResolver);
2020: getScriptProxy().addScript(script);
2021: }
2022:
2023: /**
2024: * Loads a component file and caches the document in an XML cache. If the component file already exists in the cache
2025: then it is loaded from the cache. All component files loaded as a result of this call (referenced files) are also
2026: cached. This method is a useful replacement for load() when the same URL will be loaded multiple
2027: times in one application.
2028: * @param strURL URL (either relative or absolute) of the serialization file to deserialize.
2029: This URL is resolved relative to <code>objResolver</code>, if provided, or the URI resolver of this DOM node.
2030: * @param bRepaint if <code>true</code> or <code>null</code> the deserialized objects will be
2031: added to the parent's view via the parent object's <code>paintChild()</code> method.
2032: * @param objCache the cache to store the component XML documents in. If not provided, the cache
2033: of the server of this model object is used.
2034: * @param objResolver If this parameter is provided, <code>strURL</code> is resolved
2035: relative to it. Additionally, this resolver is stored as the URI resolver for this DOM node and its descendants.
2036: */
2037: public void loadAndCache(String strURL, boolean bRepaint,
2038: jsx3.app.Cache objCache, jsx3.net.URIResolver objResolver) {
2039: ScriptBuffer script = new ScriptBuffer();
2040: script.appendCall(getContextPath() + "loadAndCache", strURL,
2041: bRepaint, objCache, objResolver);
2042: getScriptProxy().addScript(script);
2043: }
2044:
2045: /**
2046: * Returns one of the meta data values stored at the top of the serialization file that this object was loaded from.
2047: * @param strKey the name of the meta data field, one of the keys in <code>META_FIELDS</code>.
2048: * @param callback the meta data value or empty string.
2049: */
2050: @SuppressWarnings("unchecked")
2051: public void getMetaValue(String strKey,
2052: org.directwebremoting.proxy.Callback<String> callback) {
2053: ScriptBuffer script = new ScriptBuffer();
2054: String callbackPrefix = "";
2055:
2056: if (callback != null) {
2057: callbackPrefix = "var reply = ";
2058: }
2059:
2060: script.appendCall(callbackPrefix + getContextPath()
2061: + "getMetaValue", strKey);
2062:
2063: if (callback != null) {
2064: String key = org.directwebremoting.extend.CallbackHelper
2065: .saveCallback(callback, String.class);
2066: script
2067: .appendCall("__System.activateCallback", key,
2068: "reply");
2069: }
2070:
2071: getScriptProxy().addScript(script);
2072: }
2073:
2074: /**
2075: * setS one of the meta data values stored at the top of a component's serialization file.
2076: * @param strKey the name of the meta data field, one of the keys in <code>META_FIELDS</code>
2077: * @param strValue the new value of the meta data field.
2078: */
2079: public void setMetaValue(String strKey, String strValue) {
2080: ScriptBuffer script = new ScriptBuffer();
2081: script.appendCall(getContextPath() + "setMetaValue", strKey,
2082: strValue);
2083: getScriptProxy().addScript(script);
2084: }
2085:
2086: /**
2087: * Called during deserialization of this object. This method provides a hook for initializing
2088: an object during deserialization since init() is not called. Called after this object has been instantiated but
2089: before its fields and children have been assembled. This method is called before this object is attached to the
2090: DOM, therefore getParent(), getServer(), getXML(), etc. return null.
2091: * @param objParent the parent of this object once it is attached to the DOM.
2092: * @param objServer the server that this DOM object will attach to.
2093: */
2094: public void onBeforeAssemble(jsx3.app.Model objParent,
2095: jsx3.app.Server objServer) {
2096: ScriptBuffer script = new ScriptBuffer();
2097: script.appendCall(getContextPath() + "onBeforeAssemble",
2098: objParent, objServer);
2099: getScriptProxy().addScript(script);
2100: }
2101:
2102: /**
2103: * Called during deserialization of this object. This method provides a hook for initializing
2104: an object during deserialization since init() is not called. Called after this object has been instantiated and
2105: after its fields and children have been assembled.This method is called before this object is attached to the
2106: DOM, therefore getParent(), getServer(), getXML(), etc. return null.
2107: * @param objParent the parent of this object once it is attached to the DOM.
2108: * @param objServer the server that this DOM object will attach to.
2109: */
2110: public void onAfterAssemble(jsx3.app.Model objParent,
2111: jsx3.app.Server objServer) {
2112: ScriptBuffer script = new ScriptBuffer();
2113: script.appendCall(getContextPath() + "onAfterAssemble",
2114: objParent, objServer);
2115: getScriptProxy().addScript(script);
2116: }
2117:
2118: /**
2119: * Called during deserialization of this object. This method provides a hook for initializing
2120: an object during deserialization since init() is not called. Called after this object has been
2121: instantiated and after it has been attached to the DOM. Methods overriding this method should usually finish
2122: with a call to jsxsuper().
2123:
2124: When a new branch is attached to the DOM, this method is executed on each node in the branch. The order is
2125: reverse-breadth-first meaning that child nodes are notified from oldest to youngest and before the parent node.
2126:
2127: This implementation of this method executes the on-after-deserialize script of this object.
2128: */
2129: public void onAfterAttach() {
2130: ScriptBuffer script = new ScriptBuffer();
2131: script.appendCall(getContextPath() + "onAfterAttach");
2132: getScriptProxy().addScript(script);
2133: }
2134:
2135: /**
2136: * Publishes an event to all subscribed objects.
2137: * @param objEvent the event, should have at least a field 'subject' that is the event id, another common field is 'target' (target will default to this instance)
2138: * @param callback the number of listeners to which the event was broadcast
2139: */
2140: @SuppressWarnings("unchecked")
2141: public void publish(jsx3.lang.Object objEvent,
2142: org.directwebremoting.proxy.Callback<Integer> callback) {
2143: ScriptBuffer script = new ScriptBuffer();
2144: String callbackPrefix = "";
2145:
2146: if (callback != null) {
2147: callbackPrefix = "var reply = ";
2148: }
2149:
2150: script
2151: .appendCall(callbackPrefix + getContextPath()
2152: + "publish", objEvent);
2153:
2154: if (callback != null) {
2155: String key = org.directwebremoting.extend.CallbackHelper
2156: .saveCallback(callback, Integer.class);
2157: script
2158: .appendCall("__System.activateCallback", key,
2159: "reply");
2160: }
2161:
2162: getScriptProxy().addScript(script);
2163: }
2164:
2165: /**
2166: * Subscribes an object or function to a type of event published by this object.
2167:
2168: As of version 3.4 a string value for objHandler is deprecated.
2169: * @param strEventId the event type(s).
2170: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2171: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2172: */
2173: public void subscribe(Object[] strEventId,
2174: jsx3.lang.Object objHandler,
2175: org.directwebremoting.proxy.CodeBlock objFunction) {
2176: ScriptBuffer script = new ScriptBuffer();
2177: script.appendCall(getContextPath() + "subscribe", strEventId,
2178: objHandler, objFunction);
2179: getScriptProxy().addScript(script);
2180: }
2181:
2182: /**
2183: * Subscribes an object or function to a type of event published by this object.
2184:
2185: As of version 3.4 a string value for objHandler is deprecated.
2186: * @param strEventId the event type(s).
2187: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2188: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2189: */
2190: public void subscribe(Object[] strEventId,
2191: org.directwebremoting.proxy.CodeBlock objHandler,
2192: org.directwebremoting.proxy.CodeBlock objFunction) {
2193: ScriptBuffer script = new ScriptBuffer();
2194: script.appendCall(getContextPath() + "subscribe", strEventId,
2195: objHandler, objFunction);
2196: getScriptProxy().addScript(script);
2197: }
2198:
2199: /**
2200: * Subscribes an object or function to a type of event published by this object.
2201:
2202: As of version 3.4 a string value for objHandler is deprecated.
2203: * @param strEventId the event type(s).
2204: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2205: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2206: */
2207: public void subscribe(String strEventId,
2208: org.directwebremoting.proxy.CodeBlock objHandler,
2209: org.directwebremoting.proxy.CodeBlock objFunction) {
2210: ScriptBuffer script = new ScriptBuffer();
2211: script.appendCall(getContextPath() + "subscribe", strEventId,
2212: objHandler, objFunction);
2213: getScriptProxy().addScript(script);
2214: }
2215:
2216: /**
2217: * Subscribes an object or function to a type of event published by this object.
2218:
2219: As of version 3.4 a string value for objHandler is deprecated.
2220: * @param strEventId the event type(s).
2221: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2222: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2223: */
2224: public void subscribe(String strEventId, String objHandler,
2225: String objFunction) {
2226: ScriptBuffer script = new ScriptBuffer();
2227: script.appendCall(getContextPath() + "subscribe", strEventId,
2228: objHandler, objFunction);
2229: getScriptProxy().addScript(script);
2230: }
2231:
2232: /**
2233: * Subscribes an object or function to a type of event published by this object.
2234:
2235: As of version 3.4 a string value for objHandler is deprecated.
2236: * @param strEventId the event type(s).
2237: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2238: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2239: */
2240: public void subscribe(String strEventId,
2241: jsx3.lang.Object objHandler, String objFunction) {
2242: ScriptBuffer script = new ScriptBuffer();
2243: script.appendCall(getContextPath() + "subscribe", strEventId,
2244: objHandler, objFunction);
2245: getScriptProxy().addScript(script);
2246: }
2247:
2248: /**
2249: * Subscribes an object or function to a type of event published by this object.
2250:
2251: As of version 3.4 a string value for objHandler is deprecated.
2252: * @param strEventId the event type(s).
2253: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2254: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2255: */
2256: public void subscribe(Object[] strEventId,
2257: org.directwebremoting.proxy.CodeBlock objHandler,
2258: String objFunction) {
2259: ScriptBuffer script = new ScriptBuffer();
2260: script.appendCall(getContextPath() + "subscribe", strEventId,
2261: objHandler, objFunction);
2262: getScriptProxy().addScript(script);
2263: }
2264:
2265: /**
2266: * Subscribes an object or function to a type of event published by this object.
2267:
2268: As of version 3.4 a string value for objHandler is deprecated.
2269: * @param strEventId the event type(s).
2270: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2271: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2272: */
2273: public void subscribe(String strEventId, String objHandler,
2274: org.directwebremoting.proxy.CodeBlock objFunction) {
2275: ScriptBuffer script = new ScriptBuffer();
2276: script.appendCall(getContextPath() + "subscribe", strEventId,
2277: objHandler, objFunction);
2278: getScriptProxy().addScript(script);
2279: }
2280:
2281: /**
2282: * Subscribes an object or function to a type of event published by this object.
2283:
2284: As of version 3.4 a string value for objHandler is deprecated.
2285: * @param strEventId the event type(s).
2286: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2287: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2288: */
2289: public void subscribe(Object[] strEventId,
2290: jsx3.lang.Object objHandler, String objFunction) {
2291: ScriptBuffer script = new ScriptBuffer();
2292: script.appendCall(getContextPath() + "subscribe", strEventId,
2293: objHandler, objFunction);
2294: getScriptProxy().addScript(script);
2295: }
2296:
2297: /**
2298: * Subscribes an object or function to a type of event published by this object.
2299:
2300: As of version 3.4 a string value for objHandler is deprecated.
2301: * @param strEventId the event type(s).
2302: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2303: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2304: */
2305: public void subscribe(String strEventId,
2306: jsx3.lang.Object objHandler,
2307: org.directwebremoting.proxy.CodeBlock objFunction) {
2308: ScriptBuffer script = new ScriptBuffer();
2309: script.appendCall(getContextPath() + "subscribe", strEventId,
2310: objHandler, objFunction);
2311: getScriptProxy().addScript(script);
2312: }
2313:
2314: /**
2315: * Subscribes an object or function to a type of event published by this object.
2316:
2317: As of version 3.4 a string value for objHandler is deprecated.
2318: * @param strEventId the event type(s).
2319: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2320: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2321: */
2322: public void subscribe(Object[] strEventId, String objHandler,
2323: String objFunction) {
2324: ScriptBuffer script = new ScriptBuffer();
2325: script.appendCall(getContextPath() + "subscribe", strEventId,
2326: objHandler, objFunction);
2327: getScriptProxy().addScript(script);
2328: }
2329:
2330: /**
2331: * Subscribes an object or function to a type of event published by this object.
2332:
2333: As of version 3.4 a string value for objHandler is deprecated.
2334: * @param strEventId the event type(s).
2335: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2336: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2337: */
2338: public void subscribe(Object[] strEventId, String objHandler,
2339: org.directwebremoting.proxy.CodeBlock objFunction) {
2340: ScriptBuffer script = new ScriptBuffer();
2341: script.appendCall(getContextPath() + "subscribe", strEventId,
2342: objHandler, objFunction);
2343: getScriptProxy().addScript(script);
2344: }
2345:
2346: /**
2347: * Subscribes an object or function to a type of event published by this object.
2348:
2349: As of version 3.4 a string value for objHandler is deprecated.
2350: * @param strEventId the event type(s).
2351: * @param objHandler if an object, the instance to notify of events (objFunction is required); if a string, the JSX id of the instance to notify of events (objFunction is required), must exist in the same Server; if a function, the function to call to notify of events (objFunction ignored)
2352: * @param objFunction if objHandler is a string or object then the function to call on that instance. either a function or a string that is the name of a method of the instance
2353: */
2354: public void subscribe(String strEventId,
2355: org.directwebremoting.proxy.CodeBlock objHandler,
2356: String objFunction) {
2357: ScriptBuffer script = new ScriptBuffer();
2358: script.appendCall(getContextPath() + "subscribe", strEventId,
2359: objHandler, objFunction);
2360: getScriptProxy().addScript(script);
2361: }
2362:
2363: /**
2364: * Unsubscribe an object or function from an event published by this object.
2365:
2366: As of version 3.4 a string value for objHandler is deprecated.
2367: * @param strEventId the event type(s).
2368: * @param objHandler the value of objHandler passed to subscribe
2369: */
2370: public void unsubscribe(Object[] strEventId,
2371: org.directwebremoting.proxy.CodeBlock objHandler) {
2372: ScriptBuffer script = new ScriptBuffer();
2373: script.appendCall(getContextPath() + "unsubscribe", strEventId,
2374: objHandler);
2375: getScriptProxy().addScript(script);
2376: }
2377:
2378: /**
2379: * Unsubscribe an object or function from an event published by this object.
2380:
2381: As of version 3.4 a string value for objHandler is deprecated.
2382: * @param strEventId the event type(s).
2383: * @param objHandler the value of objHandler passed to subscribe
2384: */
2385: public void unsubscribe(Object[] strEventId, String objHandler) {
2386: ScriptBuffer script = new ScriptBuffer();
2387: script.appendCall(getContextPath() + "unsubscribe", strEventId,
2388: objHandler);
2389: getScriptProxy().addScript(script);
2390: }
2391:
2392: /**
2393: * Unsubscribe an object or function from an event published by this object.
2394:
2395: As of version 3.4 a string value for objHandler is deprecated.
2396: * @param strEventId the event type(s).
2397: * @param objHandler the value of objHandler passed to subscribe
2398: */
2399: public void unsubscribe(String strEventId, String objHandler) {
2400: ScriptBuffer script = new ScriptBuffer();
2401: script.appendCall(getContextPath() + "unsubscribe", strEventId,
2402: objHandler);
2403: getScriptProxy().addScript(script);
2404: }
2405:
2406: /**
2407: * Unsubscribe an object or function from an event published by this object.
2408:
2409: As of version 3.4 a string value for objHandler is deprecated.
2410: * @param strEventId the event type(s).
2411: * @param objHandler the value of objHandler passed to subscribe
2412: */
2413: public void unsubscribe(String strEventId,
2414: jsx3.lang.Object objHandler) {
2415: ScriptBuffer script = new ScriptBuffer();
2416: script.appendCall(getContextPath() + "unsubscribe", strEventId,
2417: objHandler);
2418: getScriptProxy().addScript(script);
2419: }
2420:
2421: /**
2422: * Unsubscribe an object or function from an event published by this object.
2423:
2424: As of version 3.4 a string value for objHandler is deprecated.
2425: * @param strEventId the event type(s).
2426: * @param objHandler the value of objHandler passed to subscribe
2427: */
2428: public void unsubscribe(Object[] strEventId,
2429: jsx3.lang.Object objHandler) {
2430: ScriptBuffer script = new ScriptBuffer();
2431: script.appendCall(getContextPath() + "unsubscribe", strEventId,
2432: objHandler);
2433: getScriptProxy().addScript(script);
2434: }
2435:
2436: /**
2437: * Unsubscribe an object or function from an event published by this object.
2438:
2439: As of version 3.4 a string value for objHandler is deprecated.
2440: * @param strEventId the event type(s).
2441: * @param objHandler the value of objHandler passed to subscribe
2442: */
2443: public void unsubscribe(String strEventId,
2444: org.directwebremoting.proxy.CodeBlock objHandler) {
2445: ScriptBuffer script = new ScriptBuffer();
2446: script.appendCall(getContextPath() + "unsubscribe", strEventId,
2447: objHandler);
2448: getScriptProxy().addScript(script);
2449: }
2450:
2451: /**
2452: * Unsubscribes all subscribed objects to a type of event published by this object.
2453: * @param strEventId the event type
2454: */
2455: public void unsubscribeAll(String strEventId) {
2456: ScriptBuffer script = new ScriptBuffer();
2457: script.appendCall(getContextPath() + "unsubscribeAll",
2458: strEventId);
2459: getScriptProxy().addScript(script);
2460: }
2461:
2462: }
|