[STRUTS] How to manage a table

L

loris_p

Hi, I have a table of users and I have to add for each row two buttons
(or links): "Modify" and "Delete". With JSP and Servlets I used to
pass parameters directly in the URL like this:
http://localhost/myapp/deleteUser?id=3
but I don't know how to make this with Struts Actions..
Can someone help me?
Thanks :)
 
M

mikwiat

Hi, I have a table of users and I have to add for each row two buttons
(or links): "Modify" and "Delete". With JSP and Servlets I used to
pass parameters directly in the URL like this:http://localhost/myapp/deleteUser?id=3
but I don't know how to make this with Struts Actions..
Can someone help me?
Thanks :)

i guess that you have to make two forms, one for the update, and the
second for delete.

Put some hidden field with value od your id.

for ex: <input type='hidden' value='" + user.getUserID + "'
name='userID' />

and send it to JSP that sends values to your method :)

understand?
 
S

sandy

Hi, I have a table of users and I have to add for each row two buttons
(or links): "Modify" and "Delete". With JSP and Servlets I used to
pass parameters directly in the URL like this:http://localhost/myapp/deleteUser?id=3
but I don't know how to make this with Struts Actions..
Can someone help me?
Thanks :)

----------------------
yeh same thing i did in struts but by using dispatch action and
javascript

<input type="button" value="Edit" class="edit"
onclick="window.location.href='action.do?methodToCall=edit&id=<%= --1
or 2 or 3 --- %>';"/>
<input type="button" value="Delete" class="deleteButton"
onclick="window.location.href='action.do?methodToCall=delete&id=<%=
---- 1,2,3---%>';"/></td>
 
L

Lew

sandy said:
----------------------
yeh same thing i did in struts but by using dispatch action and
javascript

<input type="button" value="Edit" class="edit"
onclick="window.location.href='action.do?methodToCall=edit&id=<%= --1
or 2 or 3 --- %>';"/>
<input type="button" value="Delete" class="deleteButton"
onclick="window.location.href='action.do?methodToCall=delete&id=<%=
---- 1,2,3---%>';"/></td>

You don't absolutely need Javascript. You can set up Struts to decipher the
method name of the Action class and dispatch to a different method for
different submit inputs. You can also name the submits the same with
different values and dispatch to the correct method within the Action's
execute method based on those values.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,162
Latest member
GertrudeMa
Top