struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Reumann <strut...@reumann.net>
Subject Re: Seeking master detail hello world
Date Sun, 12 Sep 2004 20:42:54 GMT
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message