Tuesday, December 23, 2008

Adding Object to List using Ajax and Struts Step 49

Now that you added the appropriate data to your url, you will need to grab that data from the server. You should add this code to your saveBookAjax method.


String bookname=request.getParameter("book");
String author=request.getParameter("author");
String publisher=request.getParameter("bookPublisher");
String category=request.getParameter("category");
userForm.setAuthor(author);
userForm.setBookPublisher(publisher);
userForm.setBook(bookname);
userForm.setCategoryId(category);
this.saveBook(mapping, form, request, response);


This code sets all the objects in the form just like you did when you submitted the form. Since you already have a method that creates the new book object, you can call the saveBook method to finish adding the book to the database.
Go To Step 50

0 comments: