Re: History and server call.

2010-06-18 Thread Ravi Sharma
Thanks Tristan for your comments. Your comments kicked my thoughts
running again :).

Let me explain how non readable code/decoupling view from presenter
etc can make life easier in terms of designing.(for the Records, i
always like Readable code)

Currently our view and presenter are dependent on each other, although
we use interfaces but still they are tightly bound that view know
there is one presenter for him(implementation may be different by
injection). I have seen the Contacts project code provided by Google
and see presenter(via dispaly) and view(via presenter) call each other
directly.

Now lets say i am writing a wizard screen or my one click will update
2-3 view/panels in my screen.

Ok i will take example where one click will update 2-3 section of
whole page which are basically different view and each will have
presenter.

Say ViewA is header (PresenterA is its presenter)
ViewB is left side panel,(PresenterB is its presenter)
ViewC is Bottom Panel(PresenterC is its presenter)
ViewD is right side Panel(PresenterD is its presenter)

Now there is button/Link on ViewA which say clickMe. On clicking this
ViewB should load some data from server and ViewC should hide some
data, viewD also load some data.

Now as per MVP/Contact project style.
My ViewA should be injected with PresnterA,PresnterB,PresenterC and
PresenterD

And onClick event i will call methods of each presenter, which
eventually raise the required events and which may create history and
then do the server calls. Technically everything is ok(normal java
inetrface/class calls tree), but problem occurs when something
changes. Say now PresenterB doesnt need to update any thing when we
click the same button. At that time you may want to remove PresnterB
from ViewA as whole, you dont want to keep such code as it(PresenterB)
will never be used in ViewA. Or say some new ViewE came up somewhere
and you want to update this via PresenterE, so you need to inject
presenterE dependency in ViewA so that ViewA can a make call like
PresenterE.doSomethingForMe(). Lots of code changes which could be
avoided by just using EventBus.


Say OnClick we just raise an event HEY_BUTTON_CLICKED_ON_VIEW_A and
presenterB,PresenterC,PresnterD will be interested in this event
initially. Once PresenterE will come then PresnterE will be interested
in that too.And when PresnterB says i dont need to update, it will
just stop listening to that event. But i will never touch ViewA class
or any other presenter at all.

And also i looked into AppController class in Contacts project  and it
looks to be controller it self for views and presenter.
I should say its not MVP but its MVPC

Now with using EventBus for all Communcation i am just assesing the
existance of presenter it self(just to make a go call ?). Why do i
need presenter at first place. Just to be tight bound with View??. SO
that if tommorow my site/application goes for mobile i write seprate
presenter which will be bind to seprate view as per Mobile screen. Why
not i just write seprate view and use EventBus.

Basically with in Client(between UI events/activities and server calls
at client side), i am trying to have RPC calls kind of style. UI
request client side code with an event and get response with another
event. I feel its just MVE (Model View Event), no controller and no
presenter.


Does it make sense?
Ravi.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-17 Thread Tristan Slominski
So I will just adress things you see as a benefit, ie decoupling of server
calls from presenters / views and decoupling views from presenters.

First, though, I think you shouldn't call it MVP. In my opinion it seems
that what you're doing is MVC where the model is helped out by RPC. There is
already so much variety in the meanings of this (MVP, MVC, etc...),
especially with Activities and Request Factory coming into the picture that
terminology is becoming important. Not because I don't know what you're
describing, but because someone new to the frameworks will get thoroughly
confused.

As for the benefits of what you offer, i.e. the decoupling points. Multiple
frameworks out there already accomplish decoupling. Combine the fact that
those benefits already exist in frameworks out there today with the concern
you raised:

"At some point you may forget that who is handling these vents and how the
data is reaching from server to view etc, basically you wont be able to just
Ctrl + click to traverse the code tree in eclipse or netbeans. Code reading
may be bit difficult. If someone can write a plugin for such code
readability like Spring plugin then it will be very nice."

That fact alone would make me want to never ever learn what you have to
offer. This is almost getting into the realm of product development :) ie.
as a customer what benefits do I get from your framework?

I think you have some interesting ideas about the richness of event
interactions, but after reading your proposal I still don't feel a
compelling reason to write yet another framework. Where do you feel is the
crucial difference / benefit in comparison?

I'm not familiar with all of these frameworks, but here are some to compare
to:

gwt-presenter: http://code.google.com/p/gwt-presenter/

gwt-dispatch: http://code.google.com/p/gwt-dispatch/

gwt-platform: http://code.google.com/p/gwt-platform/

handlebars: http://code.google.com/p/handlebars/

I'm sure there are a lot more, these are the ones that immediately come to
mind.

On Jun 17, 2010 12:03 PM, "Ravi Sharma"  wrote:

Hey guys,
I have been thinking about all this MVP architect(i am new to it) and
history management and show on ready pattern etc and came up with
following design/idea. Lets see if it will work and feel free to
comment on it.

1) Something happens on UI(Some User activity like mouse click,
keyboard press etc)
2) Raise an EVENT with required data from UI. something like
CLIENT_EVENT_% or VIEW_EVENT%(i.e.CLIENT_EVENT_PROFILE_LINK_CLICKED) ,
basically i want to have separate naming convention for all client/UI
events.
3) Presenters will be listening to these events. On Getting a event
presenter can do following things
  3.1) Create a history token and in history handler raise event to
