You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
# Jmix LocalizedString Datatype
6
6
7
-
This add-on provides a custom [Datatype](https://docs.jmix.io/jmix/data-model/data-types.html)and related action for the [ValuePicker](https://docs.jmix.io/jmix/flow-ui/vc/components/valuePicker.html) component for storing and editing localized string values.
7
+
This add-on provides a custom [Datatype](https://docs.jmix.io/jmix/data-model/data-types.html), sorting support, Bean Validation constraints, and a related action for the [ValuePicker](https://docs.jmix.io/jmix/flow-ui/vc/components/valuePicker.html) component for storing and editing localized string values.
8
8
9
9
The value displayed in visual components depends on the user's current locale.
10
10
@@ -19,32 +19,32 @@ The following table shows which version of the add-on is compatible with which v
The `LocalizedString` datatype is represented by three classes:
30
+
The `LocalizedString` datatype is represented by three classes:
31
31
32
-
*[LocalizedString.java](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/datatype/LocalizedString.java) - custom Java class used as a type of entity attributes.
32
+
*[LocalizedString.java](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/datatype/LocalizedString.java) - custom Java class used as a type of entity attributes.
33
33
*[LocalizedStringDatatype.java](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/datatype/LocalizedStringDatatype.java) - a `Datatype` implementation class for `LocalizedString`.
34
34
*[LocalizedStringConverter.java](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/datatype/LocalizedStringConverter.java) - a class that converts entity attribute state into database column representation and back again.
35
35
36
36
You can define an entity attribute with the `LocalizedString` datatype using Studio. For example:
As a result, Studio generates the following attribute definition:
40
+
As a result, Studio generates the following attribute definition:
41
41
42
42
```java
43
43
@Column(name="NAME", nullable=false)
44
44
privateLocalizedString name;
45
45
```
46
46
47
-
To edit localized value, add action with `type="value_localizedStringEdit"` to the `ValuePicker` component. For example:
47
+
To edit a localized value, add an action with `type="value_localizedStringEdit"` to the `ValuePicker` component. For example:
48
48
49
49
```xml
50
50
<valuePickerid="nameField"property="name">
@@ -84,7 +84,7 @@ The `value_localizedStringEdit` action is represented by [LocalizedStringEditAct
84
84
85
85
### Properties
86
86
87
-
*`multiline` - sets whether to use a multi-line text input component. `TextArea` is used for multi-line text input, `TextField` otherwise. `false` by default. If an entity attribute is annotated with `@Lob`, multi-line text input is used. For example:
87
+
*`multiline` - sets whether to use a multi-line text input component. `TextArea` is used for multi-line text input, `TextField` otherwise. If the property is not set explicitly and the entity attribute is annotated with `@Lob`, multi-line text input is used. For example:
88
88
89
89
```java
90
90
@Lob
@@ -136,12 +136,12 @@ If the target `ValuePicker` of `LocalizedStringEditAction` is bound to a require
136
136
137
137
The add-on provides Bean Validation annotations for `LocalizedString` attributes:
138
138
139
-
*`@LocalizedStringSize`
140
-
*`@LocalizedStringLength`
141
-
*`@LocalizedStringPattern`
142
-
*`@LocalizedStringNotNull`
143
-
*`@LocalizedStringNotEmpty`
144
-
*`@LocalizedStringNotBlank`
139
+
*[`@LocalizedStringSize`](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/validation/constraints/LocalizedStringSize.java) checks that every localized value length is between `min` and `max`. A `null``LocalizedString` is valid.
140
+
*[`@LocalizedStringLength`](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/validation/constraints/LocalizedStringLength.java) checks that every localized value length is between `min` and `max`. A `null``LocalizedString` is valid.
141
+
*[`@LocalizedStringPattern`](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/validation/constraints/LocalizedStringPattern.java) checks that every localized value matches `regexp`. A `null``LocalizedString` is valid.
142
+
*[`@LocalizedStringNotNull`](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/validation/constraints/LocalizedStringNotNull.java) checks that a non-null localized value is stored for every configured application locale.
143
+
*[`@LocalizedStringNotEmpty`](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/validation/constraints/LocalizedStringNotEmpty.java) checks that every localized value is not empty. A `null``LocalizedString` and an empty set of localized values are invalid.
144
+
*[`@LocalizedStringNotBlank`](jmix-localized-string-datatype/src/main/java/com/glebfox/jmix/locstr/validation/constraints/LocalizedStringNotBlank.java) checks that every localized value contains at least one non-whitespace character. A `null``LocalizedString` and an empty set of localized values are invalid.
145
145
146
146
For example:
147
147
@@ -152,7 +152,7 @@ For example:
152
152
privateLocalizedString name;
153
153
```
154
154
155
-
Every stored localized value is validated. `@LocalizedStringNotNull` also checks that a value is stored for every configured application locale. When the edit dialog is used for an entity attribute, these constraints are applied to each locale field separately. Standard `@NotNull` can still be used for the attribute itself when only the `LocalizedString` object reference should be checked.
155
+
When the edit dialog is used for an entity attribute, these constraints are applied to each locale field separately. Standard `@NotNull` can still be used for the attribute itself when only the `LocalizedString` object reference should be checked.
156
156
157
157
Additionally, you can add a validator that checks the value of every field in the edit dialog. For example:
Copy file name to clipboardExpand all lines: jmix-localized-string-datatype-starter/src/main/java/com/glebfox/jmix/autoconfigure/locstr/LocstrAutoConfiguration.java
0 commit comments