8/18/2025 1:27:27 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
|
|
|
|
Loading and displaying data asynchronously.
Posted: 23 Apr 09 10:06 AM
|
Hi!
I have the following scenario. There's some data from the db I need to display on the web client. This data could potentially take a while to be calculated, so I' looking into loading it asynchronously. I have a few questions:
1) What would be the easiest way of doing this? What would you use? There are some technologies that come to mind: AJAX, JSON, JQuery, REST, ATOM and the list goes on. Its a big puzzle for me at this point.
2) Am I right in thinking that whatever I use, I'll have to use some kind of external service to get the data? Meaning probably a web service of sorts.
3) What about sdata? Would it work with this? Can I expose business rules through sdata? How do I pass parameters to the business rules like this?
4) Regarding the client, I'll probably need to write javascript code to load the data behind the scenes. Can this be done inside AA? Do I need to do this in VS?
5) Any gotchas I should be aware of when doing something like this?
Thanks. |
|
|
|
Re: Loading and displaying data asynchronously.
Posted: 23 Apr 09 10:29 AM
|
Hi,
1) What would be the easiest way of doing this? What would you use? There are some technologies that come to mind: AJAX, JSON, JQuery, REST, ATOM and the list goes on. Its a big puzzle for me at this point.
I would use XmlHttpRequest (AJAX) in javascript to do it...I havent got the code to do what you require but there many articles on the internet to point you in the right direction. Check the following link and click Next...Next 
http://www.w3schools.com/Ajax/ajax_browsers.asp
You can consume web services through the object (and asynchronously) so you can either create your own or expose a business rule through sdata. I have no idea if this is possible as I havent had must to do with this yet - I would hope that you can.
2) A web service would be best, but you could just do a normal ASPX page and call it through an AJAX call. As long as the page just returns what you want you can just get the ResponseText of the page.
3) Above..
4) Yes you will definitely need javascript to initiate a client side asynchronous call. You can write this in a quickformload and "attach" it to the page. Basically build up a string of your javascript and use the client script manager to "attach" the code, like:
//ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "JSCR", "MYSCRIPTSTRING",true); OR to register a script block that you can call later (not on the client page load):
// ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "JSCR", sb.ToString(), false);
5) Cant think of any - only if you are going to have cross browser access to your website, make sure you cater for this in the setting up of your xmlhttp object. The link I posted above tells you how....
Cheers, Nick |
|
|
|
Re: Loading and displaying data asynchronously.
Posted: 23 Apr 09 11:03 AM
|
I am not sure if it is possible to do in AA, but I do know that it is relatively easy to do using a custom web service called from a custom smart part. Basically: 1. your javascript on the smart part calls up your custom ASMX, providing it with the entity id -> this part is very easy as ASP.NET can generate the 2. your ASMX receives this and return the result -> all the serialization will be handled by ASP.NET so there isn't much to that... your result has to be serializable though - do not return a Saleslogix entity as .NET will slurp all the relationships and generate a huge payload 3. your javascript callback gets this result and populate the form controls with its properties -> this is actually often the trickiest part, as ASP.NET will obfuscate the control ids
There is an example - a bit different but same basic idea - at http://blog.chivinou.net/2009/03/12/ajax-script-services-on-slxweb
I don't think you can expose business rules with SDATA, though you may be able to with a mashup... you may have to parse the XML inside of your Javascript in that case though - to me, that sounds like more trouble than writing a custom ASMX, but maybe not - I have not tried.
I think technically you could find a way to cram the whole script in AA, using a C# snippet... might be tough to edit though.
Make sure you get Fiddler and FireBug (or similar tools) as they will help a lot when troubleshooting AJAX calls!
Finally a quick terminology recap: * AJAX -> when you call a web service from Javascript * JSON -> a particular format used for AJAX calls (instead of XML) * JQuery -> a Javascript library, very nice for UI effects, but you don't have to worry about it in this scenario (you can use it for custom AJAX calls but not needed here) * REST -> denotes a type of web service, typically easy(-er) to call from Javascript (as opposed to SOAP) * ATOM/RSS -> they refer to standard XML formats. More work to parse than JSON. Typically used for feeds. * ASMX -> a "traditional" ASP.NET web service (you'll want to make sure you write it as a "ScriptService" in order to call it from Javascript)
Use all 6 in a single sentence: I use jQuery to make JSON-encoded AJAX calls to my REST web service implemented with an ASMX (sorry, could not find a place for ATOM there). |
|
|
|
Re: Loading and displaying data asynchronously.
Posted: 23 Apr 09 12:17 PM
|
Thanks to both. I know have more data to start working and investigating. At least now I know where I'm headed.
Regarding ATOM, i know it's used for RSS feeds. I read somewhere that sdata returns the info in ATOM format. |
|
|
|
Re: Loading and displaying data asynchronously.
Posted: 23 Apr 09 5:56 PM
|
It does... I guess it is to simplify parsing in some tools... Actually for all I know it might be possible to return JSON from sdata - I really have not looked at it beyond the "oh shiny" level yet so don't know much about it. |
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|