Hi,
A question on how the list grid gets refreshed after an update.
I am following the example code.
I add the updated Item's id to the list ( updatedIds.add(item.getId()); )
And then call respds.addAttribute("records", updatedIds) method.
The datamodule config entry is
<attribute name="records" node="@records" type="longList"/>
The list not getting refreshed ( not showing the updated value). Of course the field values are updated, you can see that when you come back again to the same page.
Jay

Re: Data Service
15 August, 2008 - 13:01 — v_peterHi, Jay,
Do you have the type "longList" defined in your configuration?
From the demo source it should be:
<type name="longList" class="java.util.ArrayList" converter="longListConverter"/>
The first line defines converter which converts
java.util.Listofjava.lang.Longto aStringof comma separated values and the second line is the definition of the type used for the "records" attribute.Please check that you have the type defined. It should be as child of the "domain" element.
Yes, I have the type
18 August, 2008 - 18:35 — JayYes, I have the type "longList" defined in my data-module config.
<converter name="longListConverter" class="bb.util.LongListDataConverter"/>
<type name="longList" class="java.util.ArrayList" converter="longListConverter"/>
<converter name="dateConverter" class="bb.util.DateConverter"/>
<type name="ttdate" class="bb.util.TTDate" converter="dateConverter"/>
<type name="project" class="bb.busobj.Project">
<id name="id" node="@id" type="long"/>
<field name="title" node="@title" type="string"/>
<field name="startDate" node="@startDate" type="ttdate"/>
<field name="targetDate" node="@targetDate" type="ttdate"/>
</type>
</domain>
If you notice, the id is of type "long". Thats is how its in my model.
Is that any problem in the LongListDataConverter, because the fromObject method accepts argument of type Object. I am not getting the control passed to the fromObject(Object obj) method at any point of time.
Regards
Jay
Re: Yes, I have the type
19 August, 2008 - 15:24 — v_peterHi, Jay,
It is ok to have the ID of the type "long".
I've just changed en example from the tutorial and it works ok.
What was changed:
- config file - the
longtype is used instead ofjava.lang.Longas you have in your code snippet- model class
com.backbase.dataservices.example.model.Movie- the fieldidchanged to be instance of the classlong- handler classes in the package
com.backbase.dataservices.example.handler:CreateMoviesActionHandler,UpdateMoviesActionHandlerandDeleteMoviesActionHandler- because the same implementation forlongListConverteris used so it is required to create instance ofjava.lang.Longfrom thelongbefore adding updated ID to theupdatedIdslist- DAO interface and implementation classes,
DataKeeperclass - to reflect the changes above.How does your implementation of
bb.util.LongListDataConverterdiffer from the same converter implementation from tutorial?And how do you populate the
updatedIdswith IDs in UpdateActionHandler?Thanks,
Peter
I use the same
19 August, 2008 - 22:25 — JayI use the same implementation of LongListDataConverter from the example.
But I was populating the updatedIds with the long id.
Now I converted into java.lang.Long and added into the updatedIds list. But still I am not getting list refreshed.
protected final static String RECORDS_ATTR="records";
public void handleRequest(ActionContext ctx, RequestDataSource reqds,
ResponseDataSource respds) {
{
List updatedIds = new ArrayList();
Iterator itemIter = reqds.getRecords().iterator();
while (itemIter.hasNext()) {
Project project = (Project) itemIter.next();
try {
ProjectProxy proxy = new ProjectProxy();
proxy.updateItem(myUser, project, updateFields);
updatedIds.add(Long.valueOf(project.getId())); // convert the long value to Long and add it to updatedIds.
} catch (Exception e) {
STD.error(e);
}
}
respds.addAttribute(RECORDS_ATTR, updatedIds);
I am debuging the code, and not seeing the method fromObject(Object obj) and toObjct(String str) in LongListDataConverter getting called.
datamodule config file
<actionGroup id="dataServices">
<mappings>
<attribute name="page" node="@page" type="int"/>
<attribute name="rows" node="@rows" type="int"/>
<attribute name="records" node="@records" type="longList"/>
<attribute name="totalRecords" node="@totalRecords" type="int"/>
<record node="record" type="project"/>
</mappings>
<action name="read" class="bb.project.ReadProjectGridHandler"/>
<action name="update" class="bb.project.UpdateProjectGridHandler"/>
<action name="delete" class="bb.project.DeleteProjectGridHandler"/>
</actionGroup>
<domain>
<converter name="longListConverter" class="bb.util.LongListDataConverter"/>
<type name="longList" class="java.util.ArrayList" converter="longListConverter"/>
<converter name="dateConverter" class="bb.util.DateConverter"/>
<type name="ttdate" class="bb.util.TTDate" converter="dateConverter"/>
<type name="project" class="bb.busobj.Project">
<id name="id" node="@id" type="long"/>
<field name="title" node="@title" type="string"/>
<field name="startDate" node="@startDate" type="ttdate"/>
<field name="targetDate" node="@targetDate" type="ttdate"/>
</type>
</domain>
</config>
Regards
Jay
Figured out the issue, an
20 August, 2008 - 22:33 — JayFigured out the issue, an older version of dataservices-core along with the new version was present in the lib.
Re: Figured out the issue, an
21 August, 2008 - 10:16 — v_peterAnyway many thanks for your questions.
Peter