get data from server SERVER_EVENT_GET_DATA (Optional, if you want to
keep history)
  3.2) or directly raise event (i.e.SERVER_EVENT_GET_DATA) to get
data from server. (If You don't want to keep history)
4) Different Data Handlers or Presenter it self will be listening to
these events SERVER_EVENT_% and make the server call.
5) once server call returns raise another event like DATA_MODEL_SUCCESS
%/DATA_MODEL_ERROR% with data/error returned by Server.
6) Presenter or View(I will prefer it to go to View, although it may
break classic MVP) will be listening to these events(DATA_MODEL%) and
will display the view/error accordingly.


Now if we want to use Client side cache in this flow then handlers of
events(at step 4) like SERVER_EVENT_GET_DATA / SERVER_EVENT_% can
first check in Cache, if found then raise the same
event(DATA_MODEL_SUCCESS%) as it will be raised by server returned
asyncallback functions.


So what we will achieve here.

Our server RPC call will stay independent of cache/view/presenter etc.
Our View stay independent of cache or server calls even independent of
presenter too.. I would make my view listen to events and show the
data.
Our Presenter dont need to know server call details, in case you are
planning to implement the separate data handlers which can use cache
as well as RPC.

Downside
1) For one user action i will be raising 3 Events like CLIENT_EVENT_%
and then SERVER_EVENT_% and then DATA_MODEL_SUCCESS%/DATA_MODEL_ERROR
%. So need to do lots of efficiency check, but good things is how many
clicks a user can click on an application on browser which is running
on atleast P4 machine, 1GHZ.
2) At some point you may forget that who is handling these events and
how the data is reaching from server to view etc, basically you wont
be able to just Ctrl + click to traverse the code tree in eclipse or
netbeans. Code reading may be bit difficult. If someone can write a
plugin for such code readability like Spring plugin then it will be
very nice.
3) One day you decide not to use cache, just remove it without
affecting any other code. Basically everything in pluggable/
unpluggable
4) One day you feel like creating same application for Mobile or new
web look create ur view again. This i

Re: History and server call.

2010-06-17 Thread Ravi Sharma
Hey guys,
I have been thinking about all this MVP architect(i am new to it) and
history management and show on ready pattern etc and came up with
following design/idea. Lets see if it will work and feel free to
comment on it.

1) Something happens on UI(Some User activity like mouse click,
keyboard press etc)
2) Raise an EVENT with required data from UI. something like
CLIENT_EVENT_% or VIEW_EVENT%(i.e.CLIENT_EVENT_PROFILE_LINK_CLICKED) ,
basically i want to have separate naming convention for all client/UI
events.
3) Presenters will be listening to these events. On Getting a event
presenter can do following things
   3.1) Create a history token and in history handler raise event to
get data from server SERVER_EVENT_GET_DATA (Optional, if you want to
keep history)
   3.2) or directly raise event (i.e.SERVER_EVENT_GET_DATA) to get
data from server. (If You don't want to keep history)
4) Different Data Handlers or Presenter it self will be listening to
these events SERVER_EVENT_% and make the server call.
5) once server call returns raise another event like DATA_MODEL_SUCCESS
%/DATA_MODEL_ERROR% with data/error returned by Server.
6) Presenter or View(I will prefer it to go to View, although it may
break classic MVP) will be listening to these events(DATA_MODEL%) and
will display the view/error accordingly.


Now if we want to use Client side cache in this flow then handlers of
events(at step 4) like SERVER_EVENT_GET_DATA / SERVER_EVENT_% can
first check in Cache, if found then raise the same
event(DATA_MODEL_SUCCESS%) as it will be raised by server returned
asyncallback functions.


So what we will achieve here.

Our server RPC call will stay independent of cache/view/presenter etc.
Our View stay independent of cache or server calls even independent of
presenter too.. I would make my view listen to events and show the
data.
Our Presenter dont need to know server call details, in case you are
planning to implement the separate data handlers which can use cache
as well as RPC.

Downside
1) For one user action i will be raising 3 Events like CLIENT_EVENT_%
and then SERVER_EVENT_% and then DATA_MODEL_SUCCESS%/DATA_MODEL_ERROR
%. So need to do lots of efficiency check, but good things is how many
clicks a user can click on an application on browser which is running
on atleast P4 machine, 1GHZ.
2) At some point you may forget that who is handling these events and
how the data is reaching from server to view etc, basically you wont
be able to just Ctrl + click to traverse the code tree in eclipse or
netbeans. Code reading may be bit difficult. If someone can write a
plugin for such code readability like Spring plugin then it will be
very nice.
3) One day you decide not to use cache, just remove it without
affecting any other code. Basically everything in pluggable/
unpluggable
4) One day you feel like creating same application for Mobile or new
web look create ur view again. This is what MVP gives.



