Frustrated newbie

I would like to have a tree that links to some jsp pages for its data. I have read the quick start guide several times. I have read through the reference guide serveral times. I have read through all the examples in the feature explorer several times. I have scanned through the postings. I have spent 3 days now looking at documentation and trying to figure out how to make a tree work with some jsp pages. I am just not getting it. I am expecting find some documentation that says something like “your jsp page will receive these parameters. your jsp page should return this data. your javascript should create the RESTDatasource like this. etc.” Instead i find pages that give me a general overview of the features with links to what i would expect to be more detailed examples. But, when i follow the links they lead to more general overviews with no real detailed explanations or examples. I like what i see, this product looks like it is very powerful and well thought out. I just cant seem to get an example that i need. Basically i want a tree control that makes requests to a jsp page for its data. I would like my jsp page to be able to write back JSON data. Any chance i could get an example that shows the html page with the tree and datasource defined, and a jsp page returning the JSON data for all the different methods? fetch, add, update, remove?
thanks.

Hi Derek,

To be fair, SmartClient ships with over 400 running examples, and countless example code snippets in the docs. The RestDataSource docs do show an example of a URL your JSP would receive, an example of DataSource creation, and several sample JSON responses. Showing every possible combination of usage would produce a blizzard of examples that would probably be more difficult to navigate.

That said, here’s an example of a tree loading from JSON to get you started.

This is the code from the Tree loading XML example with small changes in bold.

The JSON response for a fetch, shown afterwards, is taken from the Tree loading with children Arrays example.

isc.DataSource.create({
    ID:"employees",
    [b]dataURL:"/employeeData.js",
    dataFormat:"json",[/b]
    fields:[
        {type:"text", title:"Name", length:128, name:"Name"},
        {type:"integer", required:true, title:"Employee ID", primaryKey:true, name:"EmployeeId"},
        {type:"integer", required:true, title:"Manager", rootValue:"1", name:"ReportsTo"},
        {type:"text", title:"Title", length:128, name:"Job"},
        {type:"text", title:"Email", length:128, name:"Email"},
        {type:"text", title:"Employee Type", length:40, name:"EmployeeType"},
        {type:"text", title:"Status", length:40, name:"EmployeeStatus"},
        {type:"float", title:"Salary", name:"Salary"},
        {type:"text", title:"Org Unit", length:128, name:"OrgUnit"},
        {type:"text", title:"Gender", length:7, name:"Gender", valueMap:["male", "female"]},
        {type:"text", title:"Marital Status", length:10, name:"MaritalStatus",
                       valueMap:["married", "single"]},
        {childrenProperty:true, name:"directReports"}
    ]
});


isc.TreeGrid.create({
    ID: "employeeTree",
    width: 500,
    height: 400,
    dataSource: "employees",
    [b]loadDataOnDemand:false,[/b]
    autoFetchData: true,
    nodeIcon:"icons/16/person.png",
    folderIcon:"icons/16/person.png",
    showOpenIcons:false,
    showDropIcons:false,
    closedIconSuffix:""
});
    {EmployeeId:"4", Name:"Charles Madigen", directReports: [
        {EmployeeId:"188", Name:"Rogine Leger"},
        {EmployeeId:"189", Name:"Gene Porter", directReports: [
            {EmployeeId:"265", Name:"Olivier Doucet"},
            {EmployeeId:"264", Name:"Cheryl Pearson"}
        ]}
    ]}

Frustrated Newbie

Please dont take my post as a dig. I am very impressed with your product. I agree that showing every possible example would be unreasonable. After 3 days of looking at documentation and not finding the specific details i wanted i was getting quite frustrated. I finally have something working. Here is the code if anyone in future needs an example like i did.

HTML

var mydata = isc.RestDataSource.create({
    ID:"mydata",
    dataFormat:"json",
    dataURL: "/testrest.jsp",
    fields:[
        {title:"Description", name:"description"},
        {title:"ID", name:"id", primaryKey:true},
        {title:"ParentID", name:"parentID", foreignKey:"mydata.id", rootValue:0}
    ]
});
var tree = isc.TreeGrid.create({
        ID: "employeeTree",
        width: "500",
        height: "400",
        showResizeBar: "true",
        showOpenIcons:false,
        showDropIcons:false,
        closedIconSuffix:"",
        dataSource: "mydata",
        autoFetchData: true,
        fields: [
          {name: "description" },
          {name: "id" }
        ]
});

JSP

<%
String parentId = request.getParameter("parentID");
String operationType = request.getParameter("_operationType");
String dataSource = request.getParameter("_dataSource");
System.out.println("parentId: " + parentId + ", operationType: " + operationType + ", dataSource: " + dataSource);

if ( parentId != null && parentId.trim().equalsIgnoreCase("0") ) {
%>
  { response: {
      status: 0,
      data: [
        { id: 1, parentId: 0, description: "abc" }
      ]
    }
  }
<%
}
else {
%>
  { response: {
      status: 0,
      data: [
      ]
    }
  }
<%
}
%>

Thanks for posting that sample