• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 2 | How to populate a form by selecting a value from a table in the same page

 
Vikas K Gupta
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the following code what I want is when I click edit in a particular row of the table showing list of employee number and employee name passing employee number as parameter............. the name and employee number should be populated in the form so that I can edit and resubmit the form .

when edit will be clicked a topic will be published with parameter as employee number and wanted to use dojo plugin to populate the same in the form.

Please help to get the code in "//WHAT TO WRITE HERE"


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>#### Gurgaon | Welcome</title>
<sx:head debug="true" cache="false" parseContent="true"/>
<script type="text/javascript">
dojo.event.topic.subscribe("/submittedTopic", function(event, widget){
dojo.byId("empName").value="";
dojo.byId("empCode").value="";

});
dojo.event.topic.subscribe("/editTopic", function(data, type, request){


//WHAT TO WRITE HERE


}
})
</script>
</head>
<body>



<s:form action="addEmpAction" id="addEmp">
<s:textfield id="empName" name="employee.name" label="Name"/>
<s:textfield id="empCode" name="employee.employeeCode" label="Employee Code"/>
<sx:submit highlightColor="blue" highlightDuration="2000" targets="tableDiv" afterNotifyTopics="/submittedTopic"
/><s:reset/>
</s:form>
<s:if test = "employeeList.size > 0">
<table border=1 >
<tr>
<th >Name</th>
<th>Code</th>
</tr>
<s:iterator value="employeeList" status="stat">
<tr class="row${stat.count % 2} first${stat.first} last${stat.last}">
<td><s:property value="name" /></td>
<td><s:property value="employeeCode" /></td>
<td><s:url var="deleteUrl" action="deleteEmp">
<s:param name="employee.employeeCode" value="employeeCode"/>
</s:url>
<sx:a highlightColor="blue" highlightDuration="2000" href="%{deleteUrl}" targets="tableDiv" notifyTopics="/deletedTopic">Delete</sx:a>
</td>
<td><sx:a id="a_%{employeeCode}" notifyTopics="/editTopic">edit</sx:a></td>
</tr>
</s:iterator>
</body>
</html>
 
Raza Mohd
Ranch Hand
Posts: 247
Java MyEclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please use code tags..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic