ListGrid saveData

Hi,

we want to save the datas in the listgrid .we have associated datasource for the listgrid and by using the operationBindings we are calling the serverMethod with lookupstyle as spring. How to handle the list of values in delegate [ ie in java method which is associated with the ds].Please find the sample code below.
code
<isomorphic:loadDS ID=“masters_baserates_baseratesDS” />
<isomorphic:loadDS ID=“masters_baserates_baseratesListDS” />

isc.Label.create({
top:90,
left:170,
width:200,
contents:“Base Rates”,
styleName:“content_tbltitle”
});
isc.ListGrid.create({
height:210,
left:170,
top:150,
width:800,
ID:“baseRatesListGrid”,
alternateRecordStyles:false,
showAllRecords:true,
canSort:false,
canHover:false,
showRollOver:false,
border:“0px”,
canEdit:true,
editEvent:“click”,
editByCell:false,
dataSource:masters_baserates_baseratesDS,
fields:[
{title:“Base Rate Code *”, name:“baseRateCode”, type:“text”},
{
width:250,
baseStyle:“grid_valuecolumn2”,
title:“Description *”,
name:“description”,
type:“text”,
headerBaseStyle:“grid_header2”
},
{title:“Base Rate *”, name:“baseRate”, type:“float”},
{
width:150,
valueMap:{“false”:“false”, “true”:“true”},
baseStyle:“grid_valuecolumn2”,
title:“Disable”,
canToggle:true,
valueIcons:{“false”:“/dbfcweb/script/isomorphic/skins/standard/images/DynamicForm/unchecked.png”,
“true”:“/dbfcweb/script/isomorphic/skins/standard/images/DynamicForm/checked.png”},
name:“disable”,
type:“checkbox”,
headerBaseStyle:“grid_header2”
}
],
leaveScrollbarGap:false,
showHeader:true
});

baseRatesListGrid.fetchData();

isc.DynamicForm.create({
ID:“baseRateForm”,
height:20,
left:157,
top:360,
width:850,
cellPadding:5,
numCols:4,
colWidths:50,
layoutAlign:“center”,
fields:[
{ name: “baseRatesList”, title: “”, type: “canvas”,
canvas: “baseRatesListGrid”
},
{
name:“reverse”,
startRow:true,
width:100,
title:“Reverse”,
height:25,
align:“center”,
type:“button”,
endRow:false,
_constructor:“FormItem”
},
{
name:“details”,
startRow:false,
width:100,
title:“Details”,
height:25,
align:“center”,
type:“button”,
endRow:false,
_constructor:“FormItem”
},
{
name:“save”,
startRow:false,
width:100,
title:“Save”,
height:25,
align:“center”,
type:“button”,
endRow:false,
click:“baseRateForm.saveData()”,
_constructor:“FormItem”
},
{
name:“close”,
startRow:false,
width:100,
title:“Close”,
height:25,
align:“center”,
type:“button”,
endRow:true,
_constructor:“FormItem”
}
],
dataSource:“masters_baserates_baseratesListDS”
});

isc.Toolbar.create({
ID: “addButton”,
align: “left”,
membersMargin:1,
height: 30, left: 890, top: 338,
buttons:[
{title: “+”, width:20, height:15, click: “baseRatesListGrid.startEditingNew()”}
]
});

code

DataSource

<DataSource
ID=“masters_baserates_baseratesListDS”
serverType=“generic”>
<fields>
<field name=“baseRatesList” type=“canvas” />
</fields>

&lt;operationBindings&gt;

&lt;binding operationType="update" serverMethod="saveBaseRatesDetails"&gt;
    &lt;serverObject  lookupStyle="spring" bean="dbfc.masters.system.BaseRatesDelegate"/&gt;
&lt;/binding&gt;
&lt;/operationBindings&gt;

</DataSource>

Delegate Layer
public DSResponse saveBaseRatesDetails(BaseRates baseRates,DSResponse dsresponse){
getBaseRatesService().saveBaseRatesDetails(baseRates);0
return dsresponse;
}

Regards,
Arul.K

What is your question? You seem to have a BaseRatesService that can save beans, so it would appear that you’re done? If you’re getting an error, you should post the logs.

Hi,
i want to know to how to handle the list of values in Spring method. If there are 10 rows of data is present in listgrid and i want to save it . how to handle it in spring method. Help me to do this
Regards
Arulkumar.K

If you’re trying to do a “mass update” (don’t save changes until the user has modified several records), set autoSaveEdits:false, and trigger saving via a call to saveAllEdits(). This will result in a queue of DSRequests being sent in one Http request, and your Spring method will be called once per record.

Hi,

For masupdate what you are saying is correct. Is it possible for the spring method can expect a list of object. Since I want update all the records in one shot. I don’t want to have the queue of DSRequests. Please let me know.

The best pattern is generally to handle each update individually, that way, you have a method that can also be used for updates outside of the mass update scenario. If you want to share resources between different calls to the update method, set them as httpServletRequest attributes.

Hi,

I want the update method to be called only once with the list of objects. As you said where to set them, in DMI.java or .xml file. I have added code for jsp. xml, java. Pls help me.

isc.ListGrid.create({
ID:“imageGrid”,
left:“2%”, top:80,width:“96%”,height:“80%”,
wrapCells:true,
fixedRecordHeights:false,
showAllRecords:false,
alternateRecordStyles:true,
dataSource:“listGridDMI”,
canEdit: true,
editByCell: true,
autoSaveEdits:false,
editEvent: “click”,
dataPageSize: 20,
drawAheadRatio: 4,
fields:listGridFields

});

<operationBindings>
<binding operationType=“fetch” serverMethod=“fetchData”>
<serverObject lookupStyle=“new” className=“com.db.chob.web.list.ListGridDMI”/>
</binding>
<binding operationType=“update” serverMethod=“updateData”>
<serverObject lookupStyle=“new” className=“com.db.chob.web.list.ListGridDMI”/>
</binding>
</operationBindings>

public DSResponse updateData(MenuItem criteria, DSRequest request) throws Exception {

}

That’s fine so far, this will cause updateData to be called once per update. As stated previously, the best approach is to process each request separately and re-use any resources (such as SQL or Hibernate session) via storing them as HttpServletRequest attributes.

If you don’t feel up to this somehow, you can always declare the RPCManagar as an argument to your DMI and call getRequests(), but this is a worse approach, and you will still need to write code that ignore the subsequent calls to updateData() for the requests you have already processed.