Re: Pb with activity and events (using gin)
> > 1) In the comment to your code, it's said that a Scheduler must be also > managed by GIN. Therefore, the question if it is a bad practice to use > Scheduler.get(), while the rest of the project is managed by GIN? How > about RootPanel.get() (or RootLayoutPanel.get()) factory calls? Seems > like one must replace all no-parameter calls of that kind with injections. > Correct me if I'm wrong. > Depends on your testing strategy. GWTs Scheduler uses GWT.create and JSNI so if you use it inside a presenter/activity you must test it with GWTTestCase (slow) or use a library like gwtmockito which does some heavy magic to disable GWT.create() calls. If you inject your Scheduler you can use JUnit directly as you can just pass in a fake Scheduler implementation. So it is not a must, but IMHO a good idea to do so. > 2) Back to the main subject about EventBus. Actually I tried > scheduler.scheduleDeferred()before I started looking for solutions. Seems > like only scheduler.scheduleFinally() defers the event firing long enough > to give other activities time to append their handlers withing start() > method. At least in my particular case I encountered the "racing" condition > between activities for header, content and other sections of my layout. > Therefore, while there's no parallel computation in browser, GWT approach > with deferred tasks adds some unexplainable magic to the process of > debugging. I'm not even sure if I ever gonna prefer scheduleDeferred() to > scheduleFinally() from now on. > Actually it is the other way around: scheduleDeferred() delays the code longer than scheduleFinally(). scheduleFinally() is executed right after your normal code but before the browser gets control again, while a deferred command is executed via a JS timeout so the browser had control for some time before the command executes. > 3) I still need to fire events manually sometimes. Therefore I do inject > EventBus instance to some of the activities. Despite the fact start() > method uses different instance of EventBus, the code still works fine > like if it's all one single instance. This discovery confuses me a lot, > because buses are clearly different. How is it it even possible? And what > might be the best practice of using EventBus with Activities&Places + GIN? > Normally in GIN your EventBus is a singleton and you use it to initialize the activity/places framework. In your Activity.start() method you get a special ResettableEventBus which wraps the singleton EventBus you passed into the activity framework. This ResettableEventBus clears all handlers an activity has added automatically once the activity is stopped. Thats why you should prefer storing the EventBus provided by the start method in a field instead of injecting an EventBus again. I have often seen code where people have injected an EventBus and then forgot to cleanup the handlers which results in a memory leak as the singleton EventBus lives to the entire app lifetime. -- J. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Re: Is there a tutorial that explains Places and Hyperlinks?
In general the hash fragment the GWT places framework generates consists of two parts: a unique prefix that represents the place type and a token that contains the serialized state of a place instance. Both are separated by a colon. You can use @Prefix to change the default unique prefix of a Place which is the concrete Place class simple name, e.g. CustomerPlace. To fill a Hyperlink target history token you would use the PlaceHistoryMapper.getToken(new CustomerPlace()) method which basically returns Prefix + ":" + tokenizer.getToken(place) . If you don't like the colon you can also use your own logic by either implementing the PlaceHistoryMapper interface yourself or by creating just a single PlaceTokenizer with a prefix @Prefix(""). This tokenizer will act as a catch-all tokenizer and you can then freely implement your getToken() / getPlace() logic for all places inside that tokenizer. The catch-all tokenizer is kind of a cheat, so I would prefer implementing PlaceHistoryMapper directly. For example my apps usually use history tokens that look like /#!/archive/2014/august/ -- J. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Is there a tutorial that explains Places and Hyperlinks?
I'm writing a GWT app and trying to make Hyperlink widgets work. I've read http://www.gwtproject.org/doc/latest/DevGuideMvpActivitiesAndPlaces.html and some of the API docs, but it doesn't seem coherent. For instance, that web page says I can use an "@Prefix" annotation on a PlaceTokenizer to change the first part of the URL associated with a Place, but it doesn't show an example or tell me why I would want to do that. Also, all of the examples I can find of the Hyperlink widget show the target history token as a single word, with no colon. When I look in Google's AbstractPlaceHistoryMapper.getPlace(), however, it expects a colon. If the token has no colon then the tokenizer can't be found. Am I missing some documentation? Is there a good intro to this subject out there? -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Re: Pb with activity and events (using gin)
Thank you so much, Thomas. Your solution is very helpful. Though I still have three more questions: 1) In the comment to your code, it's said that a Scheduler must be also managed by GIN. Therefore, the question if it is a bad practice to use Scheduler.get(), while the rest of the project is managed by GIN? How about RootPanel.get() (or RootLayoutPanel.get()) factory calls? Seems like one must replace all no-parameter calls of that kind with injections. Correct me if I'm wrong. 2) Back to the main subject about EventBus. Actually I tried scheduler.scheduleDeferred()before I started looking for solutions. Seems like only scheduler.scheduleFinally() defers the event firing long enough to give other activities time to append their handlers withing start() method. At least in my particular case I encountered the "racing" condition between activities for header, content and other sections of my layout. Therefore, while there's no parallel computation in browser, GWT approach with deferred tasks adds some unexplainable magic to the process of debugging. I'm not even sure if I ever gonna prefer scheduleDeferred() to scheduleFinally() from now on. 3) I still need to fire events manually sometimes. Therefore I do inject EventBus instance to some of the activities. Despite the fact start() method uses different instance of EventBus, the code still works fine like if it's all one single instance. This discovery confuses me a lot, because buses are clearly different. How is it it even possible? And what might be the best practice of using EventBus with Activities&Places + GIN? On Tuesday, June 4, 2013 3:06:28 PM UTC+4, Thomas Broyer wrote: > > > > On Tuesday, June 4, 2013 12:46:16 PM UTC+2, Tugdual Huertas wrote: >> >> Hi all, >> >> i'm facing a litlle problem using places activities and events... Have >> tried multiple tricks but not luck . >> >> My problem: >> i try to fire an event from the activity but my widget does not catch it >> since its not loaded (I mean that if i fire this event once the widget's >> loaded everything works fine). >> >> Here is my Gin configuration: >> >> @Override >> protected void configure() >> { >>bind(EventBus.class).to(SimpleEventBus.class).asEagerSingleton(); >> >> >> bind(PlaceHistoryMapper.class).to(MyPlaceHistoryMapper.class).in(Singleton.class); >> >> bind(ActivityMapper.class).to(MyActivityMapper.class).in(Singleton.class); >>bind(MyActivity.class); >>install(new >> GinFactoryModuleBuilder().build(MyActivityMapper.Factory.class)); >> } >> >> @Provides >> @Singleton >> public PlaceController getPlaceController(EventBus eventBus) >> { >>return new PlaceController(eventBus); >> } >> >> @Singleton >> @Provides >> public ActivityManager provideActivityManager(ActivityMapper >> activityMapper, EventBus eventBus) >> { >>return new ActivityManager(activityMapper, eventBus); >> } >> >> in MyActivity: >> @Inject >> private MyWidget myWidget; >> @Inject >> private EventBus globalEventBus; >> >> @Override >> public void start(AcceptsOneWidget panel, EventBus eventBus) >> { >>panel.setWidget(myWidget); >>MyEvent event = new MyEvent(); >>event.setAction(MyEvent.Action.INIT); >>globalEventBus.fireEvent(event); >> } >> >> I also try two different ways of binding events in my widget, during >> onLoad and in constructor: >> >> During onLoad: >> >> @Inject EventBus eventBus; >> >> @Override >> protected void onLoad() >> { >>handlersRegistration.add(eventBus.addHandler(MyEvent.TYPE, this)); >> } >> >> >> In constructor: >> >> private EventBus eventBus; >> >> @Inject >> public MyWidget(EventBus eventBus) >> { >>this.eventBus = eventBus; >>// registration of handlers >>handlersRegistration = new ArrayList(); >>// register myself has a listener of different event TYPE >>handlersRegistration.add(eventBus.addHandler(MyEvent.TYPE, this)); >> >>... >> } >> >> >> Am I doing something w rong or missing something? >> > > All adds and removes of event handlers during the dispatching of an event > (which is the case when the activity starts: it's in response to a > PlaceChangeEvent) is deferred to after the event has been dispatched all > handlers. > Events however are dispatched synchronously (so that handlers can possibly > modify them and the sender take action depending on the event after the > dispatching; see setWarning for PlaceChangeRequestEvent). > So you have to defer your fireEvent() call using the Scheduler: > > // Assuming a Scheduler has been @Inject-ed > scheduler.scheduleFinally(new ScheduledCommand() { > @Override > public void execute() { > MyEvent event = new MyEvent(); > event.setAction(MyEvent.Action.INIT); > globalEventBus.fireEvent(event); > } > }); > > It's a good rule to always assume you might be called as part of event > dispatching unless you're handling UI events (click on a button, etc.) and > thus always defer your event dispatching in this case. >
newbie CellList Question (remove selected)
I'm using two CellLists as a multi-selection mechanism, both backed with a DataListProvider and KeyProvider for a small, private class (with a couple of strings). SimplePager for both lists. Basically the user can select multiple items from the "Left List" and push them over the the "Right List". Doing this because the options available in the left list could be pages long, and I want the user to easily see what has been selected as they page through their options. (Selected items are in the right list...like a shopping cart.) I have the lists working pretty well, and have a button to move the selected items from the left to the right. (Will have to do a de-select to move items back.) However, I'm puzzled as to how to determine which of the items in the DataListProvider's List I actually moved. I'm currently using SelectionModel.getSelectedSet(), and this accurately tells me what objects to add to the Right List, but not which items these actually are in the original List so that I can remove them. Is there a tip or trick to go about finding the currently selected items in a CellList and removing them from the underlying DataListProvider's List? Thanks in advance, AJ -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Re: GWT for Distribuited Computing
On Friday, September 19, 2014 12:32:34 AM UTC+2, Vincenzo Sambito wrote: > > Hello world, novice of Java my passion are the prime numbers for which I > developed this www.vincs.it which is among the top of Google search with > non-specific tag. Now, with this theory, I want to compete vs this > www.primegrid.com to create the largest database of prime numbers in the > world with the only perpetual sieve on-line, generator of prime numbers. > The tool that I want to build a platform for distributed computing: > - with GWT for the control panel on the server side for several reasons > including the presence of the already proven BigInteger library in GWT ( > https://code.google.com/p/gwt-math/) > FYI, gwt-math hasn't been updated for nearly 4 years …but BigInteger and BigDecimal have been built into GWT since almost the same date! (see https://code.google.com/p/google-web-toolkit/issues/detail?id=1857) -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
Re: Inside GWT compiler. How it works, and dose it use some interim outputs(eg XML )
There's also http://youtu.be/OGoJ451yiWM, no idea if (and how) the content is different though. On Friday, September 19, 2014 2:18:03 AM UTC+2, Jens wrote: > > Take a look at http://gwtcreate.com/2013/videos/#compiler-deep-dive > > -- J. > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
GWT for Distribuited Computing
Hello world, novice of Java my passion are the prime numbers for which I developed this www.vincs.it which is among the top of Google search with non-specific tag. Now, with this theory, I want to compete vs this www.primegrid.com to create the largest database of prime numbers in the world with the only perpetual sieve on-line, generator of prime numbers. The tool that I want to build a platform for distributed computing: - with GWT for the control panel on the server side for several reasons including the presence of the already proven BigInteger library in GWT (https://code.google.com/p/gwt-math/) - with an applet on the client as http://world.std.com/~reinhold/BigNumCalcSource/BigNumCalc.java distributed volunteers who harnesses the power of local computing Anyone willing to give me any suggestions or participate in any capacity on this project please write me publicly or even privately. Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscr...@googlegroups.com. To post to this group, send email to google-web-toolkit@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.