RPC DS

39 views
Skip to first unread message

jsantaelena

unread,
May 11, 2009, 5:40:11 PM5/11/09
to SmartGWT Extensions
Hi all,

I started using the gwt tpc datasource with a calendar. Before I had
to change to use Record as the Data class, then it now suppprts
CalendarEvent data class. But my problem is how rollback the view
state when I setStatus(0) as response status. Ir I remove a calendar
event and the RPC Call returns failure, the calendar event isn't
displayed anymore. Anybare knows what may I doing wrong?

Also, if I set DSResponse.setErros(), nothing is shown. Is this the
way to report DS erros?

Boysen, Pete [ITACD]

unread,
May 12, 2009, 10:33:14 AM5/12/09
to smartgwt-...@googlegroups.com
So you remove an event, the server returns a status other than 0 and the
event disappears? You may want to override the transformResponse like I
did in the ProjectDataSource (see source) to process the error. Another
option is to put some code in a DSCallback to process the exception.


Pete Boysen (pbo...@iastate.edu)
Information Technology Services
209 Durham
(515)294-6663

jsantaelena

unread,
May 12, 2009, 10:49:59 AM5/12/09
to SmartGWT Extensions
When we click to remove the event from the calendar, the event
dissapears from the calendar and the DS remove operation is called. If
some error at server side occurs, I set the status code on DS to 0
(failure) indicating removal error, but the Calendar doesn't brings
back the event to the calendar.


On 12 maio, 11:33, "Boysen, Pete [ITACD]" <pboy...@iastate.edu> wrote:
> So you remove an event, the server returns a status other than 0 and the
> event disappears?  You may want to override the transformResponse like I
> did in the ProjectDataSource (see source) to process the error.  Another
> option is to put some code in a DSCallback to process the exception.
>
> Pete Boysen (pboy...@iastate.edu)

Boysen, Pete [ITACD]

unread,
May 12, 2009, 11:06:54 AM5/12/09
to smartgwt-...@googlegroups.com
Actually, 0 is for success. Here are the actual values:
public static int STATUS_FAILURE = -1;
public static int STATUS_LOGIN_INCORRECT = -5;
public static int STATUS_LOGIN_REQUIRED = -7;
public static int STATUS_LOGIN_SUCCESS = -8;
public static int STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED = -6;
public static int STATUS_SERVER_TIMEOUT = -100;
public static int STATUS_SUCCESS = 0;
public static int STATUS_TRANSPORT_ERROR = -90;
public static int STATUS_VALIDATION_ERROR = -4;

You might try STATUS_FAILURE and see how it responds.

Pete Boysen (pbo...@iastate.edu)

Jose Santa Elena

unread,
May 12, 2009, 11:14:13 AM5/12/09
to smartgwt-...@googlegroups.com
Sorry, I just wrote the wrong number, cause I'm using these constants to set status.

Boysen, Pete [ITACD]

unread,
May 12, 2009, 1:49:24 PM5/12/09
to smartgwt-...@googlegroups.com

Well, I think I will have to tell you what others tell me:  can you some up with a small sample app that shows the problem?  I can try it in my test environment and see if I can figure out what is going on..

 

 

Pete Boysen (pbo...@iastate.edu)
Information Technology Services
209 Durham
(515)294-6663

jsantaelena

unread,
May 20, 2009, 8:25:51 AM5/20/09
to SmartGWT Extensions
Hi Pete, sorry the delay.
Here is the project. It shows what I described above.

Project:
http://www.4shared.com/file/106596941/c442e36a/calendar.html

Dependencies:
http://www.4shared.com/file/106597282/45177558/calendar-lib.html

How to use:

1) Create a database with name "calendar" into your database

2) Change the database connection properies at src/database.properties

3) Change the log4j properies at src/log4j.xml

4) Run the IntialLoadTest JUnit Test to create an test appointment

5) Run ant hosted

6) Delete an appointment

Thanks.

On 12 maio, 14:49, "Boysen, Pete [ITACD]" <pboy...@iastate.edu> wrote:
> Well, I think I will have to tell you what others tell me:  can you some
> up with a small sample app that shows the problem?  I can try it in my
> test environment and see if I can figure out what is going on..
>
> Pete Boysen (pboy...@iastate.edu)
> Information Technology Services
> 209 Durham
> (515)294-6663
>
> From: smartgwt-...@googlegroups.com
> [mailto:smartgwt-...@googlegroups.com] On Behalf Of Jose Santa
> Elena
> Sent: Tuesday, May 12, 2009 10:14 AM
> To: smartgwt-...@googlegroups.com
> Subject: Re: RPC DS
>
> Sorry, I just wrote the wrong number, cause I'm using these constants to
> set status.
>
> On Tue, May 12, 2009 at 12:06 PM, Boysen, Pete [ITACD]
>
> <pboy...@iastate.edu> wrote:
>
> Actually, 0 is for success. Here are the actual values:
>    public static int STATUS_FAILURE = -1;
>    public static int STATUS_LOGIN_INCORRECT = -5;
>    public static int STATUS_LOGIN_REQUIRED = -7;
>    public static int STATUS_LOGIN_SUCCESS = -8;
>    public static int STATUS_MAX_LOGIN_ATTEMPTS_EXCEEDED = -6;
>    public static int STATUS_SERVER_TIMEOUT = -100;
>    public static int STATUS_SUCCESS = 0;
>    public static int STATUS_TRANSPORT_ERROR = -90;
>    public static int STATUS_VALIDATION_ERROR = -4;
>
> You might try STATUS_FAILURE and see how it responds.
>

jsantaelena

unread,
May 20, 2009, 9:28:17 AM5/20/09
to SmartGWT Extensions
Sorry, I had to update the Project RAR. Now the correct link is:

http://www.4shared.com/file/106610664/1ecd54e9/calendar.html






jsantaelena

unread,
May 27, 2009, 10:17:28 PM5/27/09
to SmartGWT Extensions
Has anyone took a look?

I prepared a WAR version within a database script (mysql.sql) to
facilitate the deployment and db creation.

Here is the link to download it: http://www.4shared.com/file/108251684/6dc8189/calendar.html

Boysen, Pete [ITACD]

unread,
May 28, 2009, 10:09:42 AM5/28/09
to smartgwt-...@googlegroups.com
I did download it and take a look but I haven't had the time to set it up to run it.

Pete Boysen (pbo...@iastate.edu)
Information Technology Services
209 Durham
(515)294-6663
-----Original Message-----
From: smartgwt-...@googlegroups.com [mailto:smartgwt-...@googlegroups.com] On Behalf Of jsantaelena
Sent: Wednesday, May 27, 2009 9:17 PM
To: SmartGWT Extensions

Jose Santa Elena

unread,
May 28, 2009, 10:17:56 AM5/28/09
to smartgwt-...@googlegroups.com
Thank you Pete.

Boysen, Pete [ITACD]

unread,
May 28, 2009, 10:19:44 AM5/28/09
to smartgwt-...@googlegroups.com

Is there a way for you to set up a test case with just a calendar in hosted mode?

 

Pete Boysen (pbo...@iastate.edu)
Information Technology Services
209 Durham
(515)294-6663

From: smartgwt-...@googlegroups.com [mailto:smartgwt-...@googlegroups.com] On Behalf Of Jose Santa Elena
Sent: Thursday, May 28, 2009 9:18 AM
To: smartgwt-...@googlegroups.com
Subject: Re: RPC DS

 

Thank you Pete.

Jose Santa Elena

unread,
May 28, 2009, 6:03:40 PM5/28/09
to smartgwt-...@googlegroups.com
Ok, here is a project where you just have to run using a "ant hosted" command.


Test Cases:

*Add Case
   - Add an new appointment by selecting a time slot and set the Name to "error", it will instruct the server service to raise an exception;
   - My expectations is that the appointment addition remains at Event Editor dialog or, if it's closed, the appointment can't to be added to the calendar. It will gives the user an impression of success;

*Delete Case
  - Delete an appointment, the server always raise an exception in this case;
  - May expectations it that the appointment remains at the calendar, but it's delete from the calendar;

