Hi,
when i edit the fields in a list grid, I am getting only those values which are edited in the grid.
The unedited fields dont show their original value, but it gives empty string or -1(for int).
I am using data services to sync with server data using java bean model.
I am using the example code from data services
List updatedIds = new ArrayList();
Iterator itemIter = reqds.getRecords().iterator();
while (itemIter.hasNext()) {
Item item = (Item) itemIter.next();
// My item has say properties name and lang with initial values "Jay" and "Java"
I edit the value of "Java" to "asp" in list grid. Now if I see the properties,
name has no value(it lost the original Jay value), and lang has value "asp".
}
Iterator itemIter = reqds.getRecords().iterator();
while (itemIter.hasNext()) {
Item item = (Item) itemIter.next();
// My item has say properties name and lang with initial values "Jay" and "Java"
I edit the value of "Java" to "asp" in list grid. Now if I see the properties,
name has no value(it lost the original Jay value), and lang has value "asp".
}
Any suggestions, or is that the way data services behave?
Jay

I have another question
7 August, 2008 - 23:47 — JayI have another question too.
I select a row or multiple rows and click the delete button. I have a handler for the click event.
<e:handler event=\"click\" type=\"application/javascript\">\n<![CDATA[
bb.document.getElementById('test').deleteSelectedRows()
]]></e:handler>
</b:menuBarItem>
// 'test' is the listGrid id
when you click the delete button, it does go the the deletehandler which I defined.
But the requestDataSource and responsedataSource objects has no values.I mean, those arrayList and Hashmaps are empty.What is the reason for that?
So when I try to get list from the getAttributes method it returns null and throws exception.
HttpSession session = (HttpSession)ctx.getExternalContext().getSession(false);
HttpServletRequest request = (HttpServletRequest) ctx.getExternalContext().getRequest();
try
{
List deletedIds = new ArrayList();
//Retrieve all the items' ids that have been deleted
List ids = (List) reqds.getAttributes().get("records");
// The ids is null here... And so it throws exception in the next line.
for (int i = 0; i < ids.size(); i++) {
Long itemId = (Long) ids.get(i);
Project project = new Project();
project.setProjectId(itemId);
When you select a record and pass the control to handler class, what does the reqds contain? Does it hold the selected record or the id of the selected record or anything like that?
the datamodule-config file is the same, except that I change the Bean.
Another thing to note is that, reqds.getAttribute("name") throws noSuchMethodException.
Regards
Jay
Hi Jay, As for your second
12 August, 2008 - 11:23 — Oleg.KvyatkovskiyHi Jay,
As for your second question - it should work fine.
1. You can start from browser and review request being sent to server. You can use e.g. Firebug.
It looks like following if you are selecting records 3 and 5 and push Delete button:
request: <?xml version="1.0"?><request _actions_="true"><delete records="3,5"></delete></request>
action: delete
dataType: application/xml
2. If you see this above request sent to server then check datamodule-config.xml. It should contain mapping for records attribute
Regards
Oleg
Hi, Any idea on this? Jay
11 August, 2008 - 17:51 — JayHi,
Any idea on this?
Jay
real values are only in updated fields
12 August, 2008 - 10:52 — Oleg.KvyatkovskiyHi Jay,
The situation you have described is normal behavior of DataServices. You are receiving bean on server part during update that contains real values only in updated fields. Other fields contain -1 (for int) and null (for String).
You can find nice example how it can be managed in
http://download.backbase.com/bdn/java/examples/ds-introduction.war
com.backbase.dataservices.example.dao.impl.InlineMovieDAO.update() method.
for (int i = 0; i < getMoviesSize(); i++) {
Movie oldMovie = (Movie) getMovies().get(i);
if (oldMovie.getId() != movie.getId()) {
// movie not matched
continue;
}
// changing movie found
if (movie.getRank() != -1) {
oldMovie.setRank(movie.getRank());
}
if (movie.getTitle() != null) {
oldMovie.setTitle(movie.getTitle());
}
if (movie.getRating() != null) {
oldMovie.setRating(movie.getRating());
}
if (movie.getDirector() != null) {
oldMovie.setDirector(movie.getDirector());
}
if (movie.getGenre() != null) {
oldMovie.setGenre(movie.getGenre());
}
if (movie.getYear() != -1) {
oldMovie.setYear(movie.getYear());
}
if (movie.getVotes() != -1) {
oldMovie.setVotes(movie.getVotes());
}
break;
}
}
Regards
Oleg