Basically i am quite excited about using this new MVP archt. and
History and event bus(I Love Eventbus, it solves me lot of things and
long chains of async calls and also it gives me opportunity to make
client side calls asynch(i.e. if i find that data is present in cache
then i raise the event and view/presenter handler will be called in
async was as if server has returned)

happy coding guys.
Feel free to comment.


Thanks,
Ravi.














On Jun 17, 1:45 pm, Tristan Slominski 
wrote:
> here's an example i wrote that walks through place service, hope that helps
> with place service concepts. note that I got feedback that two types of
> place events that i implemented here are not necessary and that one would be
> sufficient, but i haven't had the time to refactor yet. it should however
> capture the essence of what a place service does. I too am waiting for 2.1
> to settle and see where Google wants to go with that, in the mean time this
> is a production system description:
>
> http://code.google.com/p/handlebars/wiki/PlaceServiceOverview
>
> 2010/6/17 Jaroslav Záruba 
>
>
>
> > I searched too but have found only this:
>
> >http://code.google.com/p/google-web-toolkit/source/browse/branches/2
> > It
> > seems to be missing in 2.1 m1 yet.
>
> > On Thu, Jun 17, 2010 at 12:30 PM, Ravi Sharma  wrote:
>
> >> Hi Thomas,
> >> I checked this URL
> >>http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html,
> >> for GWT 2.1 but didnt find much information about Activities. Is it
> >> explained somewhere else. Can you share such info/link so i can look
> >> into it dont reinvent everything. I am about to start implementing
> >> "switch view only when ready" pattern but if its present in 2.1 then i
> >> would love to use it instead of writing my own.
>
> >> Thanks,
> >> Ravi.
>
> >> On Jun 17, 10:59 am, Thomas Broyer  wrote:
> >> > On 16 juin, 15:31, Tristan  wrote:
>
> >> > > sounds like you're reinventing the place service, with event bu

Re: History and server call.

2010-06-17 Thread Thomas Broyer


On 17 juin, 12:30, Ravi Sharma  wrote:
> Hi Thomas,
> I checked this 
> URLhttp://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html,
> for GWT 2.1 but didnt find much information about Activities. Is it
> explained somewhere else. Can you share such info/link so i can look
> into it dont reinvent everything. I am about to start implementing
> "switch view only when ready" pattern but if its present in 2.1 then i
> would love to use it instead of writing my own.

Ray Ryan gave an overview of activities in his I/O session about
"Architecting GWT applications for production at Google":
http://code.google.com/events/io/2010/sessions/architecting-production-gwt.html
Maybe you can find some details in the session's waves or other GWT-
related sessions.
And of course, have a look at the JavaDoc, for instance:
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/app/place/Activity.html#start(com.google.gwt.app.place.Activity.Display)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-17 Thread Tristan Slominski
here's an example i wrote that walks through place service, hope that helps
with place service concepts. note that I got feedback that two types of
place events that i implemented here are not necessary and that one would be
sufficient, but i haven't had the time to refactor yet. it should however
capture the essence of what a place service does. I too am waiting for 2.1
to settle and see where Google wants to go with that, in the mean time this
is a production system description:

http://code.google.com/p/handlebars/wiki/PlaceServiceOverview

2010/6/17 Jaroslav Záruba 

> I searched too but have found only this:
>
> http://code.google.com/p/google-web-toolkit/source/browse/branches/2.1/bikeshed/src/com/google/gwt/app/place/
> It
> seems to be missing in 2.1 m1 yet.
>
>
> On Thu, Jun 17, 2010 at 12:30 PM, Ravi Sharma  wrote:
>
>> Hi Thomas,
>> I checked this URL
>> http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html,
>> for GWT 2.1 but didnt find much information about Activities. Is it
>> explained somewhere else. Can you share such info/link so i can look
>> into it dont reinvent everything. I am about to start implementing
>> "switch view only when ready" pattern but if its present in 2.1 then i
>> would love to use it instead of writing my own.
>>
>> Thanks,
>> Ravi.
>>
>> On Jun 17, 10:59 am, Thomas Broyer  wrote:
>> > On 16 juin, 15:31, Tristan  wrote:
>> >
>> > > sounds like you're reinventing the place service, with event bus, with
>> > > local cache rpc service, but doing it in a new, innovative, complex
>> > > and if the code grows on you perhaps unintelligible way. if you're the
>> > > only one who will support this ever, that may work. otherwise i would
>> > > seriously look into a bunch of mvp-like frameworks out there and look
>> > > at how place services/managers, local caches, and event buses are
>> > > implemented. you don't need to use the framework, but the concepts are
>> > > very helpful to organize the code. they're straightforward and most
>> > > people understand the design.
>> >
>> > Sure Ravi is "reinventing" the "place service" here. Sure he should
>> > move its "cache" to a "local cache rpc service". But the main issue
>> > with his code is that he has a "synchronous method" which has to do
>> > something "asynchronous".
>> >
>> > Now, most "place services & MVP" implementations I've seen don't use
>> > the "switch view only when ready" pattern. The "activities" coming
>> > into GWT 2.1 do that however.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to google-web-tool...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> google-web-toolkit+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-17 Thread Jaroslav Záruba
I searched too but have found only this:
http://code.google.com/p/google-web-toolkit/source/browse/branches/2.1/bikeshed/src/com/google/gwt/app/place/
It
seems to be missing in 2.1 m1 yet.

On Thu, Jun 17, 2010 at 12:30 PM, Ravi Sharma  wrote:

> Hi Thomas,
> I checked this URL
> http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html,
> for GWT 2.1 but didnt find much information about Activities. Is it
> explained somewhere else. Can you share such info/link so i can look
> into it dont reinvent everything. I am about to start implementing
> "switch view only when ready" pattern but if its present in 2.1 then i
> would love to use it instead of writing my own.
>
> Thanks,
> Ravi.
>
> On Jun 17, 10:59 am, Thomas Broyer  wrote:
> > On 16 juin, 15:31, Tristan  wrote:
> >
> > > sounds like you're reinventing the place service, with event bus, with
> > > local cache rpc service, but doing it in a new, innovative, complex
> > > and if the code grows on you perhaps unintelligible way. if you're the
> > > only one who will support this ever, that may work. otherwise i would
> > > seriously look into a bunch of mvp-like frameworks out there and look
> > > at how place services/managers, local caches, and event buses are
> > > implemented. you don't need to use the framework, but the concepts are
> > > very helpful to organize the code. they're straightforward and most
> > > people understand the design.
> >
> > Sure Ravi is "reinventing" the "place service" here. Sure he should
> > move its "cache" to a "local cache rpc service". But the main issue
> > with his code is that he has a "synchronous method" which has to do
> > something "asynchronous".
> >
> > Now, most "place services & MVP" implementations I've seen don't use
> > the "switch view only when ready" pattern. The "activities" coming
> > into GWT 2.1 do that however.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to google-web-tool...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-toolkit+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-17 Thread Ravi Sharma
Hi Thomas,
I checked this URL 
http://code.google.com/webtoolkit/doc/latest/ReleaseNotes.html,
for GWT 2.1 but didnt find much information about Activities. Is it
explained somewhere else. Can you share such info/link so i can look
into it dont reinvent everything. I am about to start implementing
"switch view only when ready" pattern but if its present in 2.1 then i
would love to use it instead of writing my own.

Thanks,
Ravi.

On Jun 17, 10:59 am, Thomas Broyer  wrote:
> On 16 juin, 15:31, Tristan  wrote:
>
> > sounds like you're reinventing the place service, with event bus, with
> > local cache rpc service, but doing it in a new, innovative, complex
> > and if the code grows on you perhaps unintelligible way. if you're the
> > only one who will support this ever, that may work. otherwise i would
> > seriously look into a bunch of mvp-like frameworks out there and look
> > at how place services/managers, local caches, and event buses are
> > implemented. you don't need to use the framework, but the concepts are
> > very helpful to organize the code. they're straightforward and most
> > people understand the design.
>
> Sure Ravi is "reinventing" the "place service" here. Sure he should
> move its "cache" to a "local cache rpc service". But the main issue
> with his code is that he has a "synchronous method" which has to do
> something "asynchronous".
>
> Now, most "place services & MVP" implementations I've seen don't use
> the "switch view only when ready" pattern. The "activities" coming
> into GWT 2.1 do that however.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-17 Thread Thomas Broyer


On 16 juin, 15:31, Tristan  wrote:
> sounds like you're reinventing the place service, with event bus, with
> local cache rpc service, but doing it in a new, innovative, complex
> and if the code grows on you perhaps unintelligible way. if you're the
> only one who will support this ever, that may work. otherwise i would
> seriously look into a bunch of mvp-like frameworks out there and look
> at how place services/managers, local caches, and event buses are
> implemented. you don't need to use the framework, but the concepts are
> very helpful to organize the code. they're straightforward and most
> people understand the design.

Sure Ravi is "reinventing" the "place service" here. Sure he should
move its "cache" to a "local cache rpc service". But the main issue
with his code is that he has a "synchronous method" which has to do
something "asynchronous".

Now, most "place services & MVP" implementations I've seen don't use
the "switch view only when ready" pattern. The "activities" coming
into GWT 2.1 do that however.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-16 Thread Sky
Hey Tristan. I am somewhat familiar with MVP frameworks as I've worked
on projects using MVP in IT but I've never dealt with "place services/
managers", local caches or event buses. Caches and event buses I can
at least imagine them cuz those words say a lot in themselves, but I
have no idea what place services/managers are and I did a couple quick
google searches for "mvp place services", "mvp place managers", "mvp
activity mangers" and didn't find any useful guides.

Is the GWT MVP guide sufficient to look into these things? Do you have
any recommendations of some online info so I can learn more?

Thanks ^_^

On Jun 16, 10:18 am, Ravi Sharma  wrote:
> Event bus looks to be promising and can solve this problem. Will try
> it and see how much it can help. But first need to use MVP in my
> project
>
> Thanks
> Ravi.
>
> On Jun 16, 2:23 am, fmod  wrote:
>
>
>
> > Using the event bus may help 
> > there.http://code.google.com/events/io/2009/sessions/GoogleWebToolkitBestPr...
> > and the two 
> > articleshttp://code.google.com/webtoolkit/articles/mvp-architecture.html
>
> > On Jun 15, 9:14 am, ping2ravi  wrote:
>
> > > Hi Guys,
> > > I have just implemented a multipage(basically multi url) website using
> > > History. It works great using history token. But i need something else
> > > from GWT which i am not able to solve.
> > > Now when user clicks on something(link/button etc) i add the token to
> > > History and my history callbacks get called.
> > > Now in history value change handler i do something like this
>
> > > 1) FInd out what page need to be dispalyed(basically identify the
> > > panels etc).
> > > 2) now each of my panel which can have history implementing
> > > hasHistory(my own) interface, which has function
> > > recoverPanelFromHistory.
> > > 3) In this function, i check if i have client side data cahced for
> > > this panel, if yes then load it into panel and display it(basically
> > > add to main panel widget tree).
> > > 4) But if no cache data found then go to server and get data.
>
> > > one such implementation
> > > @Override
> > >         public boolean recoverPanelFromHistory(Map
> > > historyTokens) {
> > >                 String page = historyTokens.get(PAGE_PARAM);
> > >                 boolean returnValue = false;
> > >                 if("home".equalsIgnoreCase(page))
> > >                 {
> > >                         returnValue =
> > > userHomePanel.recoverPanelFromHistory(historyTokens); //and this
> > > function will calls its child panels if they support history
> > >                         if(returnValue )
> > >                         {
> > >                                 mainContentPanel.clear(); //clearing the 
> > > mainPanel view of client
> > >                                 mainContentPanel.add(userHomePanel); 
> > > //and adding the view
> > > according to history token value
> > >                         }
> > >                       else
> > >                       {
> > >                            //dont change the browser view and stay at
> > > current panel/view/page. This also means child panel can not be
> > > recovered and there must be some problem with history tokens provided.
> > >                       }
>
> > >                 }
> > >                 if("profile".equalsIgnoreCase(page))
> > >                 {
> > >                         returnValue =
> > > prodilePanel.recoverPanelFromHistory(historyTokens); //and this
> > > function will calls its child panels if they support history
> > >                         if(returnValue )
> > >                         {
> > >                                 mainContentPanel.clear(); //clearing the 
> > > mainPanel view of client
> > >                                 mainContentPanel.add(profilePanel); //and 
> > > adding the view
> > > according to history token value
> > >                         }
> > >                       else
> > >                       {
> > >                            //dont change the browser view and stay at
> > > current panel/view/page. This also means child panel can not be
> > > recovered and there must be some problem with history tokens provided.
> > >                       }
>
> > >                 }
> > >                 return returnValue;
>
> > >         }
>
> > > So till now theoretically it sounds good and works good.
>
> > > Problem starts when lets say user lost his Internet connection or call
> > > fail at server because of any system level error..
>
> > > userHomePanel.recoverPanelFromHistory(historyTokens);
>
> > > This function does following things.
> > > 1) get the data from cache for this panel
> > > 2) if found call loadDataIntoPanel(data) function and load it into
> > > panel and return true.
> > > 3)  else call the server to get data.
> > >     Now server call is async and I need to return some value from
> > > userHomePanel.recoverPanelFromHistory(historyTokens);, so if i return
> > > true and call fails at server because of some network problem

