Topic
  • 4 replies
  • Latest Post - ‏2012-06-28T15:33:52Z by brock_smith
brock_smith
brock_smith
12 Posts

Pinned topic For Knowledge!

‏2012-06-28T12:29:09Z |
Hi Dear Mike,

Please help me to understand Example(WL4.2.1) module_06_0_EngadgetReader app/EngadgetReader/Common/EngadgetReader.js

1)function loadFeedsFailure(result){
WL.Logger.error("Feed retrieve failure");
busyIndicator.hide();
WL.SimpleDialog.show("EngadgetReader", "Cannot retrieve feed. Please check your internet connectivity.",
[{
text : 'Reload App',
handler : WL.Client.reloadApp
}]);
}

2)function displayFeeds(items){
var ul = $('itemsList');
for (var i = 0; i < items.length; i++) {
var li = new Element('li').update(items[i].title);
var pubDate = new Element('div', {
'class': 'pubDate'
}).update(items[i].pubDate);

li.insert(pubDate);

ul.insert(li);
}
}
These functions are used in this example, now my question is this that the parameters "i)result ii)items" are used where these parameters are populated or source where these parameter are defined/comes?

Thanx,
Regards,
Brock--
  • MikeZilbergleyt
    MikeZilbergleyt
    10 Posts

    Re: For Knowledge!

    ‏2012-06-28T13:29:09Z  
    If you look at the js:

    // THIS function does the adapter call. parameters : [] means no input.
    // it
    function loadFeeds(){
    busyIndicator.show();
    var invocationData = {
    adapter : 'RSSReader',
    procedure : 'getFeedsFiltered',
    parameters : []
    };

    WL.Client.invokeProcedure(invocationData,{
    onSuccess : loadFeedsSuccess, // ON OK call back function name
    onFailure : loadFeedsFailure,
    });
    }

    function loadFeedsSuccess(result){
    WL.Logger.debug("Feed retrieve success");
    busyIndicator.hide();
    if (result.invocationResult.Items.length>0)
    displayFeeds(result.invocationResult.Items);
    else
    loadFeedsFailure();
    }

    function loadFeedsFailure(result){
    WL.Logger.error("Feed retrieve failure");
    busyIndicator.hide();
    WL.SimpleDialog.show("EngadgetReader", "Cannot retrieve feed. Please check your internet connectivity.",
    [{
    text : 'Reload App',
    handler : WL.Client.reloadApp
    }]);
    }

    function loadFeeds(){
    busyIndicator.show();
    var invocationData = {
    adapter : 'RSSReader',
    procedure : 'getFeedsFiltered',
    parameters : []
    };

    WL.Client.invokeProcedure(invocationData,{
    onSuccess : loadFeedsSuccess,
    onFailure : loadFeedsFailure,
    });
    }

    function loadFeedsSuccess(result){
    WL.Logger.debug("Feed retrieve success");
    busyIndicator.hide();
    if (result.invocationResult.Items.length>0)
    displayFeeds(result.invocationResult.Items);
    else
    loadFeedsFailure();
    }

    function loadFeedsFailure(result){
    WL.Logger.error("Feed retrieve failure");
    busyIndicator.hide();
    WL.SimpleDialog.show("EngadgetReader", "Cannot retrieve feed. Please check your internet connectivity.",
    [{
    text : 'Reload App',
    handler : WL.Client.reloadApp
    }]);
    }
    It seems that these fuctions are callbacks from the call to an adapter.
    The loadFeedsFailure(result) is called on failure. result is the JSON object
    returned by the adapter.
  • brock_smith
    brock_smith
    12 Posts

    Re: For Knowledge!

    ‏2012-06-28T14:01:58Z  
    Thanx Mike for reply i have got the idea regarding result but i am still not clear about items parameter?
    Regards,
    Brock--
  • MikeZilbergleyt
    MikeZilbergleyt
    10 Posts

    Re: For Knowledge!

    ‏2012-06-28T14:45:46Z  
    Thanx Mike for reply i have got the idea regarding result but i am still not clear about items parameter?
    Regards,
    Brock--
    the OK call back function:

    function loadFeedsSuccess(result){
    WL.Logger.debug("Feed retrieve success");
    busyIndicator.hide();
    if (result.invocationResult.Items.length>0)
    displayFeeds(result.invocationResult.Items);
    else
    loadFeedsFailure();
    }

    Calls the displayFeeds(result.invocationResult.Items).
    If you look at module 6.0 PPT, you will see the structure of the invocationResult JSON object.

    It is formatted based on the the response from the RSS feed and xslt file configured in the adapter. See PPT for module 05_2.

    Mike Z
  • brock_smith
    brock_smith
    12 Posts

    Re: For Knowledge!

    ‏2012-06-28T15:33:52Z  
    Thank you so much Mike,
    Regards,
    Brock--