Not sure it's even possible, but would be nice to have. First the code:
public enum JqmButtonSize {
SMALL("sm"), LARGE("lg");
private final String bsSize;
private JqmButtonSize(String bsSize) {
this.bsSize = bsSize;
}
@JsMethod public String getBsSize() {
return bsSize;
}
}
@Component
public class JqmButton extends VueComponent {
@Prop @JsProperty JqmButtonSize size;
@Computed public String getCalcSize() {
return size != null ? size.getBsSize() : "";
}
}
And then it's used like:
<vue-gwt:import class="com.vx.JqmButtonSize" />
<jqm-button variant="primary" :size="JqmButtonSize.LARGE">Abc</jqm-button>
Probably there is a way to eliminate a need for manual vue-gwt:import, but anyway it works.
Then let's pretend we did some mistakes in template.
In case :size="aaa" we are getting error "Couldn't find variable/method "aaa" in the Component." during compile time, which is good.
But in case :size="222" we are not getting any error during compile time, but getting it in runtime, like "[Vue warn]: Error in render: "TypeError: this.size.getBsSize is not a function", which is too late and not very informative. IMO it would be nice to improve template generator to catch as much as possible Java types errors during compile time.
Not sure it's even possible, but would be nice to have. First the code:
And then it's used like:
Probably there is a way to eliminate a need for manual vue-gwt:import, but anyway it works.
Then let's pretend we did some mistakes in template.
In case :size="aaa" we are getting error "Couldn't find variable/method "aaa" in the Component." during compile time, which is good.
But in case :size="222" we are not getting any error during compile time, but getting it in runtime, like "[Vue warn]: Error in render: "TypeError: this.size.getBsSize is not a function", which is too late and not very informative. IMO it would be nice to improve template generator to catch as much as possible Java types errors during compile time.