Main application page

I am designing a main application page. It will look similar to SC Feature Explorer. In the left pane I want to run a tree with all apps. names. Then when I click on a name I want to run http://…/name in the right pane. I have two questions: How to execute an http link from a node click and how send this app into the right pane to run in it?

Thanks

Take a look at the docs for the ViewLoader class. This is the recommended way to load SmartClient components from the Server into a running application.

A simple sample would be so helpful.

There is an example on the website.

As far as triggering view loading, use normal TreeGrid events, such as nodeClick(), to create a ViewLoader with a viewURL based on the data in the clicked-on node, then add it to your right-hand pane.

Yes, it is clear now. About creating views for loading. In docs it says that to load JS code as a view it should not have any tags. Also (as far as I understand) All components should be added to a view using addProperties. What do I do with functions? Should I add them all to my main program? Potentially to the one that loads Application Tree?

The ViewLoader can target an arbitrary URL. That URL can go to a static or dynamic page. What’s important is that what is ultimately returned as the response to that request must be a set of SmartClient components. So the target can be, for example, a JSP or ASP page that generates SmartClient components dynamically.

The SmartClient components that are returned as part of the view have exactly the same format and semantics as the ones you create on your main page, so you can provide method overrides on them an you can have functions in global scope as well. So, for example, this is legal in a view returned to a ViewLoader:

function foo() { alert(1); }

isc.Button.create({
    title: "Click me",
    click: foo
});

As is this:

isc.Button.create({
    title: "Click me",
    click: function () { alert(1); }
});

I have been working on my ViewLoader solution. I have some things working but more of a testing, not a real code.
Here is what works:

isc.DynamicForm.create({
	ID:"frmFileIdAction",
    autoDraw:false,
    dataSource: FileIdAction,
    width: "100%",
    numCols: 4,
    colWidths: ["5%", "10%", "15%", "*"],
    fields:[
        {name: "fileid", title: "Files", valueField: "id", displayField: "filenumber",
         type: "select", optionDataSource:"FileList", required:true,  editorType: "comboBox"},
        {name: "open", title: "Open", type: "button", click: "OpenFile()", startRow:false, endRow:false}/*,
        {name: "open", title: "Open", type: "button", click: "alert(frmGeneral.getValue('division'))", startRow:false, endRow:false}*/
      ]    
});

isc.CauseLayout.create({
    ID:"Cause",   
    showEdges:true, 
    autoDraw:false 
    // backgroundColor:"#63CCCC"

});

isc.TabSet.create({
	ID:"maintabSet",
    autoDraw:false,
    width: "100%",
    height: "100%",
    disabled: true,
    tabs: [{
        ID: "general",
        title: "General",
        width:40,
        pane: frmFileIdAction
    },
    {
        ID: "cause",
        title: "Cause",
        width:40,
        pane: Cause
    }            
    ]
});
/*isc.VLayout.create({
	ID: "MainWindow",
	autoDraw:false,
    width:"100%", height:"100%",
    members:[
       maintabSet     
    ] 
});*/
//MainWindow.draw();
maintabSet.draw();

That works after this command that loads this code from as a standalone JS file:
AppPane.setViewURL(‘somefile.js’);

If I uncomment VLayout I am getting an error “AppPane is null or not an object”. Also in the working scenario if I replace “frmFileIdAction” with a form name “frmGeneral” from a file that is loaded in the main program like this:
<SCRIPT SRC=general.js></SCRIPT>
then it also fails with the same error.
Can I have some help here?

Hi Mark,

SmartClient doesn’t have an “AppPane” class or reference any variable called “AppPane”, so this is a crash somewhere in your code. We recommend taking the approaches listed under the Debugging topic.

Yes, it is my code. And AppPane is defined like this:
isc.ViewLoader.create({
ID:“AppPane”,
showEdges:true,
loadingMessage:“”,
backgroundColor:“#8DB6CD”,
autoDraw:false
})
My question why it does not work with VLayout, or with a form from an external file.

