Data Service

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

Hi, Jay,

Do you have the type "longList" defined in your configuration?
From the demo source it should be:

<converter name="longListConverter" class="com.backbase.dataservices.example.converter.LongListDataConverter"/>
<type name="longList" class="java.util.ArrayList" converter="longListConverter"/>

The first line defines converter which converts java.util.List of java.lang.Long to a String of 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

Yes, I have the type "longList" defined in my data-module config.

   <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>

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

Hi, 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 long type is used instead of java.lang.Long as you have in your code snippet
- model class com.backbase.dataservices.example.model.Movie - the field id changed to be instance of the class long
- handler classes in the package com.backbase.dataservices.example.handler: CreateMoviesActionHandler, UpdateMoviesActionHandler and DeleteMoviesActionHandler - because the same implementation for longListConverter is used so it is required to create instance of java.lang.Long from the long before adding updated ID to the updatedIds list
- DAO interface and implementation classes, DataKeeper class - to reflect the changes above.

How does your implementation of bb.util.LongListDataConverter differ from the same converter implementation from tutorial?
And how do you populate the updatedIds with IDs in UpdateActionHandler?

Thanks,
Peter

I use the same

I 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 TOTAL_RECORDS_ATTR="totalRecords";
    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

<config defaultActionGroupId="dataServices">

    <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

Figured 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

Anyway many thanks for your questions.

Peter