Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

struts 2 multiple delete buttons pass value to action

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have struts 2 question that i cannot find the answer for. can someone please help.
I have a table dynamically return after pressing search. in front of each row a dynamically delete button is created. how can I associate each button to the record:
JSP:
<div>
<s:iterator value="users" status="index" >
<s:if test="#index.first == true">
<tr style="font-weight:bold; background: #2E2E2E ">
<td></td>
<td></td>
<td>User ID</td>
<td>First Name</td>
<td>Last Name</td>
<td>Email</td>
<td>Status</td>
<td>Type</td>
</tr>
</s:if>
<s:if test="#index.odd == true">
<tr style="background: grey">
</s:if>
<s:else>
<tr style="background: #0B243B ">
</s:else>
<td><s:submit type="image" src="images/icons/deleteButton.ico" theme="simple" method="delete" name="myUser" value="<s:property value='userID'/>" /></td>
<td><s:property value="userID"/></td>
<td><s:property value="firstName"/></td>
<td><s:property value="lastName"/></td>
<td><s:property value="email"/></td>
<td><s:property value="statusID"/></td>
<td><s:property value="typeID"/></td>
</tr>
</s:iterator>
</div>

Action:
public class userAdminAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private String myUser;

public String delete() throws Exception {
System.out.println("delete:");
System.out.println("My User is: " + myUser);
return "success";
}

public String getMyUser() {
return myUser;
}

public void setMyUser(String myUser) {
this.myUser = myUser;
}
}

OUTPUT:
delete:
My User is: null

Can someone please help........
 
Ranch Hand
Posts: 213
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to return the ID value so IMHO you have two options. Replace the submit tag with an action tag or handle the click event on the submit tag to call the action and return the id value.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic