Hi,
can you advise me how to achive a custom display value for a combobox?
I have a persistent entity(hibernate) Branches with a reference to another entity Employees.
I'd like to have an option to put a ComboboxItem to a dynamic form which would select appropriate user. The display field should be "name surname".
The entity user has of course name and surname stored separately.
My DS is a follow
in the java there is
I can take the name and surname from the record but don't know what to do with it
Secondly,
I have a ComboboxItem with optionalDataSource set. I'd like to display another disabled text field with a different attribete from the chosen object above.
So I set the same OptionalDataSource to the textField like the one from ComboBoxItem. and whenewer the combobox changes I set textItem.setValue to it.
It works but there are 2 RPC call to server which is quite unnecessary.
Is there a better way hot to achieve this?
Cheers,
Martin
can you advise me how to achive a custom display value for a combobox?
I have a persistent entity(hibernate) Branches with a reference to another entity Employees.
I'd like to have an option to put a ComboboxItem to a dynamic form which would select appropriate user. The display field should be "name surname".
The entity user has of course name and surname stored separately.
My DS is a follow
Code:
<field name="regionalManager" length="80" unknownType="true" type="cz.bcom.server.persistence.hibernate.Employees" hidden="true"></field> <field name="regionalManagerFirstName" type="text" valueXPath="regionalManager/firstName" hidden="true"></field> <field name="regionalManagerSurname" type="text" valueXPath="regionalManager/surname" hidden="true"></field>
Code:
regionalManagerItem = new ComboBoxItem("regionalManager", i18nConstants.settingsTree_branchManagement_addEditWindow_dynamicForm_regionalManager()); regionalManagerItem.setOptionDataSource(DataSource.get("employeesDS")); regionalManagerItem.setValueField("employeeId"); regionalManagerItem.setDisplayField(????);
Code:
String employeesByChangedBySurname = record.getAttribute("employeesByChangedBySurname"); String employeesByChangedByFirstName = record.getAttribute("employeesByChangedByFirstName");
Secondly,
I have a ComboboxItem with optionalDataSource set. I'd like to display another disabled text field with a different attribete from the chosen object above.
So I set the same OptionalDataSource to the textField like the one from ComboBoxItem. and whenewer the combobox changes I set textItem.setValue to it.
It works but there are 2 RPC call to server which is quite unnecessary.
Code:
branchItem.setOptionDataSource(DataSource.get("branchesDS")); branchItem.setValueField("branchId"); branchItem.setDisplayField("name"); branchItem.addChangedHandler(new ChangedHandler() { @Override public void onChanged(ChangedEvent event) { branchPrimaryCodeItem.setValue(branchItem.getValue()); } }); branchPrimaryCodeItem = new TextItem("primaryCode", i18nConstants.settingsTree_employeeManagement_addEditWindow_dynamicForm_branchPrimaryCode()); branchPrimaryCodeItem.setDisabled(true); branchPrimaryCodeItem.setShouldSaveValue(false); branchPrimaryCodeItem.setOptionDataSource(DataSource.get("branchesDS")); branchPrimaryCodeItem.setValueField("branchId"); branchPrimaryCodeItem.setDisplayField("primaryCode");
Cheers,
Martin
Comment