Now I see that part of the article got outdated. Do you actually need to
issue the call to the Connection Manager yourself? The DataSource is quite
capable of doing so, as I've shown in the article. Then, as shown in the
article, you override DataSource method doBeforeCallback
myDataSource.doBeforeCallback = function (oRequest, oRawResponse,
oParsedResponse) {
if (oRawResponse.replyCode == 218) {
alert(oRawResponse.replyText);
}
return oParsedResponse;
};
What is outdated is that since 2.5, oRawResponse is already parsed and is a
plain JavaScript object so you no longer need that eval there. See:
http://developer.yahoo.com/yui/datasource/#upgrade
You can also use:
myDataSource.doBeforeParseData = function(oRequest, oRawResponse) {
if (oRawResponse.replyCode == 218) {
alert(oRawResponse.replyText);
}
return oRawResponse;
};
In either one, if the reply has not good data, it will show the No Records
sign after you have acknoledged the alert(). You can also change this:
myDataSource.doBeforeCallback = function (oRequest, oRawResponse,
oParsedResponse) {
if (oRawResponse.replyCode == 218) {
alert(oRawResponse.replyText);
oParsedResponse.error = true; // This produces a Data Error
}
return oParsedResponse;
};
Satyam
----- Original Message -----
From: "rashmeep2000" <RPrasad2@...>
To: <ydn-javascript@yahoogroups.com>
Sent: Thursday, May 22, 2008 7:02 PM
Subject: [ydn-javascript] Re: Problem with refresh page and paginator
> Satyam,
> In server side i ahve populated, replyCode:218 and replyText:"finally
> i can see error messages"
>
> in client side, i am accessing it as,
> YAHOO.util.Connect.asyncRequest('POST', sUrl, {
> success : function (o) {
> DataTable.handleDataSourcePagination(state,dt);
> },
> failure: function (o) {
> alert(o.replyCode);alert(o.replyText);
> },
>
> scope : this
> }, params);
>
> but in case of failure i want my message to be shown, but it says
> undefined. I want to show my custom message which i populate in my
> server side, which i am not able to do...Please help.......let me
> know if i am making any mistake...
>
> --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
>>
>> The idea of sending status plus data in a JSON message was
> presented in:
>>
>> client side: http://yuiblog.com/blog/2007/09/12/satyam-datatable
>>
>> server side (php): http://www.satyam.com.ar/yui/PhpJson.htm
>>
>> That covers both ends of it in good detail.
>>
>> Satyam
>>
>>
>>
>> ----- Original Message -----
>> From: "rashmeep2000" <RPrasad2@...>
>> To: <ydn-javascript@yahoogroups.com>
>> Sent: Thursday, May 22, 2008 11:27 AM
>> Subject: [ydn-javascript] Re: Problem with refresh page and
> paginator
>>
>>
>> > Hi Satyam,
>> > SOrry i am not able to get how to do this..can u please give some
>> > sample code on both server and client side..i tried doing but not
>> > able to get it rite....
>> >
>> > Luke,
>> > I also tried what u said but it seems to be giving js error, not
> able
>> > to understand y...can u pls..wat can be done...
>> >
>> > thanks.
>> >
>> > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@> wrote:
>> >>
>> >> The problem is that you have to be carefull which non-200 status
>> > codes you
>> >> use. Some have side effects either on the browser or the
>> > intermediate
>> >> proxies, others can be generated automatically by the
> communication
>> > and/or
>> >> web server and your application might think they came from the
>> > application.
>> >>
>> >> It is better to keep HTTP-related status codes to report HTTP
>> > errors
>> >> (usually generated by your web server or at any point by the
>> > communication
>> >> infrastructure) and use your own application-level codes sent as
>> > data wihin
>> >> the HTTP transport. Otherwise, some communication code which
> just
>> > happens
>> >> to have the same number as one of your custom codes, might be
>> > generated by,
>> >> say, an intermediate proxy, and you might think it comes from
> your
>> >> application. Or a browser too smart for its own good might
>> > overreact upon a
>> >> missunderstood application code which matched some HTTP code.
>> >>
>> >> Admitedly, most status codes are unused, you should be quite safe
>> > with the
>> >> 90% of the codes still unassigned, but you can't count on that.
>> > Even some
>> >> firewall or any other anti-virus/anti-spam/anti-whatever software
>> > might
>> >> think the HTTP message with a custom status code bogus and
> discard
>> > it.
>> >>
>> >> Satyam
>> >>
>> >>
>> >>
>> >> ----- Original Message -----
>> >> From: "y_lsmith" <lsmith@>
>> >> To: <ydn-javascript@yahoogroups.com>
>> >> Sent: Wednesday, May 21, 2008 8:18 PM
>> >> Subject: [ydn-javascript] Re: Problem with refresh page and
>> > paginator
>> >>
>> >>
>> >> > If the server is responding with a non-200 status or the
>> > DataSource
>> >> > parse indicates an error, you can also direct these responses
> to a
>> >> > different response handler in the DataSource's sendRequest
>> > callback.
>> >> >
>> >> > var myFailedRequestHandler = function (oReqeust, oResponse,
>> > oPayload) {
>> >> > /* do something different */
>> >> > };
>> >> >
>> >> > myDataSource.sendRequest(sRequest, {
>> >> > success : myDataTable.onDataReturnInitializeTable,
>> >> > failure : myFailedRequestHandler,
>> >> > scope : myDataTable
>> >> > });
>> >> >
>> >> > Luke
>> >> >
>> >> > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@>
> wrote:
>> >> >>
>> >> >> Sorry the URLs should have pointed to:
>> >> >>
>> >> >> http://satyam.com.ar/yui/PhpJson.htm
>> >> >>
>> >> >> Satyam
>> >> >>
>> >> >> ----- Original Message -----
>> >> >> From: "traderashish" <traderashish@>
>> >> >> To: "Satyam" <satyam@>
>> >> >> Sent: Wednesday, May 21, 2008 10:09 AM
>> >> >> Subject: Re: Problem with refresh page and paginator
>> >> >>
>> >> >>
>> >> >> >
>> >> >> > url for the examples points to local host.
>> >> >> >
>> >> >> > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@>
>> > wrote:
>> >> >> >>
>> >> >> >> That's exactly where meta-data comes in handy and why it is
>> >> > better to use
>> >> >> >> some rich message format like JSON or XML which can carry
>> > meta-data
>> >> >> >> besides
>> >> >> >> the plain data.
>> >> >> >>
>> >> >> >> What you do is you put server status information in a
> branch
>> > in your
>> >> >> >> return
>> >> >> >> message and the data in another. Before 2.5, you had to
>> > override
>> >> >> >> doBeforeParseData to extract that meta information. Now,
> the
>> >> > DataSource
>> >> >> >> takes a metaFields definition and extracts them for you
> (see
>> > the
>> >> >> >> DataTable
>> >> >> >> docs towards the end). The DataTable already has some use
>> > for some
>> >> >> >> properties from the meta-data, specially when doing server-
>> > side
>> >> >> >> pagination,
>> >> >> >> but you are free to use other property names for whatever
> else
>> >> > you want.
>> >> >> >>
>> >> >> >> I wrote an article
> (http://localhost/yui/PhpJson.htm#ajaxReq)
>> >> > which uses
>> >> >> >> PHP
>> >> >> >> set_error_handler function to trap PHP errors of whatever
>> > nature,
>> >> > and
>> >> >> >> pack
>> >> >> >> them into the reply message:
>> >> >> >> http://localhost/yui/PhpJson.htm#ajaxErrorHandler
>> >> >> >>
>> >> >> >> Satyam
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> ----- Original Message -----
>> >> >> >> From: "rashmeep2000" <RPrasad2@>
>> >> >> >> To: <ydn-javascript@yahoogroups.com>
>> >> >> >> Sent: Tuesday, May 20, 2008 7:45 PM
>> >> >> >> Subject: [ydn-javascript] Problem with refresh page and
>> > paginator
>> >> >> >>
>> >> >> >>
>> >> >> >> > hi all,
>> >> >> >> > after inlin edit,when user paginates, i am doing,
>> >> >> >> >
>> >> >> >> > myDataSource.sendRequest(newParams,
>> >> >> >> > myDataTable.onDataReturnInitializeTable, myDataTable)
>> >> >> >> > i do backend validation, if thre are any validation
> errors,
>> > i throw
>> >> >> >> > those errors(i throw an exception)..now i want
>> >> >> >> > 1.to identify somehow that an exception was thrown
>> >> >> >> > 2.display those error messages to user
>> >> >> >> > 3.stop user from pagination.
>> >> >> >> >
>> >> >> >> > i tried writing my own handler in paginationEventHandler,
>> > but i
>> >> > am not
>> >> >> >> > able to know if any exception was thrown from backend
> (even
>> >> > though it
>> >> >> >> > was thrown)...can somebody please tell me how this can be
>> > achieved.
>> >> >> >> >
>> >> >> >> >
>> >> >> >> > ------------------------------------
>> >> >> >> >
>> >> >> >> > Yahoo! Groups Links
>> >> >> >> >
>> >> >> >> >
>> >> >> >> >
>> >> >> >>
>> >> >> >>
>> >> >> >> -----------------------------------------------------------
> ---
>> > -----
>> >> >> > -------------
>> >> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> No virus found in this incoming message.
>> >> >> >> Checked by AVG.
>> >> >> >> Version: 8.0.100 / Virus Database: 269.23.21/1456 - Release
>> > Date:
>> >> >> >> 20/05/2008
>> >> >> >> 6:45
>> >> >> >>
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >>
>> >> >>
>> >> >>
>> >> > ---------------------------------------------------------------
> ---
>> > --------------
>> >> >>
>> >> >>
>> >> >>
>> >> >> No virus found in this incoming message.
>> >> >> Checked by AVG.
>> >> >> Version: 8.0.100 / Virus Database: 269.23.21/1456 - Release
> Date:
>> >> > 20/05/2008
>> >> >> 6:45
>> >> >>
>> >> >
>> >> >
>> >> >
>> >> > ------------------------------------
>> >> >
>> >> > Yahoo! Groups Links
>> >> >
>> >> >
>> >> >
>> >>
>> >>
>> >> -----------------------------------------------------------------
> ---
>> > ------------
>> >>
>> >>
>> >>
>> >> No virus found in this incoming message.
>> >> Checked by AVG.
>> >> Version: 8.0.100 / Virus Database: 269.23.21/1456 - Release Date:
>> > 20/05/2008
>> >> 6:45
>> >>
>> >
>> >
>> >
>> > ------------------------------------
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>>
>>
>> --------------------------------------------------------------------
> ------------
>>
>>
>>
>> No virus found in this incoming message.
>> Checked by AVG.
>> Version: 8.0.100 / Virus Database: 269.24.0/1459 - Release Date:
> 21/05/2008
>> 17:34
>>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
--------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG.
Version: 8.0.100 / Virus Database: 269.24.0/1459 - Release Date: 21/05/2008
17:34