trying to find out the cursor index in GWT RichTextArea
getCursor is available in GWT textarea and workd perfectly but I need to make the selected text Colored , Thats Why I am switching to RichTextArea . If there is anyway i can give color to the text of TextArea please suggest if not Please guide me how to get cursor position in GWt RichtextArea. I found One Solution using Javascript .(JSNI) with below code. But its giving me the cursor position as per each line , for example If I am on 1st line of my RichtextArea on 6th word it will say "6"(which is correct), but if I am on my 6th word on 3rd line it will again say "6" which is Wrong , That index should be the total of all three rows text. Can you please modify this Javascript or give me any other solution I have not much experience with Javascript public static native int getSelection(Element elem) /*-{ var txt = ""; var pos = 0; var range; var parentElement; var container; if (elem.contentWindow.getSelection) { txt = elem.contentWindow.getSelection(); pos = elem.contentWindow.getSelection().getRangeAt(0).startOffset; } else if (elem.contentWindow.document.getSelection) { txt = elem.contentWindow.document.getSelection(); pos = elem.contentWindow.document.getSelection().getRangeAt(0).startOffset; } else if (elem.contentWindow.document.selection) { range = elem.contentWindow.document.selection.createRange(); txt = range.text; parentElement = range.parentElement(); container = range.duplicate(); container.moveToElementText(parentElement); container.setEndPoint('EndToEnd', range); pos = container.text.length - range.text.length; } return pos; }-*/; -- 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.
Best server communication
Hi people I'm a newbie in GWT. I've made some apps but still using RPC. I was wondering now if there were a better way than that for server communication. 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.
Re: Request Factory Security
i want to check this code but the link is broken On Wednesday, December 21, 2011 10:38:04 AM UTC-4, Thomas Broyer wrote: > > > > On Wednesday, December 21, 2011 3:18:25 PM UTC+1, EMan wrote: >> >> there have been several posts on RequestFactory security, but I am still >> not clear. the sample code here: >> >> http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/expenses/src/main/java/com/google/gwt/sample/gaerequest/#gaerequest >> >> uses a filter to determine if a user can access the RequestFactory >> service. But what happens once a user authenticates? does he have access >> to all back end request? >> > > Yes. > > >> ie, if I have a findById method and a findAll (for my admin users) method >> in my locator, could a user authenticate, then post to either and receive >> all the data in my table? >> > > Yes. > > >> How do we authenticate individual types of request? >> > > Either do it at the start of each method (use > RequestFactoryServlet.getThreadLocalRequest().getUserPrincipal() to get the > current user). > Or create a ServiceLayerDecorator and override the > invoke(Method,Object...) method to add the check (probably based on some > annotation on the method). > I believe you could also use "standard AOP" (Spring AOP or Guice AOP, > probably also AspectJ or similar) on your services. > > We use the second approach, it works very well. > > -- 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: Using hammer.js for handling touch events/gesture recognitions?
Hi there I have created small GWT wrapper for hammer js Take a look at https://github.com/geomajas/geomajas-project-hammer-gwt On Tuesday, November 5, 2013 2:52:41 PM UTC+1, Manoula Orczyna wrote: > > Hi Ed! > > in the meantime i did write a tiny wrapper for hammer.js. It is kind of > incomplete, but if fits to my needs. > Of course my first idea was to use mgwts built-in capabilities for > handling touch events and gestures, however I'm afraid these functions are > a bit uggy. For example when trying to capture pinch-events on a canvas > not all of them were detected. > > Bye Manoula > > > -- 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: Use of reflection inside generator
On Saturday, June 21, 2014 6:31:47 PM UTC+2, Jens wrote: > > I don't think reflection will cause issues. I am pretty sure GIN > generators also use reflection to call into Guice and execute the > GinModule. GWT generators run in a JVM so you can use whatever you want. > BUT, in DevMode or SuperDevMode, code can change be recompiled on-the-fly, and generators be called again, and they should use the newly compiled classes. That means they have to use a specific classloader. GIN does this since 2.0, previously you had to restart DevMode for GIN to see the changes (because javac would recompile your classes, and restarting the JVM was the only way to "refresh" the classloader). If you can use JClassType et al. you should do it. An alternative is to use an annotation processor, independent of GWT. Run it to re-generate Java source code that DevMode/SuperDevMode will pick-up like any other source file. Dagger and AutoValue work that way, and integrate nicely with GWT (Dagger 2.0 though, not 1.0; 2.0 is still being developed and not yet released). I believe this is the future of codegen for GWT: generate Java code upfront instead of hooking into the GWT compilation, for every task where it's possible (there'll still be a need for GWT generators I think, at least for the time being). -- 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: Use of HandlerManager in GWT example code conflicts with javadoc
The doc was written before EventBus (or even Places and Activities) was introduced. There's a reason these are "articles" with a date in the heading ;-) So, follow the javadoc, use EventBus (but there's nothing fundamentally *wrong* using HandlerManager) On Thursday, June 19, 2014 9:19:42 PM UTC+2, Kay Pac wrote: > > I've been implementing the MVP pattern for my application. The description > of MVP on the site and the example code has been very helpful, especially > as I lack experience with GUI patterns and many descriptions of MVP and MVC > are somewhat abstract. However, I've noticed that the javadoc for > HandlerManager says that developers are strongly discouraged from using it > for an event dispatch mechanism, which is the opposite of what seems to be > suggested in the code (Contacts and Contacts2). Can someone clarify this > point for me? I'm wondering why the discrepancy, and if maybe we should > update the example code somehow. > > Kay > -- 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: Request Factory Security
Code has moved to gwt.googlesource.com, and the "expenses" sample has been retired since then. You can find the code at https://gwt.googlesource.com/gwt/+/2.4.0/samples/expenses/src/main/java/com/google/gwt/sample/gaerequest/#gaerequest (that was the version of the sample that shipped in GWT 2.4.0) On Thursday, June 19, 2014 8:45:35 PM UTC+2, Clive Cadogan wrote: > > i want to check this code but the link is broken > > On Wednesday, December 21, 2011 10:38:04 AM UTC-4, Thomas Broyer wrote: >> >> >> >> On Wednesday, December 21, 2011 3:18:25 PM UTC+1, EMan wrote: >>> >>> there have been several posts on RequestFactory security, but I am still >>> not clear. the sample code here: >>> >>> http://code.google.com/p/google-web-toolkit/source/browse/trunk/samples/expenses/src/main/java/com/google/gwt/sample/gaerequest/#gaerequest >>> >>> uses a filter to determine if a user can access the RequestFactory >>> service. But what happens once a user authenticates? does he have access >>> to all back end request? >>> >> >> Yes. >> >> >>> ie, if I have a findById method and a findAll (for my admin users) >>> method in my locator, could a user authenticate, then post to either and >>> receive all the data in my table? >>> >> >> Yes. >> >> >>> How do we authenticate individual types of request? >>> >> >> Either do it at the start of each method (use >> RequestFactoryServlet.getThreadLocalRequest().getUserPrincipal() to get the >> current user). >> Or create a ServiceLayerDecorator and override the >> invoke(Method,Object...) method to add the check (probably based on some >> annotation on the method). >> I believe you could also use "standard AOP" (Spring AOP or Guice AOP, >> probably also AspectJ or similar) on your services. >> >> We use the second approach, it works very well. >> >> -- 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: Use of reflection inside generator
I looked at annotation processor but there is one thing that is bothering me for my use case. If I have something like this : @GenMapper public interface PersonMapper extends JsonMapper {} or @GenMapper public class Person{ public Child child; } First compilation, my processor is called and the mapper is generated correctly. If I modify Person in the 1st example or Child in the 2nd one, the processor is not called and the mapper is not up to date unless I do a full recompilation. Otherwise, there was a few discussion about integrating a REST api inside GWT some time ago. Is this still planned ? If that's the case, any interest for a serialization mechanism based on Jackson annotations ? :) -- 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.
Server side JSR 303 validation issues
Hi, I get following error on throwing ConstraintViolationException from following server code. Validator jsr303Validator = Validation.buildDefaultValidatorFactory ().getValidator(); Set> violations = jsr303Validator. validate(userDto); if (!violations.isEmpty()) { Set> violationSet = new HashSet< ConstraintViolation>(violations); throw new ConstraintViolationException(violationSet); } com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.HashSet' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = [ConstraintViolationImpl{interpolatedMessage='Invalid user name.', propertyPath=name, rootBeanClass=class c.b.a.SomeClass, messageTemplate='Invalid user name.'} HashSet can certainly be serialized as I can throw exception with HashSet but throwing exception with HashSet> is not working! Any help is appreciated. I'm using GWT 2.5.1 Thanks. -- 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: Use of reflection inside generator
On Sunday, June 22, 2014 3:57:49 PM UTC+2, Nicolas Morel wrote: > > I looked at annotation processor but there is one thing that is bothering > me for my use case. > > If I have something like this : > @GenMapper > public interface PersonMapper extends JsonMapper {} > > or > > @GenMapper > public class Person{ > public Child child; > } > > First compilation, my processor is called and the mapper is generated > correctly. If I modify Person in the 1st example or Child in the 2nd one, > the processor is not called and the mapper is not up to date unless I do a > full recompilation. > Annotation processors are called by javac or whichever tool which compiles / pre-processes your code: javac or your IDE (or javac triggered by your IDE). So before you see the result in GWT, you have to run the annotation processor (this can be done automatically by your IDE or editor each time your hit Ctrl+S to save your changes). The thing is: it's totally independent from GWT, it's a pre-processing step before GWT is involved (before you launch DevMode/SuperDevMode/Compiler, before you refresh in DevMode, and/or before your hit "DevMode On" and "Compile" in SuperDevMode). So if your processor is not called, blame your tool (Eclipse, whatever) or blame yourself for not calling it. Otherwise, there was a few discussion about integrating a REST api inside > GWT some time ago. Is this still planned ? If that's the case, any interest > for a serialization mechanism based on Jackson annotations ? :) > Google might be more inclined to use GSON ;-) -- 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: Server side JSR 303 validation issues
Does your RPC declares ConstraintViolationException in its "throws" clause? On Sunday, June 22, 2014 4:51:46 PM UTC+2, Arpit wrote: > > Hi, > > I get following error on throwing ConstraintViolationException from > following server code. > > Validator jsr303Validator = Validation. > buildDefaultValidatorFactory().getValidator(); > Set> violations = jsr303Validator. > validate(userDto); > if (!violations.isEmpty()) { > Set> violationSet = new HashSet< > ConstraintViolation>(violations); > throw new ConstraintViolationException(violationSet); > } > > com.google.gwt.user.client.rpc.SerializationException: Type > 'java.util.HashSet' was not included in the set of types which can be > serialized by this SerializationPolicy or its Class object could not be > loaded. For security purposes, this type will not be serialized.: instance > = [ConstraintViolationImpl{interpolatedMessage='Invalid user name.', > propertyPath=name, rootBeanClass=class c.b.a.SomeClass, > messageTemplate='Invalid user name.'} > > HashSet can certainly be serialized as I can throw exception with > HashSet but throwing exception with HashSet> > is not working! Any help is appreciated. I'm using GWT 2.5.1 > > Thanks. > -- 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: Using hammer.js for handling touch events/gesture recognitions?
Thanks for sharing! 2014-06-20 10:20 GMT-03:00 Dosi Bingov : > Hi there I have created small GWT wrapper for hammer js Take a look at > > https://github.com/geomajas/geomajas-project-hammer-gwt > > > On Tuesday, November 5, 2013 2:52:41 PM UTC+1, Manoula Orczyna wrote: >> >> Hi Ed! >> >> in the meantime i did write a tiny wrapper for hammer.js. It is kind of >> incomplete, but if fits to my needs. >> Of course my first idea was to use mgwts built-in capabilities for >> handling touch events and gestures, however I'm afraid these functions are >> a bit uggy. For example when trying to capture pinch-events on a canvas >> not all of them were detected. >> >> Bye Manoula >> >> >> -- > 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. > -- 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 RequestFactory: IllegalArgumentException for setter only fields
Why is it mandatory to have both getters and setters for a field in RF Proxy interfaces? For some fields (like plain text password), you want setters only. e.g. @ProxyFor(value = User.class) public interface UserProxy extends ValueProxy { void setPassword(String password); } User class has both getters and setters. public class User implements Serializable { private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } When I set the password on proxy, I get an IllegalArgumentException: UserProxy user = userRequest.create(UserProxy.class); user.setPassword("abc"); Above code results in following error: java.lang.IllegalArgumentException: password at com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doCoderFor(AutoBeanCodexImpl.java:525) at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.setProperty(AbstractAutoBean.java:276) ... ... This error goes away if I add a 'getPassword()' method in UserProxy interface but that defeats the purpose. Any help is appreciated. Thanks, Arpit -- 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 RequestFactory: IllegalArgumentException for setter only fields
See https://code.google.com/p/google-web-toolkit/issues/detail?id=5760 I don't get why having a getter "defeats the purpose". Just because you have a getter does not mean there's a value to get. You could also have a setPassword "service method" instead (you can probably use your existing User#setPassword using an InstanceRequest setPassword(String password) method) On Monday, June 23, 2014 12:05:34 AM UTC+2, Arpit wrote: > > Why is it mandatory to have both getters and setters for a field in RF > Proxy interfaces? For some fields (like plain text password), you want > setters only. > e.g. > > @ProxyFor(value = User.class) > public interface UserProxy extends ValueProxy { > void setPassword(String password); > } > > > User class has both getters and setters. > > > public class User implements Serializable { > > private String password; > > public String getPassword() { > return password; > } > > public void setPassword(String password) { > this.password = password; > } > > > > When I set the password on proxy, I get an IllegalArgumentException: > > UserProxy user = userRequest.create(UserProxy.class); > user.setPassword("abc"); > > > > Above code results in following error: > java.lang.IllegalArgumentException: password > at > com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl.doCoderFor(AutoBeanCodexImpl.java:525) > at > com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.setProperty(AbstractAutoBean.java:276) > ... > ... > > This error goes away if I add a 'getPassword()' method in UserProxy > interface but that defeats the purpose. Any help is appreciated. > > Thanks, > Arpit > -- 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: WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Confirm that adding the key to the Wow6432Node as above does the trick. The other solutions didn't work for me. Could either be the difference between the 32/64bit versions, or java 1.7/1.8. -- 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: Ignoring requestFactory responses on page reload
Thomas, Thank you for the detailed answer (as always) :) Cheers Samin On Thursday, June 19, 2014 9:01:21 PM UTC+10, Thomas Broyer wrote: > > If you go to http://jsfiddle.net/vX8uK/ you'll see that you'll have an > onbeforeunload event (in GWT, Window.ClosingEvent) before the request is > abort with status=0, and then you have the onunload (in GWT, CloseEvent). > That means you can listen to Window.ClosingEvent and set a flag to ignore > subsequent errors. In case you have a prompt in Window.ClosingEvent added > by other means (e.g. Places & Activities), then you'll have to handle the > case where the user canceled the navigation and unset your flag; you can do > that, for example, by resetting the flag in case of successful response, > and/or listen to some mouse or keyboard events. > To centralize the flag processing, use a custom RequestTransport extending > the DefaultRequestTransport and wrapping the RequestCallback to deal with > the responses (at the RequestBuilder level, before they're transformed to > RequestFactory's Receiver calls) > > On Thursday, June 19, 2014 8:40:14 AM UTC+2, Samin Pour wrote: >> >> Hi Alberto, >> >> Thanks for your tip :) Unfortunately I can't inform the user to wait (I >> mean the product description is to let the user to do what ever they want >> without disturbing them) So I need to find the way to let the Receiver >> class not to wait for the response. >> >> Any ideas? >> >> Thanks again >> Samin >> >> On Tuesday, June 17, 2014 5:04:50 PM UTC+10, Alberto Mancini wrote: >>> >>> Hi Samir, >>> the page refresh should call the closinghandler cause a refresh is a >>> page unload followed by a load and the closing handler essentially >>> is a listener to 'onbeforeunload' event. >>> >>> Cheers, >>>Alberto >>> >>> Note: >>> there are issues with the returned message so if you go for a closing >>> handler read this also: >>> >>> http://stackoverflow.com/questions/5398772/firefox-4-onbeforeunload-custom-message >>> >>> >>> >>> >>> >>> >>> On Tue, Jun 17, 2014 at 7:10 AM, Samin Pour wrote: >>> Thanks Alberto :) Isn't this handler triggered for closing the Window? I'm just refreshing a page which doesn't fire the associated event. Or am I missing something? Thanks again Samin On Friday, June 13, 2014 10:31:25 PM UTC+10, Alberto Mancini wrote: > > Hi, > may be not a solution in your context but a choice can be also using > http://www.gwtproject.org/javadoc/latest/com/google/gwt/ > user/client/Window.html#addWindowClosingHandler%28com. > google.gwt.user.client.Window.ClosingHandler%29 > to inform the user that should wait until the response is ready. > I think it is at least less dangerous than ignoring eventual errors. > > Alberto. > > > > > > -- 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-we...@googlegroups.com. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout. >>> >>> -- 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.