Sunday, May 18, 2014

Re: extend UiBinder engine

Hi Jens,

Thanks for your answer, I didn't see you did.

I visibly don't need to rewrite the UiBinderGenerator, there's space left for non generating a field in com.google.gwt.uibinder.rebind.FieldWriter : it's specified in the javadoc

The weired thing is that I don't understand from the comment  (In the rare case that you need a field not to be initialized, initialize it to "null".)

what they want me to initialize to null: it's clearly visible in the implementation com.google.gwt.uibinder.rebind.AbstractFieldWriter.write(IndentedWriter)  that if initializer is null, the code generation defalts to GWT.create

 public void write(IndentedWriter w) throws UnableToCompleteException {
    if (written) {
      return;
    }

    for (FieldWriter f : needs) {
      f.write(w);
    }

    if (initializer == null) {
      JClassType type = getInstantiableType();
      if (type != null) {
        if ((type.isInterface() == null)
            && (type.findConstructor(new JType[0]) == null)) {
          logger.die(NO_DEFAULT_CTOR_ERROR, type.getQualifiedSourceName(),
              type.getName());
        }
      }
    }

    if (null == initializer) {
      initializer = String.format("(%1$s) GWT.create(%1$s.class)",
          getQualifiedSourceName());
    }


Le dimanche 18 mai 2014 23:22:23 UTC+1, Jens a écrit :
You would need to extend (or even replace) UiBinderGenerator and then use deferred binding like in UiBinder.gwt.xml to use your custom UiBinderGenerator.

However I would find it a lot easier to write an annotation processor that generates a class next to your UiBinder java file and that contains the code to setVisible(true/false) your UiFields.

-- J.

--
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+unsubscribe@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.

No comments:

Post a Comment