File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts 2 | How to populate a form by selecting a value from a table in the same page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 | How to populate a form by selecting a value from a table in the same page" Watch "Struts 2 | How to populate a form by selecting a value from a table in the same page" New topic
Author

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

Vikas K Gupta
Greenhorn

Joined: Dec 07, 2010
Posts: 6
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

Joined: Jan 20, 2010
Posts: 247

please use code tags..


Good luck!!
A small leak can sink a Gigantic ship.>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 2 | How to populate a form by selecting a value from a table in the same page
 
Similar Threads
JspTranslate: End of content reached while more parsing required: tag nesting error?.
Struts2.1 div problem in tabbedpanel
result display error
List not refreshing after submit
DisplayTag problem to export Excel not working