Hi,
I'm using the SmartGWT version 2.4.
I have this situation:
There is a relation between to entities, Issue and User (the user are the watchers of the issues, like in the RedMine traker).
In the client side I have a ListGrid to show all the issues with their fields. Also I have a DynamicForm to edit the Issues there. An issue can have several watchers, so for the field watchers is multiple=true and it is displayed as a MultiPickList in the form.
The problem is that when I create/update a new issue I lose the watchers selected from the picklist and only gets the first one. Also in the ListGrid, the column "Watchers" only show one value. The data is stored in the DB, I mean all the watchers selected are stored, but It seems like only the first can gets to the UI in the listgrid or the form.
The summary of the relevant code is:
User.java
Issue.java
Fields of UserDS.java
Fields of IssueDS.java
Relevant ListGrid code:
Relevant DynamicForm code:
I guess that there is some problem in the way that I'm creating the my DataSources. Let me know if you need more info. I hope you can help me.
Thanks,
Viko
I'm using the SmartGWT version 2.4.
I have this situation:
There is a relation between to entities, Issue and User (the user are the watchers of the issues, like in the RedMine traker).
In the client side I have a ListGrid to show all the issues with their fields. Also I have a DynamicForm to edit the Issues there. An issue can have several watchers, so for the field watchers is multiple=true and it is displayed as a MultiPickList in the form.
The problem is that when I create/update a new issue I lose the watchers selected from the picklist and only gets the first one. Also in the ListGrid, the column "Watchers" only show one value. The data is stored in the DB, I mean all the watchers selected are stored, but It seems like only the first can gets to the UI in the listgrid or the form.
The summary of the relevant code is:
User.java
Code:
public class User { private Long id; private String name; }
Code:
public class Issue { private Long id; private String name; @ManyToMany private Set<User> watchers; }
Code:
DataSourceIntegerField idField = new DataSourceIntegerField("id", "Id", 128, true); idField.setHidden(true); idField.setPrimaryKey(true); DataSourceTextField nameField = new DataSourceTextField("name", "Name", 128, true);
Code:
DataSourceIntegerField idField = new DataSourceIntegerField("id", "Id", 128, true); idField.setHidden(true); idField.setPrimaryKey(true); DataSourceTextField nameField = new DataSourceTextField("name", "Name", 128, true); DataSourceTextField watchersIdField = new DataSourceTextField("watchersId", "Watchers ID"); watchersIdField.setForeignKey("UserDS.id"); watchersIdField.setMultiple(true); watchersIdField.setValueXPath("watchers/user/id"); DataSourceTextField watchersNameField = new DataSourceTextField("watchersName", "Watchers Name Hidden"); watchersNameField.setMultiple(true); watchersNameField.setHidden(true); watchersNameField.setValueXPath("watchers/user/name");
Code:
grid = new IssueListGrid(); grid.setDataSource(IssueDS.getInstance()); grid.setAutoFetchData(true); // Redefine the watchers id field of the grid in order to use displayField and valueField ListGridField watchersGriField = new ListGridField("watchersId", "Watchers"); watchersGriField.setDisplayField("watchersName"); watchersGriField.setValueField("watchersId"); grid.setFields(watchersGriField);
Code:
form = new DynamicForm(); form.setDataSource(IssueDS.getInstance()); form.setUseAllDataSourceFields(true); SelectItem watchersSelectItem = new SelectItem("watchersId", "Seguidores"); watchersSelectItem.setOptionDataSource(UserDS.getInstance()); watchersSelectItem.setMultiple(true); watchersSelectItem.setShowOptionsFromDataSource(true); watchersSelectItem.setDisplayField("name"); watchersSelectItem.setValueField("id"); form.setFields(watchersSelectItem);
Thanks,
Viko