Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to relate the isc javascript call documented in the javadoc to a class

    For example, the javadoc for DynamicForm says

    Code:
    To create a DynamicForm, set fields  to an Array of Objects describing the FormItems you want to use. For example:
    
    isc.DynamicForm.create({
     fields:[
      {name:"userName", type:"text"},  // creates a TextItem
      {name:"usState", type:"select"}  // creates a SelectItem
     ]
    })
    I don't understand how to relate this javascript segment to the class.
    How do I feed this javascript segment into an instance of DynamicForm.

    Not just DynamicForm. For example, ValuesManager, etc, where their javadoc provides examples of usage in terms of isc javascript calls. So - how should I associate an isc javascript call with a Smart GWT class?

    Another example is the javadoc of setDataPath of Canvas gives a lot of isc javascript calls. How do I feed those isc calls in as arguments for setDataPath? Or should the question be, how do I get setDataPath to run those isc calls in the javadoc examples?

    #2
    From JSOHelper :

    Code:
    /**
     * Evaluate the passed string as Javascript
     *
     * @param jsFrag the string to evaluate
     * @return the JavaScriptObject upon evaluation
     */
    public static native JavaScriptObject eval(String jsFrag) /*-{
        if(!($wnd.isc.startsWith(jsFrag, '(') && $wnd.isc.endsWith(jsFrag, ')'))) {
            jsFrag = '(' + jsFrag + ')';
        }
        return eval(jsFrag);
    }-*/;
    Call the above method and construct a new DynamicForm(jso) where jso is the return value of the above eval call. Note that if your JS fragment is of the form isc.DynamicForm.create(..) instead of $wnd.isc.DynamicForm.create(..) you'll need to have the JSNI method return :

    Code:
    return $wnd.eval(jsFrag)
    instead.

    Sanjiv

    Comment


      #3
      Thanks Sanjiv for the response, but following your advice, I encountered an error.

      I did the JSOHelper.eval twice. First, for ValuesManager and the second for DynamicForm.

      First I obtained the JavascriptObject from:
      Code:
      $wnd.isc.ValuesManager.create({
        ID:'vm',
        values: {
          companyName:"Some Company",
          address:{
            street:"123 Main Street",
            city:"New York",
            state:"NY"
          }
        }
      })
      Which I fed into
      Code:
      ValuesManager vm = new ValuesManager(jso);
      I ran the page and there was no error. Debug shows that vm was created successfully. Then I further inserted a second eval (that runs after the first eval which creates ValuesManager successfully).

      Code:
      $wnd.isc.DynamicForm.create({
        valuesManager:"vm",
        dataPath:"address",
        fields: [
          {name : "street",
           title: "Street",
           type: "text",
           required: true,
           defaultValue: "st"
          },
          {name: "city",
           title: "City",
           required: true,
           type: "text",
           defaultValue: "#"
          },
          {name: "state",
           title: "State or Province",
           required: true,
           type: "text"
          }
        ]
      })
      Unfortunately, the second eval created a stack dump:

      Code:
      Uncaught exception escaped : com.google.gwt.core.client.JavaScriptException
      (TypeError): _2.duplicate is not a function
       fileName: http://127.0.0.1:8201/Main/sc/modules/ISC_Core.js
       lineNumber: 3232
       stack: isc_Canvas_bindToDataSource([object Array])@http://127.0.0.1:8201/Main/sc/modules/ISC_Core.js:3232
      isc_DynamicForm_setItems([object Array],true)@http://127.0.0.1:8201/Main/sc/modules/ISC_Forms.js:253
      isc_DynamicForm_initWidget([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://127.0.0.1:8201/Main/sc/modules/ISC_Forms.js:240
      isc_Canvas_init([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://127.0.0.1:8201/Main/sc/modules/ISC_Core.js:1867
      isc_Class_completeCreation([object Object],(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0),(void 0))@http://127.0.0.1:8201/Main/sc/modules/ISC_Core.js:335
      isc_c_Class_create([object Object])@http://127.0.0.1:8201/Main/sc/modules/ISC_Core.js:205
      ("($wnd.isc.DynamicForm.create({\n  valuesManager:\"vm\",\n  dataPath:\"address\",\n  fields: [\n    {name : \"street\",\n     title: \"Street\",\n     type: \"text\",\n     required: true,\n     defaultValue: \"st\"\n    },\n    {name: \"city\",\n     title: \"City\",\n     required: true,\n     type: \"text\",\n     defaultValue: \"#\"\n    },\n    {name: \"state\",\n     title: \"State or Province\",\n     required: true,\n     type: \"text\"\n    }\n  ]\n})\n)")@http://127.0.0.1:8201/Main/hosted.html?Main:73
      ("($wnd.isc.DynamicForm.create({\n  valuesManager:\"vm\",\n  dataPath:\"address\",\n  fields: [\n    {name : \"street\",\n     title: \"Street\",\n     type: \"text\",\n     required: true,\n     defaultValue: \"st\"\n    },\n    {name: \"city\",\n     title: \"City\",\n     required: true,\n     type: \"text\",\n     defaultValue: \"#\"\n    },\n    {name: \"state\",\n     title: \"State or Province\",\n     required: true,\n     type: \"text\"\n    }\n  ]\n})\n)")@http://127.0.0.1:8201/Main/hosted.html?Main:54
      ("($wnd.isc.DynamicForm.create({\n  valuesManager:\"vm\",\n  dataPath:\"address\",\n  fields: [\n    {name : \"street\",\n     title: \"Street\",\n     type: \"text\",\n     required: true,\n     defaultValue: \"st\"\n    },\n    {name: \"city\",\n     title: \"City\",\n     required: true,\n     type: \"text\",\n     defaultValue: \"#\"\n    },\n    {name: \"state\",\n     title: \"State or Province\",\n     required: true,\n     type: \"text\"\n    }\n  ]\n})\n)")@http://127.0.0.1:8201:365
      @:0
      ([object GWTJavaObject],20447234,[object XMLHttpRequest])@http://127.0.0.1:8201/Main/hosted.html?Main:56
      ([object Event])@http://127.0.0.1:8201:62
      ((function () {__gwt_makeJavaInvoke(1)(handler, 20447234, _this);}),[object XMLHttpRequest],[object Object])@http://127.0.0.1:8201:66
      @:0
      (null,106,(function () {__gwt_makeJavaInvoke(1)(handler, 20447234, _this);}),[object XMLHttpRequest],[object Object])@http://127.0.0.1:8201/Main/hosted.html?Main:56
      ([object Event])@http://127.0.0.1:8201:28

      Comment


        #4
        Any suggestions on where to find more documentation on isc would be appreciated. I am trying to manipulate some of the finer display features on menu bars and menu lists and it would be helpful to know where a list of properties and corresponding values are for various object such as isc.Menu or isc.IMenu. Thank you.

        Comment

        Working...
        X