Before posting this I grabbed the latest version of 4.1p available via the maven plugin which is yesterdays build. The issue I am seeing is that fetch is returning enum toString() rather than name() for enumerated fields. This appears to be contrary to your documentation, as the documentation states when deriving a value map name() will be the key and toString() the display value. So I would assume that the value returned during a fetch would be name() as that would be the key to determine the appropriate display value?
Announcement
Collapse
No announcement yet.
X
-
So is that to say that I should expect value.toString() to be passed to the client? I am trying to sort out how to appropriately setup the DS to display user friendly names that are derived from the enum itself, as well as use an option datasource to be able to disable values when appropriate. so assuming I have a DS with an enum field declared via:
Which points to the following enum:
And then a client only DS for an option datasource:
When I fetch a record and edit it in a form I end up with validation errors, because the enum field has the toString() value rather than the name().Last edited by jpappalardo; 24 Sep 2014, 09:10.
Comment
-
Here's the behavior we document:
In both of these case, the display values generated for the valueMap are the result of calling toString() on each Enum member. If that gives the same value as calling name(), the value is passed through DataTools.deriveTitleFromName(), which applies the same processing rules as DataSource.getAutoTitle to derive a more user-friendly display value.
Comment
-
I originally set the enum values as map.put(value.name(), value.toString()) but still had the same issue since the server is actually returning value.toString() rather than value.name() in the fetched records. So I am confused as to why a server fetch is returning the display name, rather than the actual value? Is it supposed to behave that way, and I need to actually put(value.toString(), value.name())? This does not seem to explain the fact that enumerated values that do not override toString() end up fetched as the enum value, and not something that your code has attempted to turn into a display value.
Comment
-
Something went goofy when trying to edit my last post.
are all defined as enumerated values. The compressionMode and streamCategory enums override toString() and end up being returned from the server as the display value, where as all of the other enumerations do not. If the behavior were to always return the display name via a fetch then why are the four other enums not given as display names?Last edited by jpappalardo; 24 Sep 2014, 09:11.
Comment
-
How we translate enums is also settable, controlled by dataSource.enumTranslateStrategy.
So basically it looks like accomodating your definition is going to require one more possible setting for enumTranslateStrategy, which would be to use the name.
We'll take a look at this, but note that you could also, in the meantime, hand-declare the valueMap in your .ds.xml.
Comment
Comment