I am trying to debug as you had suggested. Here is the result of my failed execution:
16:02:19.813:INFO:Log:initialized
16:02:20.563:INFO:Log:isc.Page is loaded
16:02:25.064:DEBUG:DynamicForm:isc_DynamicForm_31:Drawing FormItem: [TextItem ID:isc_TextItem_32 name:causecode1]
16:02:25.080:DEBUG:DynamicForm:isc_DynamicForm_31:Drawing FormItem: [TextItem ID:isc_TextItem_33 name:causecode2]
16:02:25.393:WARN:DynamicForm:isc_DynamicForm_31:ignoring bad or negative height: NaN
Canvas.getDelta(_1=>“height”, _2=>NaN, _3=>20)
Canvas.resizeTo(_1=>null, _2=>NaN, _3=>undef, _4=>undef)
Canvas.setHeight(_1=>NaN)
“this.resizeTo(null,_1)”
Layout.setMemberBreadth(_1=>[DynamicForm ID:isc_DynamicForm_31], _2=>NaN)
Layout.autoSetBreadth(_1=>[DynamicForm ID:isc_DynamicForm_31])
“if(!this.shouldAlterBreadth(_1))return false;var _2=this.$2c;this.$2c=true;this.setMemberBreadth(_1,this.getBreadth()-this.$17());this.$2c=_2;return true”
Layout.addMembers(_1=>Array[5], _2=>undef, _3=>undef)
CauseLayout.initWidget()
Canvas.init(_1=>Obj{ID:Cause}, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef)
Class.completeCreation(_1=>Obj{ID:Cause}, _2=>undef, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef, _11=>undef, _12=>undef, _13=>undef)
Class.create(_1=>Obj{ID:Cause}, _2=>undef, _3=>undef, _4=>undef, _5=>undef, _6=>undef, _7=>undef, _8=>undef, _9=>undef, _10=>undef, _11=>undef, _12=>undef, _13=>undef)
“var _14=this.createRaw();_14=_14.completeCreation(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13);return _14”

16:02:25.658:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [DateItem ID:isc_DateItem_0 name:dateofaccident]
16:02:25.674:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_2 name:otherrailroadinvolved]
16:02:25.689:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [TextItem ID:isc_TextItem_3 name:otherfilenumber]
16:02:25.705:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_4 name:railroadrespfortrack]
16:02:25.721:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [TextItem ID:isc_TextItem_5 name:respfilenumber]
16:02:25.721:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [TimeItem ID:isc_TimeItem_6 name:timeofaccident]
16:02:25.721:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_7 name:yard]
16:02:25.736:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_8 name:division]
16:02:25.752:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_9 name:subdivision]
16:02:25.752:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_10 name:location]
16:02:25.768:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [TextItem ID:isc_TextItem_11 name:milepost]
16:02:25.768:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_12 name:nearestcitytown]
16:02:25.783:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_13 name:state]
16:02:25.799:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [TextItem ID:isc_TextItem_14 name:industrynum]
16:02:25.799:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SpinnerItem ID:isc_SpinnerItem_15 name:specificsite]
16:02:25.815:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_16 name:typeoftrack]
16:02:25.815:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_17 name:weather]
16:02:25.830:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [TextItem ID:isc_TextItem_18 name:temperature]
16:02:25.830:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_19 name:visibility]
16:02:25.846:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [SelectItem ID:isc_SelectItem_20 name:typeofaccident]
16:02:25.846:DEBUG:DynamicForm:frmGeneral:Drawing FormItem: [ButtonItem ID:isc_ButtonItem_21 name:generalProcess]
16:02:28.471:WARN:Log:Error:
‘‘this.masterElement.overflow’ is null or not an object’
in http://localhost/beltrailway/accidents/forms/main.htm
at line 1579
BackMask.draw(_1=>undef, _2=>undef, _3=>undef)
“if(!this.readyToDraw())return this;this.invokeSuper(isc.BackMask,this.$nx,_1,_2,_3);if(this.masterElement.overflow==isc.Canvas.VISIBLE)this.masterElement.$qh();return this”
ViewLoader.setView(_1=>[BackMask ID:isc_BackMask_62])
ViewLoader.$35t(_1=>Array[64])
callback(globals=>Array[64])
“AppPane.$35t(globals)”
Class.fireCallback(_1=>“AppPane.$35t(globals)”, _2=>Array[1], _3=>Array[1], _4=>undef, _5=>undef) on [Class Class]
Class.$de()
Class.globalEvalWithCapture(_1=>“javascript:isc.showConsole()
isc.Dyna…”[1365], _2=>“AppPane.$35t(globals)”, _3=>Obj)
ViewLoader.$35r(_1=>Obj, _2=>Obj, _3=>“javascript:isc.showConsole()
isc.Dyna…”[1365])
callback(operationResult=>Obj, data=>“javascript:isc.showConsole()
isc.Dyna…”[1365], context=>Obj, transaction=>Obj, rpcRequest=>Obj, rpcResponse=>Obj, dsRequest=>Obj, dsResponse=>Obj, callbackID=>undef)
“AppPane.$35r(rpcRequest, rpcResponse, data)”
** recursed on Class.fireCallback

There is an error there. But how do I work with this error? What exactly does it mean? How would I get from that error message back to my code with the actual error?

Hi Mark,

That’s a different crash, which you can avoid by calling setView() explicitly, as suggested under the docs for ViewLoader, instead of relying on ViewLoader’s autodetection to find the View.