Reputation: 25
I am trying to encode input form data here. There are two options and I have tried both of them:
URLencoder.encode(inputString)
method which does not work on GWT client side (My code resides in client module) Results in error 'Did you forget to inherit required module?'URL.encodeQueryString(inputString)
which works well, But when I run relevant test cases using JUnit, all I get is unsatisfiedlinkederror
Are there any alternatives for encoding method or is there any work around for above mentioned methods?
Upvotes: 0
Views: 3501
Reputation: 4366
For URL building, I use the "UrlBuilder": com.google.gwt.http.client.UrlBuilder
UrlBuilder u = new UrlBuilder();
u.setProtocol("https");
u.setHost("www.mysite.com:8080");
u.setPath("/myServletPath");
u.setParameter("username", nameField.getValue());
u.setParameter("someAttribute", "itsValue");
u.buildString();
This code will result in: https://www.mysite.com:8080/myServlet?username=GWT%20User&someAttribute=itsValue
Upvotes: 0
Reputation: 3048
Just use the URL
class and its methods:
Do not forget to inherit the required module <inherits name="com.google.gwt.http.HTTP"/>
.
Upvotes: 0
Reputation: 91
For your second option : GWT uses modules and needs to be compiled, which is different than running a simple JUnit test. Take a look at http://www.gwtproject.org/doc/latest/DevGuideTesting.html, they explain how to setup JUnit test.
Upvotes: 1