EzDevInfo.com

gwt interview questions

Top gwt frequently asked interview questions

Why use GWT.create() instead of new?

What is the difference between GWT.create(SomeClass.class) and new SomeClass()?

Why would you use one over the other?


Source: (StackOverflow)

Maven GWT 2.0 and Eclipse

Does anyone know of a good guide for creating a project with the new 2.0 release of GWT using maven and eclipse? I am running into a lot of problems getting them to play nicely together.

For what it's worth, I can create a gwt project using the maven eclipse plugin which works fine, but porting it to maven doesn't work (so a guide for this would be great).

Likewise, I can use the maven plugin (gwt-maven-plugin), but when I import it to eclipse (import -> materialize maven projects), it does not get recognised as a GWT project...

Thanks


Source: (StackOverflow)

Advertisements

GWT: Capturing URL parameters in GET request

I need to build a GWT application that will be called by an external application with specific URL parameters.

For example:

http://www.somehost.com/com.app.client.Order.html?orderId=99999.

How do I capture the orderId parameter inside the GWT application?


Source: (StackOverflow)

Biggest GWT Pitfalls?

I'm at the beginning/middle of a project that we chose to implement using GWT. Has anyone encountered any major pitfalls in using GWT (and GWT-EXT) that were unable to be overcome? How about from a performance perspective?

A couple things that we've seen/heard already include:

  • Google not being able to index content
  • CSS and styling in general seems to be a bit flaky

Looking for any additional feedback on these items as well. Thanks!


Source: (StackOverflow)

How to do calendar operations in Java GWT? How to add days to a Date?

Since GWT does not provide the GregorianCalendar class, how to do calendar operations on the client?

I have a Date a and I want the Date, which is n days after a.

Examples:

a (2000-01-01) + n (1) -> 2000-01-02
a (2000-01-01) + n (31) -> 2000-02-01

Source: (StackOverflow)

How do I pass a class as a parameter in Java?

Is there any way to pass class as a parameter in Java and fire some methods from that class?

void main()
{
    callClass(that.class)
}

void callClass(???? classObject)
{
    classObject.somefunction
    // or 
    new classObject()
    //something like that ?
}

I am using Google Web Toolkit and it does not support reflection.


Source: (StackOverflow)

Should I use Vaadin Framework [closed]

I just tried to play with Vaadin Framework and it seems to me very easy to use. Plus what I like about his framework is that it is built on top of GWT. What do you think, should I continue using this framework or it's better to stick with GWT.


Source: (StackOverflow)

When should I use RequestFactory vs GWT-RPC?

I am trying to figure out if I should migrate my gwt-rpc calls to the new GWT2.1 RequestFactory cals.

Google documentation vaguely mentions that RequestFactory is a better client-server communication method for "data-oriented services"

What I can distill from the documentation is that there is a new Proxy class that simplifies the communication (you don't pass back and forth the actual entity but just the proxy, so it is lighter weight and easier to manage)

Is that the whole point or am I missing something else in the big picture?


Source: (StackOverflow)

Interface/enum listing standard mime-type constants

I am looking among the standard libraries (like apache commons, jax, jboss, javax) for an interface or enum that lists the values of all the standard mime-type (aka content-type).

This interface should not be encumbered with too deep with other classes that would make it difficult to include the whole bunch as gwt source code.

for example

interface ContentType{
  String JSON = "Application/JSON";
  blah ... blah ...
}

or,

enum ContentType{
  JSON("Application/JSON"),
  blah ... blah ...
}

Source: (StackOverflow)

What is the meaning of double tilde (~~) in Java?

When browsing the source code of Guava, I came across the following piece of code (part of the implementation of hashCode for the inner class CartesianSet):

int adjust = size() - 1;
for (int i = 0; i < axes.size(); i++) {
    adjust *= 31;
    adjust = ~~adjust;
    // in GWT, we have to deal with integer overflow carefully
}
int hash = 1;
for (Set<E> axis : axes) {
    hash = 31 * hash + (size() / axis.size() * axis.hashCode());

    hash = ~~hash;
}
hash += adjust;
return ~~hash;

Both of adjust and hash are ints. From what I know about Java, ~ means bitwise negation, so adjust = ~~adjust and hash = ~~hash should leave the variables unchanged. Running the small test (with assertions enabled, of course),

for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
    assert i == ~~i;
}

confirms this. Assuming that the Guava guys know what they are doing, there must be a reason for them to do this. The question is what?

EDIT As pointed out in the comments, the test above doesn't include the case where i equals Integer.MAX_VALUE. Since i <= Integer.MAX_VALUE is always true, we will need to check that case outside the loop to prevent it from looping forever. However, the line

assert Integer.MAX_VALUE == ~~Integer.MAX_VALUE;

yields the compiler warning "Comparing identical expressions", which pretty much nails it.


Source: (StackOverflow)

How do I speed up the gwt compiler?

We're starting to make heavier use of GWT in our projects, and the performance of the GWT compiler is becoming increasingly annoying.

We're going to start altering our working practices to mitigate the problem, including a greater emphasis on the hosted-mode browser, which defers the need to run the GWT compiler until a later time, but that brings its own risks, particularly that of not catching issues with real browsers until much later than we'd like.

Ideally, we'd like to make the GWT compiler itself quicker - a minute to compile a fairly small application is taking the piss. However, we are using the compile if a fairly naive fashion, so I'm hoping we can make some quick and easy gains.

We're currently invoking com.google.gwt.dev.Compiler as a java application from ant Ant target, with 256m max heap and lots of stack space. The compiler is launched by Ant using fork=true and the latest Java 6 JRE, to try and take advantage of Java6's improved performance. We pass our main controller class to the compiler along with the application classpath, and off it goes.

What else can we do to get some extra speed? Can we give it more information so it spends less time doing discovery of what to do?

I know we can tell it to only compile for one browser, but we need to do multi-browser testing, so that's not really practical.

All suggestions welcome at this point.


Source: (StackOverflow)

Best GWT widget library? [closed]

Question for all the GWT gurus out there - which is the best GWT widgets library out there? And why?

List based on the answers:

И наконец- новое поколение основанное на JsInterop:


Source: (StackOverflow)

Why should I use jQuery instead of GWT? [closed]

I need to decide between jQuery and GWT for my new project.

I haven't programmed in JavaScript for a while, and I was looking into GWT for the last few days. It looks pretty awesome, generating all the different JS for different browsers and all, however:

  • developing in Java takes more time than the same thing using jQuery (at least for this project)
  • the documentation is poor (for example, how should I know which elements should I use when designing the page? -- there's not enough documentation for this)

I've been using jQuery for most of my projects and it's pretty good.

I want to convince the client that jQuery is better suited for this project and I need more arguments to support this.


Source: (StackOverflow)

Is a colon safe for friendly-URL use?

We are designing a URL system that will specify application sections as words separated by slashes. Specifically, this is in GWT, so the relevant parts of the URL will be in the hash (which will be interpreted by a controller layer on the client-side):

http://site/gwturl#section1/section2

Some sections may need additional attributes, which we'd like to specify with a :, so that the section parts of the URL are unambiguous. The code would split first on /, then on :, like this:

http://site/gwturl#user:45/comments

Of course, we are doing this for url-friendliness, so we'd like to make sure that none of these characters which will hold special meaning will be url-encoded by browsers, or any other system, and end up with a url like this:

http://site/gwturl#user%3A45/comments <--- BAD

Is using the colon in this way safe (by which I mean won't be automatically encoded) for browsers, bookmarking systems, even Javascript or Java code?


Source: (StackOverflow)

Regular Expressions and GWT

My questions is: Is there a good solution to use regular expression in GWT?

I'm not satisfied with the use of String.split(regex) for example. GWT translates the Code to JS and then uses the regex as a JS regex. But I cannot use something like the Java Matcher or Java Pattern. But I would need these for group matching.

Is there any possibility or library?

I tried Jakarta Regexp, but I had other problems because GWT doesn't emulate all methods of the Java SDK this library uses.

I want to be able to use something like this on the client side:

// Compile and use regular expression
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr);
boolean matchFound = matcher.find();

if (matchFound) {
    // Get all groups for this match
    for (int i=0; i<=matcher.groupCount(); i++) {
        String groupStr = matcher.group(i);
        System.out.println(groupStr);
    }
}

Source: (StackOverflow)