Re: History and server call.

2010-06-16 Thread Ravi Sharma
Event bus looks to be promising and can solve this problem. Will try
it and see how much it can help. But first need to use MVP in my
project

Thanks
Ravi.

On Jun 16, 2:23 am, fmod  wrote:
> Using the event bus may help 
> there.http://code.google.com/events/io/2009/sessions/GoogleWebToolkitBestPr...
> and the two 
> articleshttp://code.google.com/webtoolkit/articles/mvp-architecture.html
>
> On Jun 15, 9:14 am, ping2ravi  wrote:
>
>
>
> > Hi Guys,
> > I have just implemented a multipage(basically multi url) website using
> > History. It works great using history token. But i need something else
> > from GWT which i am not able to solve.
> > Now when user clicks on something(link/button etc) i add the token to
> > History and my history callbacks get called.
> > Now in history value change handler i do something like this
>
> > 1) FInd out what page need to be dispalyed(basically identify the
> > panels etc).
> > 2) now each of my panel which can have history implementing
> > hasHistory(my own) interface, which has function
> > recoverPanelFromHistory.
> > 3) In this function, i check if i have client side data cahced for
> > this panel, if yes then load it into panel and display it(basically
> > add to main panel widget tree).
> > 4) But if no cache data found then go to server and get data.
>
> > one such implementation
> > @Override
> >         public boolean recoverPanelFromHistory(Map
> > historyTokens) {
> >                 String page = historyTokens.get(PAGE_PARAM);
> >                 boolean returnValue = false;
> >                 if("home".equalsIgnoreCase(page))
> >                 {
> >                         returnValue =
> > userHomePanel.recoverPanelFromHistory(historyTokens); //and this
> > function will calls its child panels if they support history
> >                         if(returnValue )
> >                         {
> >                                 mainContentPanel.clear(); //clearing the 
> > mainPanel view of client
> >                                 mainContentPanel.add(userHomePanel); //and 
> > adding the view
> > according to history token value
> >                         }
> >                       else
> >                       {
> >                            //dont change the browser view and stay at
> > current panel/view/page. This also means child panel can not be
> > recovered and there must be some problem with history tokens provided.
> >                       }
>
> >                 }
> >                 if("profile".equalsIgnoreCase(page))
> >                 {
> >                         returnValue =
> > prodilePanel.recoverPanelFromHistory(historyTokens); //and this
> > function will calls its child panels if they support history
> >                         if(returnValue )
> >                         {
> >                                 mainContentPanel.clear(); //clearing the 
> > mainPanel view of client
> >                                 mainContentPanel.add(profilePanel); //and 
> > adding the view
> > according to history token value
> >                         }
> >                       else
> >                       {
> >                            //dont change the browser view and stay at
> > current panel/view/page. This also means child panel can not be
> > recovered and there must be some problem with history tokens provided.
> >                       }
>
> >                 }
> >                 return returnValue;
>
> >         }
>
> > So till now theoretically it sounds good and works good.
>
> > Problem starts when lets say user lost his Internet connection or call
> > fail at server because of any system level error..
>
> > userHomePanel.recoverPanelFromHistory(historyTokens);
>
> > This function does following things.
> > 1) get the data from cache for this panel
> > 2) if found call loadDataIntoPanel(data) function and load it into
> > panel and return true.
> > 3)  else call the server to get data.
> >     Now server call is async and I need to return some value from
> > userHomePanel.recoverPanelFromHistory(historyTokens);, so if i return
> > true and call fails at server because of some network problem then
> > ideally i dont want to switch to new view as per this history action
> > but my function has already returned true and mainPanle has already
> > changed the view to new panel.
> > Now i dont want child panels to call parentPanel's method to tell them
> > later that server call was success or failure so that main parent
> > panel can decide whethere i should switch panels/view or not. If child
> > need to know parent then my all panels will be too much dependent on
> > each other and they will be too much crossed chain to each other.
>
> > If you see gmail it uses such features. If you have loaded ur inbox
> > and then you lost ur internet connection and then u click on any
> > email. Then gmail doesnt take you to single mail viewer page and then
> > tell "oh u lost ur connection" but it just keep you on inbox view an

