Problems with the @Optional annotation

54 views
Skip to first unread message

bliz

unread,
Nov 27, 2015, 7:49:12 AM11/27/15
to GWTP
Hi,

I'm having some problems using the @Optional annotation to generate events. I wrote the following class that would generate the event class.

@GenEvent
public class Error {


 
@Order(1) String message;
 
@Order(2) @Optional Throwable caught;
 
}


If I understood right the documentation on this page, the generated class should have two fire methods, one only with the message parameter and another one with both the message and caught parameters. However, I get this two constructors and fire methods.

public class ErrorEvent extends GwtEvent<ErrorEvent.ErrorHandler> { 

  java.lang.String message;
  java.lang.Throwable caught;

  public static class Builder { ... }
  
  public ErrorEvent(java.lang.String message) {
    this.message = message;
  }

  private ErrorEvent(Builder builder) {
    this.message = builder.message;
    this.caught = builder.caught;
  }

  public void fire(HasHandlers source) {
    source.fireEvent(this);
  }

  public static void fire(HasHandlers source, ErrorEvent eventInstance) {
    source.fireEvent(eventInstance);
  }

  ...


So I can't fire the event like this:

ErrorEvent.fire(this, message, caught);

or

ErrorEvent.fire(this, message);


On the contrary, if I remove the @Optional annotation I can fire the event using this line without problems:

ErrorEvent.fire(this, message, caught);


I would appreciate if anyone could help me.

Thank you.

Илья Альтерович

unread,
Oct 5, 2016, 4:47:56 PM10/5/16
to GWTP
Hi!
I have the same issue, coz I need ability to fire both methods, and it's very interested for me too how to resolve it!
Reply all
Reply to author
Forward
0 new messages