I have an entity "Item" which contains a type object which is also an entity in the database. In the admin, I want to allow the user to edit the type using a dropdown which should contain all of the possible "ItemType" values in the database. So my class is as follows:
@AdminPresentationClass(friendlyName = "Item", populateToOneFields=PopulateToOneFieldsEnum.FALSE)
public class Item {
//bi-directional many-to-one association to ItemType
@ManyToOne
@JoinColumn(name="item_type_id")
@AdminPresentationDataDrivenEnumeration(optionListEntity = ItemType.class, optionValueFieldName = "id", optionDisplayFieldName = "name")
private ItemType itemType;
...
I am aware that the datadriven enum is supposed to operate on a string type and not an object, however, I am not aware of any other way to do this. My item type is automatically populated for me by JPA. How can I modify this scenario to operate on a string instead of the "ItemType" object? From what I have read, the datadrivenenumeration is the only way to list other entities in the drop-down. What I have above actually renders the drop-down, however, the drop down doesn't pre-select the value corresponding to the saved type, and upon trying to save, I get a failure as blc tries to store the selected string value to "ItemType" which obviously won't work. I would appreciate any suggestions to help be get this issue resolved. Thank you.
This forum is in readonly mode and serves as an archive of old information. All posting, registration and commenting abilities have been turned off. To get help, the Broadleaf team reguarly monitors the broadleaf-commerce tag on Stack Overflow so please ask your questions there.