import io.jmix.core.metamodel.datatype.EnumClass;
import lombok.Getter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.lang.NonNull;
@Getter
public enum SignMethods implements EnumClass<String> {
PIN("PIN", "Pin"),
SELFIE("SELFIE", "Selfie");
private final String id;
private final String label;
SignMethods(String id, String label) {
this.id = id;
this.label = label;
}
@Override
@NonNull
public String getId() {
return id;
}
public static SignMethods fromId(String id) {
for (SignMethods status : SignMethods.values()) {
if (status.getId().equals(id)) {
return status;
}
}
return null;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("id", id)
.toString();
}
}
Where the attribute method is an enum, according to Jmix design, as a data type.
The thing is that it is recognized as an enum — in the filter it appears as a dropdown, but there (and in the datagrid display, in the detail page, and when exporting to a file using Grid Export Action), the value shown is SignMethods.PIN and not just PIN.
Is that normal? Is it not possible to only show the value (like PIN), and not the full enum representation (like SignMethods.PIN)?
Looking forward to your comments. Thank you very much!
The file is messages_es_PY.properties, for Spanish, and it’s working — the system is getting translations from it for everything else. I’m only using one language.
Here is my enum file:
package py.com.itti.secure.certificates.backoffice.utils;
import io.jmix.core.metamodel.datatype.EnumClass;
import lombok.Getter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.springframework.lang.NonNull;
@Getter
public enum SignMethods implements EnumClass<String> {
PIN("PIN", "Pin"),
SELFIE("SELFIE", "Selfie");
private final String id;
private final String label;
SignMethods(String id, String label) {
this.id = id;
this.label = label;
}
@Override
@NonNull
public String getId() {
return id;
}
public static SignMethods fromId(String id) {
for (SignMethods status : SignMethods.values()) {
if (status.getId().equals(id)) {
return status;
}
}
return null;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("id", id)
.toString();
}
}
Thank you very much for your response — you’re absolutely right, the way to add the translation is exactly as you showed. I had tried using the design tab to add the translation, but apparently it doesn’t work if the enum has an extra parameter in its constructor besides the ID, which I’ve confirmed. It’s probably a bug in the Jmix plugin. I removed the label attribute from the enum, and after that I was able to generate the message for the local language file. Thank you so much for your help!