diff --git a/views-fieldset/build.gradle.kts b/views-fieldset/build.gradle.kts index f79426516..fa16e9d13 100644 --- a/views-fieldset/build.gradle.kts +++ b/views-fieldset/build.gradle.kts @@ -9,7 +9,7 @@ dependencies { testImplementation(mnValidation.micronaut.validation) compileOnly(projects.micronautViewsCore) - compileOnly(mnData.micronaut.data.model) + testImplementation(mnData.micronaut.data.model) testAnnotationProcessor(mn.micronaut.inject.java) diff --git a/views-fieldset/src/main/java/io/micronaut/views/fields/DefaultFieldGenerator.java b/views-fieldset/src/main/java/io/micronaut/views/fields/DefaultFieldGenerator.java index 1c73e446c..1cb19bc7d 100644 --- a/views-fieldset/src/main/java/io/micronaut/views/fields/DefaultFieldGenerator.java +++ b/views-fieldset/src/main/java/io/micronaut/views/fields/DefaultFieldGenerator.java @@ -24,7 +24,6 @@ import io.micronaut.core.beans.BeanProperty; import io.micronaut.core.beans.BeanWrapper; import io.micronaut.core.util.StringUtils; -import io.micronaut.data.annotation.AutoPopulated; import io.micronaut.views.fields.annotations.InputCheckbox; import io.micronaut.views.fields.annotations.InputEmail; import io.micronaut.views.fields.annotations.InputHidden; @@ -92,6 +91,7 @@ public class DefaultFieldGenerator implements FieldsetGenerator { ); private static final String MEMBER_MIN = "min"; private static final String MEMBER_MAX = "max"; + private static final String CLASS_IO_MICRONAUT_DATA_ANNOTATION_AUTO_POPULATED = "io.micronaut.data.annotation.AutoPopulated"; private final EnumOptionFetcher enumOptionFetcher; @@ -183,7 +183,7 @@ private List generateOfBeanWrapper(@NonNull BeanWrapp @NonNull private Optional> formElementClassForBeanProperty(@NonNull BeanProperty beanProperty) { - if (beanProperty.hasStereotype(AutoPopulated.class)) { + if (beanProperty.hasStereotype(CLASS_IO_MICRONAUT_DATA_ANNOTATION_AUTO_POPULATED)) { return Optional.empty(); } for (var mapping : ANNOTATION_MAPPING.entrySet()) { diff --git a/views-fieldset/src/main/java/io/micronaut/views/fields/render/views/package-info.java b/views-fieldset/src/main/java/io/micronaut/views/fields/render/views/package-info.java index 879c1d9d4..d94926c2f 100644 --- a/views-fieldset/src/main/java/io/micronaut/views/fields/render/views/package-info.java +++ b/views-fieldset/src/main/java/io/micronaut/views/fields/render/views/package-info.java @@ -24,4 +24,4 @@ import io.micronaut.context.annotation.Configuration; import io.micronaut.context.annotation.Requires; -import io.micronaut.views.ViewsRenderer; \ No newline at end of file +import io.micronaut.views.ViewsRenderer; diff --git a/views-fieldset/src/test/java/io/micronaut/views/fields/formsexamples/AutomaticallyPopulatedTest.java b/views-fieldset/src/test/java/io/micronaut/views/fields/formsexamples/AutomaticallyPopulatedTest.java index e520034bd..5dc6dc053 100644 --- a/views-fieldset/src/test/java/io/micronaut/views/fields/formsexamples/AutomaticallyPopulatedTest.java +++ b/views-fieldset/src/test/java/io/micronaut/views/fields/formsexamples/AutomaticallyPopulatedTest.java @@ -20,6 +20,8 @@ @Property(name = "spec.name", value = "AutomaticallyPopulatedTest") @MicronautTest(startApplication = false) class AutomaticallyPopulatedTest { + + // @DateCreated and @DateUpdated are @AutoPopulated annotations @Introspected record Book(@NotBlank String title, @DateCreated @Nullable LocalDate dateCreated,