Hi, I’m trying to use your addon but edit and delete operation cause an exception,update and add work fine. I use crudRepository for all operations. (vaadin 8.4.4, crudui 2.3.0)
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set
at com.vaadin.ui.AbstractMultiSelect.setValue(AbstractMultiSelect.java:61) ~[vaadin-server-8.4.4.jar:8.4.4]
at com.vaadin.data.Binder$BindingImpl.initFieldValue(Binder.java:1143) ~[vaadin-server-8.4.4.jar:8.4.4]
at com.vaadin.data.Binder$BindingImpl.access$100(Binder.java:995) ~[vaadin-server-8.4.4.jar:8.4.4]
at com.vaadin.data.Binder.lambda$readBean$2(Binder.java:1690) ~[vaadin-server-8.4.4.jar:8.4.4]
at java.util.ArrayList.forEach(ArrayList.java:1249) ~[na:1.8.0_73]
at com.vaadin.data.Binder.readBean(Binder.java:1690) ~[vaadin-server-8.4.4.jar:8.4.4]
Антон, the problem is well described in the exception message:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.util.Set at com.vaadin.ui.AbstractMultiSelect.setValue(AbstractMultiSelect.java:61)
So, you are using an ArrayList where a Set is expected.
Dear Alejandro,
nice add-on, thank you, but I have problem with date field on edit form. I’m using Kotlin 1.2.51 and Vaadin 10.0.1 and CrudUI 3.5.0. If I use default (CrudFormFactory), or create object of DefaultCrudFormFactory and setCrudFormFactory it, and don’t use setVisibleProperties (will be rendered all properties?), on edit form are displayed only properties of types String, Long, Boolean, but no properties of LocalDateTime type (validFrom, validTo in my case). What should I do wrong?
Viktor, the DefaultFieldProvider works only with LocalDate since DatePicker doesn’t support time selection. You can use a custom FieldProvider to build any field you want for a property:
Just by reading the high level abstraction description, I know you have done something good here.
I intend to use this add-on for CRUD generation of an extensible set of composite meta-models and eliminate the need to write custom CRUD UI for each meta-model (I hope this makes sense)
I intend to use this add-on for CRUD generation of an extensible set of composite meta-models and eliminate the need to write custom CRUD UI for each meta-model (I hope this makes sense)
Do you think this add-on is suitable?
I’d say yes. The best way is to try it out and see if it suits your needs.
You can set a custom CrudFormFactory. The easiest way is to extend AbstractCrudFormFactory:
AbstractCrudFormFactory<User> customFormFactory = new AbstractCrudFormFactory<User>() {
@Override
public Component buildNewForm(CrudOperation operation, User domainObject, boolean readOnly, ComponentEventListener<ClickEvent<Button>> cancelButtonClickListener, ComponentEventListener<ClickEvent<Button>> operationButtonClickListener) {
return new CustomForm(cancelButtonClickListener, operationButtonClickListener);
}
@Override
public void showError(CrudOperation operation, Exception e) {
}
};
crud.setCrudFormFactory(customFormFactory);
CustomForm would be your own form implemented as a regular Vaadin UI component. You have to connect it somehow to the Crud component by using the cancelButtonClickListener and operationButtonClickListener references.
Hi Alejandro, i added this dependency to the bakery app and this error occur
bakery app v10.0.4 , crudui v3.5.0:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:496)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from file:/C:/Users/weiliang/.m2/repository/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:637)
at org.springframework.util.Assert.isInstanceOf(Assert.java:537)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:99)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:191)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:170)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
at weiliang.Application.main(Application.java:27)
... 6 more
[INFO]
------------------------------------------------------------------------
[INFO]
BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO]
Total time: 4.042 s
[INFO]
Finished at: 2018-08-29T11:33:44+08:00
[INFO]
------------------------------------------------------------------------
[ERROR]
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) on project naili10: An exception occurred while running. null: InvocationTargetException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from file:/C:/Users/weiliang/.m2/repository/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.3.RELEASE:run (default-cli) on project naili10: An exception occurred while running. null
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
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:956)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:290)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occurred while running. null
at org.springframework.boot.maven.AbstractRunMojo$IsolatedThreadGroup.rethrowUncaughtException(AbstractRunMojo.java:464)
at org.springframework.boot.maven.RunMojo.runWithMavenJvm(RunMojo.java:95)
at org.springframework.boot.maven.AbstractRunMojo.run(AbstractRunMojo.java:221)
at org.springframework.boot.maven.AbstractRunMojo.execute(AbstractRunMojo.java:178)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:496)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from file:/C:/Users/weiliang/.m2/repository/org/slf4j/slf4j-simple/1.7.25/slf4j-simple-1.7.25.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.SimpleLoggerFactory
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:637)
at org.springframework.util.Assert.isInstanceOf(Assert.java:537)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:99)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:191)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:170)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
at weiliang.Application.main(Application.java:27)
... 6 more
[ERROR]
[ERROR]
[ERROR]
For more information about the errors and possible solutions, please read the following articles:
[ERROR]
[Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Wei liang lim:
Hi Alejandro, i added this dependency to the bakery app and this error occur
…
This error is due to a bug in the checkbox-group component. I have sent a [PR]
(checkbox-group-flow) and it’s merged already. Waiting for the author to publish a new version and then I’ll update Crud UI.
Wei liang lim:
Hi Alejandro, i added this dependency to the bakery app and this error occur
…
This error is due to a bug in the checkbox-group component. I have sent a [PR]
(checkbox-group-flow) and it’s merged already. Waiting for the author to publish a new version and then I’ll update Crud UI.
Adexe Rivera Martín:
where is the best way, if exist, to convert price fields with currency converter??
If you mean Vaadin’s Converter, currently there’s no API for it in the component. As an alternative, you can create your own CrudFormFactory implementation. If you mean Java’s CurrencyStringConverter you can encapsulate any kind of logic in a custom field.
Adexe Rivera Martín:
where is the best way, if exist, to convert price fields with currency converter??
If you mean Vaadin’s Converter, currently there’s no API for it in the component. As an alternative, you can create your own CrudFormFactory implementation. If you mean Java’s CurrencyStringConverter you can encapsulate any kind of logic in a custom field.
Thanks for the alternative, but I think a good idea that you try to integrate as ‘setFieldProvider’.
Alejandro Duarte:
Yeah. Maybe a new method to set a Converter for a specific field. Can you please open an issue about it at https://github.com/alejandro-du/crudui/issues ? Cheers.
Wei liang lim:
Hi Alejandro, i added this dependency to the bakery app and this error occur
…
This error is due to a bug in the checkbox-group component. I have sent a [PR]
(checkbox-group-flow) and it’s merged already. Waiting for the author to publish a new version and then I’ll update Crud UI.
I have implemented the CRUD UI Add-on and it simply fits good as per my requirement.
There are 2 problems for which I am trying to find a solution:
I am trying to find a solution for the similar problem asked by Costantino Saponaro mentioned in the directory reviews: “How i can use it to display a bean with its inner objects? For example, I a heve a list of “Person” (name, surname, email, …). What about if Person contains inner object, like Address (city, street, …) and so on?”
Looking at the source code examples I feel for each and every field of inner class I may need to add something like:
formFactory.setFieldProvider("mainGroup",
new ComboBoxProvider<>("Main Group", GroupRepository.findAll(), new TextRenderer<>(Group::getName), Group::getName));
Is there any other way to get this done?
I have a settings screen which just does not need a grid. Can I use the editor/ form layout without the grid?
Deepak Chainani: “How i can use it to display a bean with its inner objects? For example, I a heve a list of “Person” (name, surname, email, …). What about if Person contains inner object, like Address (city, street, …) and so on?”
You can implement a component (should implement HasValueAndElement) that shows all the fields in the inner object (Address in your case). Then just pass an instance of this new component to the setFieldProvider method.
Is there any other way to get this done?
You could implement a CrudFormFactory to return any kind of complex form, but that would require also taking care of other stuff such as data binding for example. I’d go with the first approach.