Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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.
 
What's gotten into you? Could it be this tiny ad?
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic