I want to integrate as much of the SmartClient 8.0 server framework as possible into my Liferay 5.2 portal server environment. (Liferay 5.0 is a JSR 286 compliant portal server.) My goal is to get a SmartClient TreeGrid working within a portlet bound to a dynamic data source. I'd like to use the call to the SmartClient server's IDACall servlet and just write a custom datasource Java class but I cannot becuase the datasource for the tree grid needs access to the portlet's session to generate its data.
The problem of needing to access the portlet's session from an AJAX request is nicely illustrated here:
http://www.ibm.com/developerworks/websphere/library/techarticles/0803_hepper/0803_hepper.html#N10186
I want to solve this problem by having my SmartClient TreeGrid call its containing portlet's resourceURL with all of its fetchData requests as the article suggests. To do this here is my planned approach using the SmartClient RPCManager on both the client and the server side. Can someone from Isomorphic please let me know if you know of any better approach (possibly integrating the complete functionality of the IDACall servlet into the portlet architecture)?
UI jsp code:
Portlet serveResource() method which is called by the resource URL looks like this:
Thank you,
Jeff
The problem of needing to access the portlet's session from an AJAX request is nicely illustrated here:
http://www.ibm.com/developerworks/websphere/library/techarticles/0803_hepper/0803_hepper.html#N10186
I want to solve this problem by having my SmartClient TreeGrid call its containing portlet's resourceURL with all of its fetchData requests as the article suggests. To do this here is my planned approach using the SmartClient RPCManager on both the client and the server side. Can someone from Isomorphic please let me know if you know of any better approach (possibly integrating the complete functionality of the IDACall servlet into the portlet architecture)?
UI jsp code:
Code:
isc.DataSource.create({ ID: "pivotDS", fields: [ { name: "nodeid", type:"integer", primaryKey:true, hidden:true } ,{ name: "parentnodeid", type:"integer", foreignKey:"pivotDS.nodeid", hidden:true } ,{ name: "name" } ,{ name: "sec_id" } ,{ name: "total_qty" } ,{ name: "exposure_percent" } ,{ name: "total_amt" } ,{ name: "target_weight" } ,{ name: "deviation" } ] }); isc.RPCManager.actionURL = '<portlet:resourceURL id="AJAX_RESPONSE" escapeXml="false" />';
Code:
public void serveResource(ResourceRequest request, ResourceResponse response) { String resourceID = request.getResourceID(); if(!resourceID.equals("AJAX_RESPONSE")){ super.serveResource(request, response); return; } RPCManager rpc = null; try { rpc = new RPCManager((HttpServletRequest)request, (HttpServletResponse)response); } 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(!"pivotDS".equals(dsName)) { rpc.send(dsRequest, dsRequest.execute()); continue; } String operation = dsRequest.getOperationType(); if(operation.equals(DataSource.OP_FETCH)) { List resultData = getResultData(request); DSResponse dsResponse = new DSResponse(); dsResponse.setSuccess(); dsResponse.setData(resultData); } else { dsResponse.setFailure(); dsResponse.setData("Unsupported operationType: " + operation); } rpc.send(dsRequest, dsResponse); } }
Jeff
Comment