reset password
Author Message
msargent
Posts: 519
Posted 15:44 Feb 07, 2013 |

Hello Dr. Sun,

Regarding Editing an Entry in the Guestbook project, I'm trying to set a property Index that I added to the GuestBook bean. However, my program crashes when I try to invoke the GuestBook method I added called thisEntry(String id) that uses Index. When I debug, after I click a link to edit an entry (I set a break point to thisEntry) Index always is null. Here's my code from EditEntry.jsp. Index is always null, even if I put a string literal in for the value. 

...
Last edited by cysun at 15:57 Feb 07, 2013.
cysun
Posts: 2935
Posted 16:02 Feb 07, 2013 |

First of all, I edited out the code in your post. Please do NOT post large portion of code to any assignment in the forum. You can post code snippets if necessary.

Secondly, you need to embed the index of an entry in the Edit link (e.g. href="EditComment.jsp?index=...").

Finally, you don't need a currentEntry property. You can do ${gb.entries[param.index]} to get the entry at that index.

msargent
Posts: 519
Posted 16:19 Feb 07, 2013 |

Thanks. 

jonathankroening
Posts: 39
Posted 17:12 Feb 07, 2013 |

When applying the edits that have been made to the entry, are we to use <c:set target... or <jsp:setProperty... or something else?

I'm having trouble getting the changes to actually update the properties of the entry being edited.

cysun
Posts: 2935
Posted 19:55 Feb 07, 2013 |
jonathankroening wrote:

When applying the edits that have been made to the entry, are we to use <c:set target... or <jsp:setProperty... or something else?

I'm having trouble getting the changes to actually update the properties of the entry being edited.

You need to use <c:set> because <jsp:setProperty> can only set properties of a bean declared with <jsp:useBean>. In this case "gb" is the declared bean, but you want to set the properties of ${gb.entries[param.index]}.