Re: History and server call.

2010-06-16 Thread Tristan
sounds like you're reinventing the place service, with event bus, with
local cache rpc service, but doing it in a new, innovative, complex
and if the code grows on you perhaps unintelligible way. if you're the
only one who will support this ever, that may work. otherwise i would
seriously look into a bunch of mvp-like frameworks out there and look
at how place services/managers, local caches, and event buses are
implemented. you don't need to use the framework, but the concepts are
very helpful to organize the code. they're straightforward and most
people understand the design.

On Jun 16, 5:46 am, Thomas Broyer  wrote:
> On Jun 16, 3:52 am, Sky  wrote:
>
>
>
>
>
> > Well, I don't know about the event bus and I have yet to watch that
> > GWT best practices video (but I really should!) and I haven't done MVP
> > with GWT, BUT I'm super creative so here's what I would do with your
> > situation! :D
>
> > I would have an object that is rather more aware of the all
> > recoverPanelFromHistory async actions going on. This object would
> > store a copy of each other object that is performing the
> > recoverPanelFromHistory for a specific panel. (in other words a list
> > of objects that have the method(s) controlling all that async
> > goodness) The code inside recoverPanelFromHistory() that does the
> > async data retrieval from the server would talk back to this object,
> > which is the "owner". It tells the Owner that it's finished getting
> > the data (even when it already had the data cached). Every time the
> > owner gets told that one of it's "subjects" finished getting data it
> > checks to see if that was the last "subject" to get it's data, and if
> > so it talks to the mainContentPanel and gets it to do it's view change
> > (clear and add). Inside the recoverPanelFromHistory code you can do
> > your repeatedly trying to obtain the data and even if you don't get
> > the data until a day later when the user finally reconnects your code
> > will be able to continue on no prob.
>
> > Did that make sense? It makes sense in my head, so if it doesn't make
> > perfect sense to you ask me to clarify things and I'll do my best!
>
> Totally makes sense. In other words: make recoverPanelFromHistory
> async, with a callback passed as an argument rather than returning a
> value; and if data is cached, then just use the callback synchronously
> (of call it from a Scheduler.scheduleFinally if it makes you nervous
> to have your async call actually be synchronous)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-16 Thread Thomas Broyer


