Hi,
I have two data sets
profile.data.xml
and state.data.xml
I want a grid with fields: nickname, state, rating. Is it possible to join both data sources?
This is my java code:
What should I change in order it works?
Thanks in advance.
I have two data sets
profile.data.xml
Code:
<profiles> <profile> <nickname>u1</nickname> <rating>4</rating> </profile> <profile> <nickname>u2</nickname> <rating>5</rating> </profile> <profile> <nickname>u3</nickname> <rating>3</rating> </profile> <profile> <nickname>u4</nickname> <rating>4</rating> </profile> </profiles>
Code:
<states> <state> <online>true</online> <nickname>u1</nickname> </state> <state> <online>true</online> <nickname>u2</nickname> </state> <state> <online>false</online> <nickname>u3</nickname> </state> <state> <online>false</online> <nickname>u4</nickname> </state> </states>
This is my java code:
Code:
public static ProfileXmlDS getInstance() { if (instance == null) { instance = new ProfileXmlDS("profileDS"); } return instance; } public ProfileXmlDS(String id) { setID(id); setRecordXPath("/profiles/profile"); DataSourceTextField nameField = new DataSourceTextField("nickname"); nameField.setPrimaryKey(true); DataSourceIntegerField ratingField = new DataSourceIntegerField("rating"); setFields(nameField, ratingField); setDataURL("data/profile.data.xml"); setClientOnly(true); }
Code:
public StateXmlDS(String id) { ClientModel clientModel = ClientController.getInstance().getModel(); Model model = clientModel.getModel(); setID(id); setRecordXPath("/states/state"); DataSourceTextField nameField = new DataSourceTextField("nickname", "Expert"); nameField.setPrimaryKey(true); nameField.setForeignKey("profileDS.nickname"); DataSourceBooleanField statusField = new DataSourceBooleanField("online", "Online"); setFields(nameField, statusField); setDataURL("data/state.data.xml"); setClientOnly(true); }
Code:
ListGrid gr = new ListGrid(); gr.setDataSource(StateXmlDS.getInstance()); gr.setShowAllRecords(true); gr.setAutoFetchData(true); ListGridField f1 = new ListGridField("nickname"); ListGridField f2 = new ListGridField("online"); ListGridField f3 = new ListGridField("rating"); gr.setFields(f1, f2, f3);
Thanks in advance.