You can simply add your book object to the ModelAndView. Use a Map to include the book.
Map objects = new HashMap(); objects.put("ParentBook", book); objects.put("bookFileList",bookManager.get(book.getId()).getBookFiles()); ModelAndView().addObject("bookFileList", objects); On Thu, Nov 5, 2009 at 3:54 PM, gerogut <gero...@yahoo.com> wrote: > > > Can you describe the workflow. > How do you add BookFile to Book object ? > > Workflow: > 1. Books are loaded, the controller is BookController and BookManager gets > all books. (books.jsp) > > 2. I select a book and BookForm is loaded (with book info), controller is > BookFormController, command class is Book. (bookform.jsp) > > 3. I click de button "Files" and BookFileList is loaded, the controller is > BookFileController and there bookManager gets the book and then the set of > bookFiles which is returned as: > > return new > > ModelAndView().addObject("bookFileList",bookManager.get(book.getId()).getBookFiles()); > > so the list of files is displayed. (bookfiles.jsp) > > 4. When I click on a file, bookFileForm is displayed, the controller is > BookFileFormController and it has a different manager wich is > BookFileManager.(bookfileform.jsp) Here it's the problem, I can't get to > associate the file to the book because I don't know how to get the book > without an id. In this controller I only have the id of the bookFile. So, > answering you second question, I can't add BookFile to the Book object. > > Gero > > > ramzi khlil wrote: > > > > Can you describe the workflow. > > How do you add BookFile to Book object ? > > > > Ramzi > > > > > > > > On Thu, Nov 5, 2009 at 2:57 PM, gerogut <gero...@yahoo.com> wrote: > > > >> > >> This is what I have annotated in BookFile set. > >> > >> @OneToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) > >> @JoinTable(name = "book_file", joinColumns = > >> {...@joincolumn(name="book_id")}, > >> inverseJoinColumns = {...@joincolumn(name = > >> "bookFile_id")}) > >> @LazyCollection(value = LazyCollectionOption.FALSE) > >> public Set<BookFile> getBookFiles() { > >> return bookFiles; > >> } > >> > >> Gero > >> > >> > >> ramzi khlil wrote: > >> > > >> > You may need to specify cascade attribute. > >> > > >> > Ramzi > >> > > >> > > >> > > >> > On Thu, Nov 5, 2009 at 12:50 PM, gerogut > >> > <gutierrez.geron...@gmail.com>wrote: > >> > > >> >> > >> >> Hi, I'm a begginer in this matter so I'm sorry if my questions are > >> >> stupid. > >> >> > >> >> I'm building a webapp to manage the books i have in my office. > >> >> I have a book class which has the info I need and it has a > >> Set<BookFile> > >> >> which will store file associated to that info. That is, the actual > pdf > >> of > >> >> the book, examples, etc. > >> >> > >> >> 1 - I declared the set with @OnToMany with a @JoinTable and > >> >> @LazyCollection > >> >> is that ok? It creates de DB ok and populates it with my sample data. > >> >> 2- Then I have a booksearch.jsp which allowws me to search through > the > >> >> books > >> >> and then shows me the list of books in books.jsp > >> >> 3- If I click on a book it sends me to bookform.jsp which shows me > >> book > >> >> info > >> >> in a form an I can update the info. > >> >> 4- When I click on the "files" button it takes me to the > bookfiles.jsp > >> >> which > >> >> is the list of files associated to that book, and then comes my > >> PROBLEM, > >> >> which I dont know how to resolve and maybe t comes from before. > >> >> 5- when I add a book it adds it to the DB but it does not add the > >> value > >> >> to > >> >> the joinTable so the file is not associated to the book. And i can't > >> >> acces > >> >> the value of the Book from bookFileFormController... > >> >> > >> >> Any suggestions, corrections, comments? THANK YOU. > >> >> -- > >> >> View this message in context: > >> >> > >> > http://old.nabble.com/Spring-MVC-or-General---Begginer-Question-tp26216556s2369p26216556.html > >> >> Sent from the AppFuse - User mailing list archive at Nabble.com. > >> >> > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > >> >> For additional commands, e-mail: users-h...@appfuse.dev.java.net > >> >> > >> >> > >> > > >> > > >> > >> -- > >> View this message in context: > >> > http://old.nabble.com/Spring-MVC---Begginer-Question-tp26216556s2369p26220378.html > >> Sent from the AppFuse - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > >> For additional commands, e-mail: users-h...@appfuse.dev.java.net > >> > >> > > > > > show gero...@yahoo.com as gerogut > -- > View this message in context: > http://old.nabble.com/Spring-MVC---Begginer-Question-tp26216556s2369p26222035.html > Sent from the AppFuse - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > For additional commands, e-mail: users-h...@appfuse.dev.java.net > >