On Jun 16, 3:52 am, Sky  wrote:
> Well, I don't know about the event bus and I have yet to watch that
> GWT best practices video (but I really should!) and I haven't done MVP
> with GWT, BUT I'm super creative so here's what I would do with your
> situation! :D
>
> I would have an object that is rather more aware of the all
> recoverPanelFromHistory async actions going on. This object would
> store a copy of each other object that is performing the
> recoverPanelFromHistory for a specific panel. (in other words a list
> of objects that have the method(s) controlling all that async
> goodness) The code inside recoverPanelFromHistory() that does the
> async data retrieval from the server would talk back to this object,
> which is the "owner". It tells the Owner that it's finished getting
> the data (even when it already had the data cached). Every time the
> owner gets told that one of it's "subjects" finished getting data it
> checks to see if that was the last "subject" to get it's data, and if
> so it talks to the mainContentPanel and gets it to do it's view change
> (clear and add). Inside the recoverPanelFromHistory code you can do
> your repeatedly trying to obtain the data and even if you don't get
> the data until a day later when the user finally reconnects your code
> will be able to continue on no prob.
>
> Did that make sense? It makes sense in my head, so if it doesn't make
> perfect sense to you ask me to clarify things and I'll do my best!

Totally makes sense. In other words: make recoverPanelFromHistory
async, with a callback passed as an argument rather than returning a
value; and if data is cached, then just use the callback synchronously
(of call it from a Scheduler.scheduleFinally if it makes you nervous
to have your async call actually be synchronous)

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.



Re: History and server call.

2010-06-15 Thread Sky
Well, I don't know about the event bus and I have yet to watch that
GWT best practices video (but I really should!) and I haven't done MVP
with GWT, BUT I'm super creative so here's what I would do with your
situation! :D

I would have an object that is rather more aware of the all
recoverPanelFromHistory async actions going on. This object would
store a copy of each other object that is performing the
recoverPanelFromHistory for a specific panel. (in other words a list
of objects that have the method(s) controlling all that async
goodness) The code inside recoverPanelFromHistory() that does the
async data retrieval from the server would talk back to this object,
which is the "owner". It tells the Owner that it's finished getting
the data (even when it already had the data cached). Every time the
owner gets told that one of it's "subjects" finished getting data it
checks to see if that was the last "subject" to get it's data, and if
so it talks to the mainContentPanel and gets it to do it's view change
(clear and add). Inside the recoverPanelFromHistory code you can do
your repeatedly trying to obtain the data and even if you don't get
the data until a day later when the user finally reconnects your code
will be able to continue on no prob.

Did that make sense? It makes sense in my head, so if it doesn't make
perfect sense to you ask me to clarify things and I'll do my best!

You'll have to do some refactoring... the code inside
recoverPanelFromHistory() that does the depth search through all
children and fires recoverPanelFromHistory() on all children and their
children you'll want to still happen at the place where you currently
call recoverPanelFromHistory() from the top of the tree... BUT you'll
want to refactor the code that does the data cache check and then
calls the async-data-get out of that method. The depth search of all
children will add each child (aka "subject") to the Owner object.
After the Owner knows about all of it's subjects it then loops through
and calls the recoverPanelFromHistory() code which does the data cache
check and asyn-data-get goodness. This way the owner doesn't think
it's done loading just cuz the first subject added has it's data
cached and immediately tells the owner before any other subjects have
been added. did that make sense?

btw, did I just invent an event bus?

cheers! ^_^

On Jun 15, 8:23 pm, fmod  wrote:
> Using the event bus may help 
> there.http://code.google.com/events/io/2009/sessions/GoogleWebToolkitBestPr...
> and the two 
> articleshttp://code.google.com/webtoolkit/articles/mvp-architecture.html
>
> On Jun 15, 9:14 am, ping2ravi  wrote:
>
>
>
> > Hi Guys,
> > I have just implemented a multipage(basically multi url) website using
> > History. It works great using history token. But i need something else
> > from GWT which i am not able to solve.
> > Now when user clicks on something(link/button etc) i add the token to
> > History and my history callbacks get called.
> > Now in history value change handler i do something like this
>
> > 1) FInd out what page need to be dispalyed(basically identify the
> > panels etc).
> > 2) now each of my panel which can have history implementing
> > hasHistory(my own) interface, which has function
> > recoverPanelFromHistory.
> > 3) In this function, i check if i have client side data cahced for
> > this panel, if yes then load it into panel and display it(basically
> > add to main panel widget tree).
> > 4) But if no cache data found then go to server and get data.
>
> > one such implementation
> > @Override
> >         public boolean recoverPanelFromHistory(Map
> > historyTokens) {
> >                 String page = historyTokens.get(PAGE_PARAM);
> >                 boolean returnValue = false;
> >                 if("home".equalsIgnoreCase(page))
> >                 {
> >                         returnValue =
> > userHomePanel.recoverPanelFromHistory(historyTokens); //and this
> > function will calls its child panels if they support history
> >                         if(returnValue )
> >                         {
> >                                 mainContentPanel.clear(); //clearing the 
> > mainPanel view of client
> >                                 mainContentPanel.add(userHomePanel); //and 
> > adding the view
> > according to history token value
> >                         }
> >                       else
> >                       {
> >                            //dont change the browser view and stay at
> > current panel/view/page. This also means child panel can not be
> > recovered and there must be some problem with history tokens provided.
> >                       }
>
> >                 }
> >                 if("profile".equalsIgnoreCase(page))
> >                 {
> >                         returnValue =
> > prodilePanel.recoverPanelFromHistory(historyTokens); //and this
> > function will calls its child panels if they support history
> >                         if(returnValue )
> >            

Re: History and server call.

2010-06-15 Thread fmod
Using the event bus may help there.
http://code.google.com/events/io/2009/sessions/GoogleWebToolkitBestPractices.html
and the two articles 
http://code.google.com/webtoolkit/articles/mvp-architecture.html


On Jun 15, 9:14 am, ping2ravi  wrote:
> Hi Guys,
> I have just implemented a multipage(basically multi url) website using
> History. It works great using history token. But i need something else
> from GWT which i am not able to solve.
> Now when user clicks on something(link/button etc) i add the token to
> History and my history callbacks get called.
> Now in history value change handler i do something like this
>
> 1) FInd out what page need to be dispalyed(basically identify the
> panels etc).
> 2) now each of my panel which can have history implementing
> hasHistory(my own) interface, which has function
> recoverPanelFromHistory.
> 3) In this function, i check if i have client side data cahced for
> this panel, if yes then load it into panel and display it(basically
> add to main panel widget tree).
> 4) But if no cache data found then go to server and get data.
>
> one such implementation
> @Override
>         public boolean recoverPanelFromHistory(Map
> historyTokens) {
>                 String page = historyTokens.get(PAGE_PARAM);
>                 boolean returnValue = false;
>                 if("home".equalsIgnoreCase(page))
>                 {
>                         returnValue =
> userHomePanel.recoverPanelFromHistory(historyTokens); //and this
> function will calls its child panels if they support history
>                         if(returnValue )
>                         {
>                                 mainContentPanel.clear(); //clearing the 
> mainPanel view of client
>                                 mainContentPanel.add(userHomePanel); //and 
> adding the view
> according to history token value
>                         }
>                       else
>                       {
>                            //dont change the browser view and stay at
> current panel/view/page. This also means child panel can not be
> recovered and there must be some problem with history tokens provided.
>                       }
>
>                 }
>                 if("profile".equalsIgnoreCase(page))
>                 {
>                         returnValue =
> prodilePanel.recoverPanelFromHistory(historyTokens); //and this
> function will calls its child panels if they support history
>                         if(returnValue )
>                         {
>                                 mainContentPanel.clear(); //clearing the 
> mainPanel view of client
>                                 mainContentPanel.add(profilePanel); //and 
> adding the view
> according to history token value
>                         }
>                       else
>                       {
>                            //dont change the browser view and stay at
> current panel/view/page. This also means child panel can not be
> recovered and there must be some problem with history tokens provided.
>                       }
>
>                 }
>                 return returnValue;
>
>         }
>
> So till now theoretically it sounds good and works good.
>
> Problem starts when lets say user lost his Internet connection or call
> fail at server because of any system level error..
>
> userHomePanel.recoverPanelFromHistory(historyTokens);
>
> This function does following things.
> 1) get the data from cache for this panel
> 2) if found call loadDataIntoPanel(data) function and load it into
> panel and return true.
> 3)  else call the server to get data.
>     Now server call is async and I need to return some value from
> userHomePanel.recoverPanelFromHistory(historyTokens);, so if i return
> true and call fails at server because of some network problem then
> ideally i dont want to switch to new view as per this history action
> but my function has already returned true and mainPanle has already
> changed the view to new panel.
> Now i dont want child panels to call parentPanel's method to tell them
> later that server call was success or failure so that main parent
> panel can decide whethere i should switch panels/view or not. If child
> need to know parent then my all panels will be too much dependent on
> each other and they will be too much crossed chain to each other.
>
> If you see gmail it uses such features. If you have loaded ur inbox
> and then you lost ur internet connection and then u click on any
> email. Then gmail doesnt take you to single mail viewer page and then
> tell "oh u lost ur connection" but it just keep you on inbox view and
> keep trying and after some time stop trying.
>
> How can i achieve such functionality.?
> Are there any existing libraries to do that or any particular design
> pattern is there?
>
> Thanks, in advance
>
> Ravi.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool

History and server call.

2010-06-15 Thread ping2ravi
Hi Guys,
I have just implemented a multipage(basically multi url) website using
History. It works great using history token. But i need something else
from GWT which i am not able to solve.
Now when user clicks on something(link/button etc) i add the token to
History and my history callbacks get called.
Now in history value change handler i do something like this

1) FInd out what page need to be dispalyed(basically identify the
panels etc).
2) now each of my panel which can have history implementing
hasHistory(my own) interface, which has function
recoverPanelFromHistory.
3) In this function, i check if i have client side data cahced for
this panel, if yes then load it into panel and display it(basically
add to main panel widget tree).
4) But if no cache data found then go to server and get data.


one such implementation
@Override
public boolean recoverPanelFromHistory(Map
historyTokens) {
String page = historyTokens.get(PAGE_PARAM);
boolean returnValue = false;
if("home".equalsIgnoreCase(page))
{
returnValue =
userHomePanel.recoverPanelFromHistory(historyTokens); //and this
function will calls its child panels if they support history
if(returnValue )
{
mainContentPanel.clear(); //clearing the 
mainPanel view of client
mainContentPanel.add(userHomePanel); //and 
adding the view
according to history token value
}
  else
  {
   //dont change the browser view and stay at
current panel/view/page. This also means child panel can not be
recovered and there must be some problem with history tokens provided.
  }

}
if("profile".equalsIgnoreCase(page))
{
returnValue =
prodilePanel.recoverPanelFromHistory(historyTokens); //and this
function will calls its child panels if they support history
if(returnValue )
{
mainContentPanel.clear(); //clearing the 
mainPanel view of client
mainContentPanel.add(profilePanel); //and 
adding the view
according to history token value
}
  else
  {
   //dont change the browser view and stay at
current panel/view/page. This also means child panel can not be
recovered and there must be some problem with history tokens provided.
  }

}
return returnValue;

}

So till now theoretically it sounds good and works good.

Problem starts when lets say user lost his Internet connection or call
fail at server because of any system level error..

userHomePanel.recoverPanelFromHistory(historyTokens);

This function does following things.
1) get the data from cache for this panel
2) if found call loadDataIntoPanel(data) function and load it into
panel and return true.
3)  else call the server to get data.
Now server call is async and I need to return some value from
userHomePanel.recoverPanelFromHistory(historyTokens);, so if i return
true and call fails at server because of some network problem then
ideally i dont want to switch to new view as per this history action
but my function has already returned true and mainPanle has already
changed the view to new panel.
Now i dont want child panels to call parentPanel's method to tell them
later that server call was success or failure so that main parent
panel can decide whethere i should switch panels/view or not. If child
need to know parent then my all panels will be too much dependent on
each other and they will be too much crossed chain to each other.

If you see gmail it uses such features. If you have loaded ur inbox
and then you lost ur internet connection and then u click on any
email. Then gmail doesnt take you to single mail viewer page and then
tell "oh u lost ur connection" but it just keep you on inbox view and
keep trying and after some time stop trying.

How can i achieve such functionality.?
Are there any existing libraries to do that or any particular design
pattern is there?

Thanks, in advance

Ravi.



-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-tool...@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.