gwtproject / gwt-editor

Ported GWT editors from GWT 2.8.x ready for GWT 2.x & J2CL /GWT 3)
Apache License 2.0
8 stars 14 forks source link

Getter/Setters on UI Fields in the Editor (PersonComponent) Fail Build #26

Open jhillbounce opened 1 year ago

jhillbounce commented 1 year ago

From the example in the Readme.md on https://github.com/gwtproject/gwt-editor

Copy the Person.java, PersonComponent.java

Add getter/setter for id, name and active UI fields in the PersonComponent editor PersonComponent.java ... public IntegerBox getId() { return id; }

public void setId(IntegerBox id) {
    this.id = id;
}

public TextBox getName() {
    return name;
}

public void setName(TextBox name) {
    this.name = name;
}

public CheckBox getActive() {
    return active;
}

public void setActive(CheckBox active) {
    this.active = active;
}

....

mvn -e compile

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project YZZ-client: Fatal error compiling: java.lang.IllegalStateException: generation aborted! No getter exists for >>getId<< -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project cris-client: Fatal error compiling at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293) at org.apache.maven.cli.MavenCli.main (MavenCli.java:196) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104) at java.lang.reflect.Method.invoke (Method.java:578) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.apache.maven.plugin.MojoExecutionException: Fatal error compiling at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1143) at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:193) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293) at org.apache.maven.cli.MavenCli.main (MavenCli.java:196) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104) at java.lang.reflect.Method.invoke (Method.java:578) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: org.codehaus.plexus.compiler.CompilerException: java.lang.IllegalStateException: generation aborted! No getter exists for >>getId<< at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:198) at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:183) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1140) at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:193) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293) at org.apache.maven.cli.MavenCli.main (MavenCli.java:196) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104) at java.lang.reflect.Method.invoke (Method.java:578) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: generation aborted! No getter exists for >>getId<< at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper (JavacTaskImpl.java:168) at com.sun.tools.javac.api.JavacTaskImpl.doCall (JavacTaskImpl.java:100) at com.sun.tools.javac.api.JavacTaskImpl.call (JavacTaskImpl.java:94) at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:136) at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:183) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1140) at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:193) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293) at org.apache.maven.cli.MavenCli.main (MavenCli.java:196) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104) at java.lang.reflect.Method.invoke (Method.java:578) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) Caused by: java.lang.IllegalStateException: generation aborted! No getter exists for >>getId<< at org.gwtproject.editor.processor.model.EditorProperty$Builder.findBeanPropertyMethods (EditorProperty.java:240) at org.gwtproject.editor.processor.model.EditorProperty$Builder.access (EditorProperty.java:149) at org.gwtproject.editor.processor.model.EditorProperty$Builder.access (EditorProperty.java:68) at org.gwtproject.editor.processor.model.EditorModel.calculateEditorData (EditorModel.java:149) at org.gwtproject.editor.processor.model.EditorModel. (EditorModel.java:68) at org.gwtproject.editor.processor.DriverProcessor.process (DriverProcessor.java:110) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor (JavacProcessingEnvironment.java:1018) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs (JavacProcessingEnvironment.java:934) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run (JavacProcessingEnvironment.java:1262) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing (JavacProcessingEnvironment.java:1377) at com.sun.tools.javac.main.JavaCompiler.processAnnotations (JavaCompiler.java:1248) at com.sun.tools.javac.main.JavaCompiler.compile (JavaCompiler.java:930) at com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0 (JavacTaskImpl.java:104) at com.sun.tools.javac.api.JavacTaskImpl.invocationHelper (JavacTaskImpl.java:152) at com.sun.tools.javac.api.JavacTaskImpl.doCall (JavacTaskImpl.java:100) at com.sun.tools.javac.api.JavacTaskImpl.call (JavacTaskImpl.java:94) at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess (JavaxToolsCompiler.java:136) at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile (JavacCompiler.java:183) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1140) at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:193) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293) at org.apache.maven.cli.MavenCli.main (MavenCli.java:196) at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104) at java.lang.reflect.Method.invoke (Method.java:578) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282) at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406) at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347) [ERROR] [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR]

FrankHossfeld commented 1 year ago

I think, you mixed some things up.

The editor is the class containing your widgets. There is no need to add getter- & setter-methods for your widgets. The widgets gets bind to the bean using the @Path-annotation. (keep in mind to make your widgets package protected or add getters-methods for them in case you keep them private.) The bean must be a POJO.

The error is telling you, that in your been no getter exists, which returns int.

I think, there is something wrong with your set up.

Please, can you provide a small project which shows the error. This might help to identify the error.

FrankHossfeld commented 1 year ago

OK, I am able to reproduce the issue.

niloc132 commented 1 year ago

To be clear though, there is no reason you can't have a getter/setter for the sub-editors. However, the GWT documentation prefers accessors to the editors that just follow the name (plus an optional Editor suffix): https://www.gwtproject.org/doc/latest/DevGuideUiEditors.html#Editor_contract

  • A no-arg method with at least package visibility whose name exactly is the property that will be edited or propertyNameEditor. This allows the use of interfaces for defining the Editor hierarchy. For example:
   interface FooEditor extends Editor<Foo> {
     // Edits the Foo.getBar() property
     BarEditor bar();
     // Edits the Foo.getBaz() property
     BazEditor bazEditor();
   }

This removes the need to leave your sub-editor field exposed and non-private.

FrankHossfeld commented 1 year ago

I played a little bit around. I realized, using native GWT widgets, it works. Switching to Domino-UI, the error occurs. Might be Domino-UI related.

jhillbounce commented 1 year ago

Interesting. Thanks Frank.

FrankHossfeld commented 1 year ago

To make clear, it is not a Domino-UI problem.

FrankHossfeld commented 1 year ago

Thanks @niloc132 for is pointing in the right direction.

This is not a bug at all. The error message might be confusing, but is correct. In this case the editor framework is looking for a property with the name getId and does not found a property getId inside the person bean. To fix this error annotate the IntegerBox getId()-method with @Path("id") and everything is fine.

niloc132 commented 1 year ago

Thanks, you're right - @jhillbounce you also have the option of annotating the getter with @Ignore to indicate that this shouldn't be bound at all (for example if you leave the field as non-private).

jhillbounce commented 1 year ago

Thank you @FrankHossfeld and @niloc132

As an experienced GWT developer, transitioning into newer GWT practices - I'm working to note hiccup points that could be barriers to entry for others.

What is the thought process for documentation on these potential hiccups for others?

My idea was to put some "inline" comments to help others avoid these confusing situations that are following the how to get started guide. https://github.com/gwtproject/gwt-editor/pull/25

Thoughts? Let me know if I should continue with this path.

FrankHossfeld commented 1 year ago

Happy to help ...

yeah, great idea. help is really appreciated. Please add some more text to your PR to clearify.

jhillbounce commented 1 year ago

Thanks! I'll create a few tests based on feedback provided to make sure what I type in the documentation is correct. Basically - I'll let them know if creating getter/setters on the UI fields that are bound to make sure to properly annotate with @Ignore or the @Path and parameter elements