Hi Freddy, Thanks for the quick reply. The book really rocks, this one little example just has me tripped up a bit. By using contact.id as the hidden field are you just creating a new Contact and overwriting the old contact though? I think I validated that is what is happening by removing a field in the form (e.g phoneNumber) and then editing an existing contact. When I do this using the sample code I loose the value in the removed form field (e.g phoneNumber). I don't believe this is the typical expected behavior for an update. I am not trying to be a stickler for a particular semantic behavior, just trying to understand how Stripes does its things under the covers. I have a lot of experience with java web development and any time I try a new framework I seem to spend most of my time understanding how it does what it does (that usually pays off once I encounter problems, often self inflicted ;-). For the life of me I was unable to figure out how Stripes could load an existing Contact using contact.id when the DAO lookup used contactId as the field to fetch existing an existing contact. Would you agree that the proper semantic behavior for an update to a contact would be to use contactId as the hidden field (based on the existing behavior of the action bean)? I hope I am not way off base here or misunderstanding your intentions in the example.
On Mon, Dec 29, 2008 at 6:27 PM, Freddy Daoud <[email protected]> wrote: > Hi Darryl, > > It's very nice to hear that you are enjoying the book. > > For the example that you mention: if you look at the bottom of > page 55(Paper) 65(PDF), you'll see that from the contact list page, > in contact_list.jsp, the "contactId" parameter is set to the > corresponding id of the contact on each row of the table, which is > retrieved using ${contact.id}. Now, when you click on an Update > link from the contact list, the contactId parameter will be sent > and used by the getContact() method of ContactBaseActionBean.java > to retrieve the contact. This allows to prepopulate the form. > > At this point, you have the form in contact_form.jsp. When that > form is submitted, all fields of the contact entered or modified > by the user are sent, but, as explained on page 56(Paper) 66(PDF), > we need to resubmit the contact id parameter. The hidden input > is set to "contact.id" because here we are just resubmitting the > id that was set in the contact object. We don't need the contactId > parameter anymore; that was just to prepopulate the form upon > arrival. > > Let me know if that helps. I hope you enjoy the rest of the book! > > Cheers, > Freddy > http://www.stripesbook.com > > On Mon, 29 Dec 2008 17:41:23 -0800, "Stoflet Darryl" <[email protected]> > said: > > Hi, > > > > I am new to Stripes but have been very intrigued for quite some time. The > > other java web frameworks have always left a bad taste with me (overly > > complex, difficult to troubleshoot etc). When the Stripes book from > > pragprog > > came out I snapped up a copy. > > > > So far I am pleased with the book and am taking my time absorbing it and > > following along with the examples (with slight customizations for my own > > better understanding). However I've run into an issue with the first > > contact > > form example and I am not sure if its something I did wrong when > > customizing > > the example or if there is a typo. On pg 55 there is a hidden form field > > and > > its name is set to contact.id. However, the checks within the ActionBean > > are > > for contactId, so when an update is submitted that contact is not found > > and > > thus not updated. > > Should the example hidden tag use a name of contactId rather than > > contact.id > > ? > > > > Btw: The example is also in the freely available forms pdf here: > > http://media.pragprog.com/titles/fdstr/forms.pdf on page 8. > > > > Thanks, > > Darryl > > > ------------------------------------------------------------------------------ > _______________________________________________ > Stripes-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/stripes-users >
------------------------------------------------------------------------------
_______________________________________________ Stripes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/stripes-users
