GWT Interview Questions and Answers
Ques 26. What is the use GWT generator?
Generators allow the GWT coder to generate Java code at compile time and have it then be compiled along with the rest of the project into JavaScript.
Ques 27. How to make GWT Custom Event Handler?
This is an event that is triggered when the user becomes happy.
Define a new event class. You can add arbitrary metadata in the event class. For simplicity, we will not include any here though.
public class HappyEvent extends GwtEvent {
...
}
Define a new handler and marker interface for the event class.
interface HappyHandler extends EventHandler {
public void onHappiness(HappyEvent event);
}
interface HasHappyEvents {
public HandlerRegistration addHappyHandler(HappyHandler handler);
}
Add a unique event type
class HappyEvent extends AbstractEvent{
public static AbstractEvent.Key KEY = new AbstractEvent.Key(){...}
public GwtEvent.Key getKey(){
return KEY;
}
...
}
Wire up the handler's fire method
class HappyEvent extends GwtEvent {
static Key
protected void fire(HappyHandler handler, HappyEvent event) {
handler.onHappiness(event);
};
...
}
Most helpful rated by users:
- What is Google Web Toolkit (GWT)?
- How many modes are provided by GWT to execute application?
- What are Modules, Entry Points and HTML Pages in GWT?
- How can you set Browser targeted Compilation in GWT?
- How can we run GWT application?