Victor Grazi wrote the following on 9/12/2004 10:28 AM:

For example if the page is displaying a collection of beans as an html table, and there is an update and delete button on each row, how do you pass the id of the record to those buttons and how does the Action capture the button (update or delete, and record id) that was pressed.

For the example above I usually have the buttons use a bit of javascript and use a link to get to the action I want passing the id. There are a bunch of other ways you can do it as well. This is just one way. (If not using JSP2.0 use html-el button below. Also better to not hardcode the button names like I did below and instead use a name from your resources file. For sake of brevity I didn't show that below.)


//looping over users on JSP...

<c:url var="url" scope="page" value="/updateUser.do">
  <c:param name="id" value="${user.id}"/>
</c:url>
<input TYPE="button" VALUE="UPDATE" onClick="goToLink('${url}');"/>

<c:url var="url" scope="page" value="/deleteUser.do">
  <c:param name="id" value="${user.id}"/>
</c:url>
<input TYPE="button" VALUE="DELETE" onClick="goToLink('${url}');"/>


//javascript somewhere function goToLink(linkLocation) { window.location = linkLocation; }

--
Rick

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to