I am new to SmartClient, I am tring to use SmartClient’s TreeGrid component. I am setting a list of java objects in dsResponse . The list got all objects. But I am getting an error as
" “rootValue” is null or not an object ". What I am doing wrong? am I missing anything in the code?
Thanks in advance.
DataSource.create({
ID:“bomData”,
parentID: “parentPartNo”,
fields:{
Id:{name:“id”,type:“text”,title:“ID”, length:128, primaryKey:true},
ParentPartNo:{name:“parentPartNo”,type:“text”, title:“Parent Part No”, primaryKey:true},
PartNo:{name:“name” ,type:“text” , title:“Part No” }
});
isc.RPCManager.actionURL = “<c:url value=‘/frames/bomViewOperations.jsp?’/>”;
isc.TreeGrid.create({
ID:“boundNewList”,
width:900, height:300,
dataSource:bomData,
modelType:“parent”,
rootValue:“ParentPartNo”,
fields:[
{name:“Id”},
{name:“ParentPartNo”},
{name:“PartNo”}
]
});
--------------bomViewOperations.jsp-----
RPCManager rpc;
try {
rpc = new RPCManager(request, response, out);
} catch (ClientMustResubmitException e) {
return;
}
for(Iterator i = rpc.getRequests().iterator(); i.hasNext()
{
Object req = i.next();
if(req instanceof RPCRequest)
throw new Exception(“This example expects only DSRequests”);
DSRequest dsRequest = (DSRequest)req;
String dsName = dsRequest.getDataSourceName();
if(!“bomData”.equals(dsName)) {
rpc.send(dsRequest, dsRequest.execute());
continue;
}
DataSource bomData = dsRequest.getDataSource();
DSResponse dsResponse = new DSResponse();
dsResponse.setSuccess();
String operation = dsRequest.getOperationType();
if(operation.equals(DataSource.OP_FETCH)) {
HttpSession sess = request.getSession(false) ;
ServletContext context = sess.getServletContext();
String id = request.getParameter("id");
id = "2";
String bomName = request.getParameter("BomName");
ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext (context);
ImportedBomManager mgr = (ImportedBomManager) ctx.getBean("importedBomManager");
ImportedBom bom = null;
if (id != null)
bom = mgr.getImportedBom(id);
else if (bomName != null)
{
bom = new ImportedBom();
bom.setName(bomName);
List boms = mgr.getImportedBoms(bom);
if (boms.size() > 0)
{
bom = (ImportedBom) boms.get(0);
id = bom.getId().toString();
}
}
String partNo = bom.getPartNo();
if (partNo == null || partNo.length() == 0)
return;
// Once everything works fine change "partNo" to
//String parentID = (String)dsRequest.getCriteria().get("parentID");
dsResponse.setData(getChildren(bom,partNo,ctx));
}
else {
throw new Exception("Operation: " + operation + " not implemented.");
}
// match the response to the request
rpc.send(dsRequest, dsResponse);
}