*Another doubt is, what is the correctly way to report DS errors? May I use SC.say()? Or DSResponse.setErrors()?

Thanks Pete! And, in this project I did some changes on GWTRPCDataSource with a better use of Java 5 Generics, so, consider this  as my contribution too.

Boysen, Pete [ITACD]

unread,
May 28, 2009, 6:05:59 PM5/28/09
to smartgwt-...@googlegroups.com

Awesome.  I will look at it this weekend.

Pete

unread,
Jun 1, 2009, 2:04:09 PM6/1/09
to SmartGWT Extensions
I spent about 4 hours playing with your code and haven't found a way
to leave the event in the calendar on delete failure. I would like to
try another approach using a RestDataSource to see if it behaves
differently. Is there a reason you need a GWTRPCDataSource? A
RestDataSource handles most of the plumbing for you.

I did add the following code:
protected void transformResponse(DSResponse response, DSRequest
request, Object data) {
if (response.getStatus() == RPCResponse.STATUS_SUCCESS) {
GWT.log("transformResponse success",null);
super.transformResponse(response, request, data);
} else {
GWT.log("transformResponse failure",null);
response.setStatus(RPCResponse.STATUS_VALIDATION_ERROR);
Object errors = XMLTools.selectNodes(data, "/response/errors");
JavaScriptObject errorsJS = XMLTools.toJS(errors);
response.setErrors(errorsJS);
}
}

Normally, if I get an error, the above code will report the errors on
the field and won't delete because super.transformResponse is not
called. Note that I return
<response>
<status>-1</status>
<errors>
<field>this field had errors</field>
</errors>
</response>
but this may be restricted to an RDS. I'll let you know my results.

jsantaelena

unread,
Jun 1, 2009, 9:47:19 PM6/1/09
to SmartGWT Extensions
I must have to communicate with my server in a GWT RPC way. I don't
know if RDS does it, but I guess not, cause this missing the GWTPRCDS
was made, isn't?
So, if RDS does what we want, then we have to find the behavior gap
between these two DSs.
I tryed to add a override to transformResponse to call the super
method only when success, but it didn't work also, the appointments
remains deleted or added to the calendar!

protected void transformResponse(DSResponse response, DSRequest
request, Object data) {
if (response.getStatus() == RPCResponse.STATUS_SUCCESS) {
super.transformResponse(response, request, data);

Boysen, Pete [ITACD]

unread,
Jun 2, 2009, 10:18:18 AM6/2/09
to smartgwt-...@googlegroups.com
Yes, I found that as well so I will try a RDS and see if it makes a difference.

Pete Boysen (pbo...@iastate.edu)
Information Technology Services
209 Durham
(515)294-6663
-----Original Message-----
From: smartgwt-...@googlegroups.com [mailto:smartgwt-...@googlegroups.com] On Behalf Of jsantaelena
Sent: Monday, June 01, 2009 8:47 PM
To: SmartGWT Extensions
Subject: Re: RPC DS


jsantaelena

unread,
Jun 6, 2009, 9:53:06 AM6/6/09
to SmartGWT Extensions
Hi Pete, has you any news?!

On 2 jun, 11:18, "Boysen, Pete [ITACD]" <pboy...@iastate.edu> wrote:
> Yes, I found that as well so I will try a RDS and see if it makes a difference.
>
> Pete Boysen (pboy...@iastate.edu)

Boysen, Pete [ITACD]

unread,
Jun 7, 2009, 5:16:08 PM6/7/09
to smartgwt-...@googlegroups.com
Sorry for the delay... I'm trying to get a beta out.

I was successful in creating a RestDataSource for the calendar. On delete I return a
<response>
<status>-4</status>
<data>
</data>
</response>

The event temporarily disappears and then reappears again so it looks like the RestDataSource is handling it correctly.
Perhaps it is reinserting it on failure?

Any thoughts, Sanjiv?

Pete Boysen
Information Technology Services
pbo...@iastate.edu
winmail.dat
Reply all
Reply to author
Forward
0 new messages