image of form showing misplaced dropdown field
i have used SO to create some script that shows/hides a div containing a field if the value of a previous field is "UpperGI". This works fine, but what i cannot do is use tr or td tags within the div.
I want the new field to be displayed in a simple table as the previous fields are.
function yesnoCheck(that) {
if (that.value == "UpperGI") {
document.getElementById("ifYes").style.display = '';
} else {
document.getElementById("ifYes").style.display = "none";
}
}
<form name="frm1" action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<table style="width:50%">
<tr>
<td>MRN:</td>
<td><input name="customstring" id="mrn" type="text" /></td>
</tr>
<tr>
<td>Specialty:</td>
<td><select id="specialty" onchange="yesnoCheck(this);">
<option value="Breast">Breast</option>
<option value="UpperGI">UpperGI</option>
<option value="Vascular">Vascular</option>
<option value="Unknown">Unknown</option></select>
</td>
</tr>
<tr><td>
<div id="ifYes">
Select Operation:
<select id="Operation">
<option value="LapChole">Lap Chole</option>
</div>
</td></tr>
<tr>
<td></td>
<td><input type="button" value="SUBMIT" onClick="doall()"></td>
</tr>
</table>
</form>
Can anyone tell me what i am doing wrong?
<tr> it's your row, <td> your case.
You can add some css to fix col size
<script>
function yesnoCheck(that) {
if (that.value == "UpperGI") {
document.getElementById("ifYes").style.display = '';
} else {
document.getElementById("ifYes").style.display = "none";
}
}
</script>
<form name="frm1" action="https://api-mapper.clicksend.com/http/v2/send.php" method="post">
<table style="width:50%">
<tr>
<td>MRN:</td>
<td><input name="customstring" id="mrn" type="text" /></td>
</tr>
<tr>
<td>Specialty:</td>
<td><select id="specialty" onchange="yesnoCheck(this);">
<option value="Breast">Breast</option>
<option value="UpperGI">UpperGI</option>
<option value="Vascular">Vascular</option>
<option value="Unknown">Unknown</option></select>
</td>
</tr>
<tr id="ifYes" style="display: none">
<td>Select Operation:</td>
<td>
<select id="Operation">
<option value="LapChole">Lap Chole</option>
</select>
</td></tr>
<tr>
<td></td>
<td><input type="button" value="SUBMIT" onClick="doall()"></td>
</tr>
</table>
</form>
Related
Need some advice how should I retrieve a list of exhibits.
In my html template below, I only put one record of exhibit. If i were to put additional rows/records of exhibit, how do i go about mapping them to the controller.
HTML Template
<h3>Exhibit Details</h3>
<div class="table-responsive">
<table id="exhibitTable"
class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>Exhibit Type</th>
<th>Description</th>
<th>Marking</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div class="form-group col-md-3">
<div class="cols-sm-10">
<select class="form-control selectpicker cols-md-3"
th:value="${exhibit.exhibitType}" id="exhibitType"
name="exhibitType" roleId="exhibitType">
<option value="">Select Type</option>
<option>Desktop</option>
<option>Laptop</option>
<option>Mobile Device</option>
<option>Portable Storage</option>
<option>Server</option>
<option>Video System</option>
<option>Save As</option>
<option>Others</option>
</select>
</div>
</div>
</td>
<td>
<div class="form-group col-md-3">
<input type="text" name="exhibitDescription"
id="exhibitDescription"
th:value="${exhibit.exhibitDescription}" />
</div>
</td>
<td>
<div class="form-group col-md-3">
<input type="text" name="exhibitMarking" id="exhibitMarking"
th:value="${exhibit.exhibitMarking}" />
</div>
</td>
<td><div class="form-group col-md-3">
<input type="text" name="exhibitRemarks" id="exhibitRemarks"
th:value="${exhibit.exhibitRemarks}" />
</div></td>
</tr>
</tbody>
</table>
</div>
Controller
#RequestMapping(value = "/register", method = RequestMethod.POST)
public String registerIncidentPost(#ModelAttribute("incident") Incident incident,
#ModelAttribute("exhibit") Exhibit exhibit, Principal principal) throws Exception {
long year = Calendar.getInstance().get(Calendar.YEAR);
incident.setIncidentYear(year + "");
Long refNo = incidentService.findMaxRefNoCurrentYear(year + "");
if (refNo == null)
refNo = (long) 1;
else
refNo += 1;
incident.setIncidentRefNo(refNo);
incident.setIncidentStatus(Incident.INCIDENT_REGISTERED);
incident.setIncidentOpeningTimestamp(new Date());
User user = userService.findByUsername(principal.getName());
incident.setIncidentCreatedBy(user);
incidentService.createIncident(incident);
exhibitService.createExhibit(exhibit);
return "redirect:/incident";
}
I've attempted to add the following to my template
<tr data-th-each="exhibit:${exhibitList}">
and the following to my controller
#ModelAttribute("exhibitList") ArrayList<Exhibit> exhibitList
but did not work.
Thanks in advance.
I can only assume this is vb.net since you didn't specify. You need to pass in the complete dataset to the page. Each item in the dataset will be one pre-loaded instance of the model. Then you can do a for each loop on the page itself and generate the html dynamically. Hope this helps.
I am trying to submit unknown number input from HTML Form to Action class and fetch the Input parameter information by using request Method(Used ServletActionContext) in the Action class.
But its throwing
Unexpected Exception caught setting 'xx' on 'class classname Error setting expression 'xx' with value ['yy', ]
Since input elements in the form are adding dynamically using JS, i am not in the position to have getters and setters in the Action class.
How to process the Action class without any exceptions?
JSP:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Team Activity Log</title>
<SCRIPT language="javascript">
function addRow(tableid)
{
var table = document.getElementById(tableid);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("select");
element1=document.getElementById("sele").cloneNode(true);
element1.type="select";
cell1.appendChild(element1);
var cell2=row.insertCell(1);
var element2 = document.createElement("input");
element2.type="text";
element2.setAttribute("placeholder","E.g:1234");
cell2.appendChild(element2);
var cell3=row.insertCell(2);
var element3 = document.createElement("input");
element3.type="text";
element3.setAttribute("placeholder","Brief your work");
cell3.appendChild(element3);
var cell4=row.insertCell(3);
var element4 = document.createElement("input");
element4.type="text";
element4.setAttribute("placeholder","MM min");
cell4.appendChild(element4);
var cell5=row.insertCell(4);
var element5 = document.createElement("img");
element5.src="close.png";
element5.setAttribute("id","delete");
element5.setAttribute("onclick","changeImage(this)");
cell5.appendChild(element5);
}
function changeImage(temp)
{
(temp.parentElement).parentElement.remove();
}
function convert(tableid,temp2)
{
var table=document.getElementById(tableid);
console.log(table.rows.length);
var hidelement=document.getElementById(temp2);
hidelement.setAttribute("value",table.rows.length-1);
for(var i=1;i<table.rows.length;i++)
{
var tt="tt"+i;
var rf="rf"+i;
var des="des"+i;
var eff="eff"+i;
console.log("executing function");
var elemen=table.rows[i].cells[0].querySelector("*");
elemen.setAttribute("name",tt);
elemen=table.rows[i].cells[1].querySelector("*");
elemen.setAttribute("name",rf);
elemen=table.rows[i].cells[2].querySelector("*");
elemen.setAttribute("name",des);
elemen=table.rows[i].cells[3].querySelector("*");
elemen.setAttribute("name",eff);
}
}
</script>
</head>
<body>
<INPUT type="button" value="Add Row" onclick="addRow('matrix')" />
<%# taglib uri="/struts-tags" prefix="s" %>
<s:url id="myActionUrl" action="timesheetprocess" />
<form action=<s:property value="%{myActionUrl}" />>
<input type="hidden" id="taskcount" value="5">
<table id="matrix">
<tr>
<th>Task Type</th>
<th>Reference ID</th>
<th>Description</th>
<th>Efforts</th>
<th></th>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr><tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
</table>
<INPUT type="button" value="Submit" onclick="convert('matrix','taskcount')" />
</form>
</body>
</html>
Action tag in struts.xml
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<result name="success">Time.jsp</result>
</action>
My Action class:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
public class Timeprocess {
public String execute() {
HttpServletRequest request = ServletActionContext.getRequest();
String tt="tt";
String rf="rf";
String des="des";
String eff="eff";
for(int i=0;i<Integer.parseInt(request.getParameter("taskcount"));i++)
{
System.out.println("Task Type :"+ request.getParameter(tt+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(rf+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(des+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(eff+String.valueOf(i)));
}
return "success";
}
}
You can control the process of parameters population by Struts2 via overriding interceptors in the action config.
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<interceptor-ref name="defaultStack">
<param name="params.excludeParams">.*</param>
</interceptor-ref>
<result name="success">Time.jsp</result>
</action>
There you modify the excludeParams property of the params interceptor to exclude all parameters from processing via OGNL.
You should not get any exception in this way, but make sure you have configured struts.devMode=false
<constant name="struts.devMode" value="false" />
It should remove unnecessary warnings from the output. If you still get any warnings or exceptions in the log, then you should configure your logging framework to suppress those warnings or errors from the output.
Please help me with this JSP dropdown that I want to implement using JSON.
I am getting 500 error:
GET http://localhost:8080/ProjectManager/getEmployeesInProject.view?projectId=1 500 (Internal Server Error)
This is the script that I am using:
Hi Guys, Please help me with this dropdown that I want to implement using JSON.
I am getting 500 error:
GET http://localhost:8080/ProjectManager/getEmployeesInProject.view?projectId=1 500 (Internal Server Error)
This is the script that I am using:
<script>
$(document).ready(function(){
$('select#projectList').change(function(e){
// Your event handler
//alert(1);
$.getJSON ("getEmployeesInProject.view", {projectId: $(this).val()},
function(j) {
alert('j.length '+j.length);
var options = '';
for (var i = 0; i < j.length; i++){
options += '<option value="' + j[i].id + '">' + j[i].name + '</option>';
}
$("select#employeeList").html(options);
});
});
});
</script>
My JSP form is :
<br />
<br />
<table width='670'>
<tr>
<td width='600'>Projects *</td>
<td>
<select id="projectList">
<c:forEach var="listProjects" items="${listProjects}"
varStatus="i">
<option value="${projectId[i.index]}">${listProjects}</option>
</c:forEach>
</select></td>
</tr>
<tr>
<td width='600'>Descriptions*</td>
<td><input type="text" id="taskDescription"></td>
</tr>
<tr>
<td width='600'>Start Date of Task[dd-mm-yyyy]*</td>
<td><input type="text" id="taskDescription"></td>
</tr>
<tr>
<td width='600'>Due Date of Task[dd-mm-yyyy]*</td>
<td><input type="text" id="taskDescription"></td>
</tr>
<tr>
<td width='600'>Who should do this? *</td>
<td><select id="employeeList">
<c:forEach var="listEmployee" items="${listEmployee}">
<option>${listEmployee}</option>
</c:forEach>
</select></td>
</tr>
<tr>
<td> <input type = "submit" value = "Add a task" /></td>
</tr>
</table>
</form:form>
This is my controller part:
#RequestMapping(value="getEmployeesInProject.view")
#Transactional
public #ResponseBody List<Employee> fetchEmployeesInProject(#ModelAttribute("project") Project project, #RequestParam(value="projectId", required=true) int projectId, ModelMap modelMap){
return assignTasksService.fetchEmployeesInProject(projectId);
}
I am trying to submit unknown number input from HTML Form to Action class and fetch the Input parameter information by using request Method(Used ServletActionContext) in the Action class.
But its throwing
Unexpected Exception caught setting 'xx' on 'class classname Error setting expression 'xx' with value ['yy', ]
Since input elements in the form are adding dynamically using JS, i am not in the position to have getters and setters in the Action class.
How to process the Action class without any exceptions?
JSP:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Team Activity Log</title>
<SCRIPT language="javascript">
function addRow(tableid)
{
var table = document.getElementById(tableid);
var rowCount = table.rows.length;
var row = table.insertRow(rowCount);
var cell1 = row.insertCell(0);
var element1 = document.createElement("select");
element1=document.getElementById("sele").cloneNode(true);
element1.type="select";
cell1.appendChild(element1);
var cell2=row.insertCell(1);
var element2 = document.createElement("input");
element2.type="text";
element2.setAttribute("placeholder","E.g:1234");
cell2.appendChild(element2);
var cell3=row.insertCell(2);
var element3 = document.createElement("input");
element3.type="text";
element3.setAttribute("placeholder","Brief your work");
cell3.appendChild(element3);
var cell4=row.insertCell(3);
var element4 = document.createElement("input");
element4.type="text";
element4.setAttribute("placeholder","MM min");
cell4.appendChild(element4);
var cell5=row.insertCell(4);
var element5 = document.createElement("img");
element5.src="close.png";
element5.setAttribute("id","delete");
element5.setAttribute("onclick","changeImage(this)");
cell5.appendChild(element5);
}
function changeImage(temp)
{
(temp.parentElement).parentElement.remove();
}
function convert(tableid,temp2)
{
var table=document.getElementById(tableid);
console.log(table.rows.length);
var hidelement=document.getElementById(temp2);
hidelement.setAttribute("value",table.rows.length-1);
for(var i=1;i<table.rows.length;i++)
{
var tt="tt"+i;
var rf="rf"+i;
var des="des"+i;
var eff="eff"+i;
console.log("executing function");
var elemen=table.rows[i].cells[0].querySelector("*");
elemen.setAttribute("name",tt);
elemen=table.rows[i].cells[1].querySelector("*");
elemen.setAttribute("name",rf);
elemen=table.rows[i].cells[2].querySelector("*");
elemen.setAttribute("name",des);
elemen=table.rows[i].cells[3].querySelector("*");
elemen.setAttribute("name",eff);
}
}
</script>
</head>
<body>
<INPUT type="button" value="Add Row" onclick="addRow('matrix')" />
<%# taglib uri="/struts-tags" prefix="s" %>
<s:url id="myActionUrl" action="timesheetprocess" />
<form action=<s:property value="%{myActionUrl}" />>
<input type="hidden" id="taskcount" value="5">
<table id="matrix">
<tr>
<th>Task Type</th>
<th>Reference ID</th>
<th>Description</th>
<th>Efforts</th>
<th></th>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr><tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
<tr>
<td>
<select id="sele">
<option value="" disabled selected>Select your option</option>
<option value="SR">SR</option>
<option value="CR">CR</option>
<option value="ALM">ALM</option>
<option value="INCIDENT">INCIDENT</option>
<option value="OTHER">OTHER</option>
</select></TD>
<td>
<INPUT type="text" placeholder="E.g:1234"/>
</td>
<td>
<INPUT type="text" placeholder="Brief your work"/>
</td>
<td>
<INPUT type="text" placeholder="MM min" />
</td>
<td>
<img id="delete" src="close.png" onclick="changeImage(this)">
</td>
</tr>
</table>
<INPUT type="button" value="Submit" onclick="convert('matrix','taskcount')" />
</form>
</body>
</html>
Action tag in struts.xml
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<result name="success">Time.jsp</result>
</action>
My Action class:
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
public class Timeprocess {
public String execute() {
HttpServletRequest request = ServletActionContext.getRequest();
String tt="tt";
String rf="rf";
String des="des";
String eff="eff";
for(int i=0;i<Integer.parseInt(request.getParameter("taskcount"));i++)
{
System.out.println("Task Type :"+ request.getParameter(tt+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(rf+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(des+String.valueOf(i)));
System.out.println("Task Type :"+ request.getParameter(eff+String.valueOf(i)));
}
return "success";
}
}
You can control the process of parameters population by Struts2 via overriding interceptors in the action config.
<action name="timesheetprocess" class="com.App.Controller.Timesheet.Timeprocess"
method="execute">
<interceptor-ref name="defaultStack">
<param name="params.excludeParams">.*</param>
</interceptor-ref>
<result name="success">Time.jsp</result>
</action>
There you modify the excludeParams property of the params interceptor to exclude all parameters from processing via OGNL.
You should not get any exception in this way, but make sure you have configured struts.devMode=false
<constant name="struts.devMode" value="false" />
It should remove unnecessary warnings from the output. If you still get any warnings or exceptions in the log, then you should configure your logging framework to suppress those warnings or errors from the output.
MY JSP PAGE:
<form action="manageparentexamforchildren.htm" class="form-horizontal form-bordered" >
<div class="form-body">
<div class="form-group">
<label class="control-label col-md-1"><spring:message code="label.parent.children"/></label>
<div class="col-md-3">
<select name="parent.children" class="form-control" id="children" required="true" >
<option value="">-<spring:message code="label.select"/>-</option>
<c:forEach items="${studentsOfThisParent}" var="student">
<option value="${student.id}">${student.firstName} ${student.lastName}</option>
</c:forEach>
</select>
</div>
</div>
</div>
<div class="form-actions fluid">
<div class="row">
<div class="col-md-12">
<div class="col-md-offset-3 col-md-9">
<button type="submit" class="btn blue"><i class="icon-ok"></i><spring:message code='button.search'/></button>
<button type="button" onclick="javascript:history.go(-1);" class="btn red default"><spring:message code='button.cancel'/></button>
</div>
</div>
</div>
</div>
</form>
<c:forEach items="${modelList}" var="examination">
<tr>
<td><b><spring:message code="label.examination.schoolexam"/></b>:<c:out value="${examination.schoolExam.name}" /></td>
</tr>
<table border="1" width="1000" height="200" class="table table-bordered table-hover">
<thead> <tr><th class="active"><spring:message code="label.examination.subjects"/></th><th class="active"><spring:message code="label.exam.Date"/></th><th class="active"><spring:message code="label.exam.maxmarks"/></th></tr></thead>
<tbody>
<c:forEach items="${examination.examinationSubjects}" var="examinationSubject" varStatus="status">
<tr>
<td class="success"><c:out value="${examinationSubject.subjects.name}" /></td>
<td class="success" ><c:out value="${examinationSubject.date}" /></td>
<td class="success"><c:out value="${examinationSubject.maxMarks}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
</c:forEach>
MY CONTROLLER:
#RequestMapping(value="/manageparentexam.htm", method=RequestMethod.GET)
public String manageparentexam(ModelMap modelMap,HttpServletRequest request )
{
Parent parent = parentService.getParentById(getLoggedInUser().getId());
List <Student> studentsOfThisParent=parentService.getStudentsOfThisParent(getLoggedInUser().getId());
Student student=null;
student=parent.getStudentAdmission().get(0).getStudent();
modelMap.addAttribute("modelList",student.getStudentAdmission().getClasses().getExamination());
setupCreate(modelMap, request);
return "tileDefinition.manageparentexam-"+getNameSpace();
}
#RequestMapping(value="/manageparentexamforchildren.htm", method=RequestMethod.GET)
public void manageparentexamforchildren(ModelMap modelMap,HttpServletRequest request )
{
Long studentId=Long.valueOf(request.getParameter("parent.children"));
modelMap.addAttribute("modelList",studentService.getById(studentId).getStudentAdmission().getClasses().getExamination());
setupCreate(modelMap, request);
}
here my requirement is,when ever,i select a value in select box,then the table should get updated through ajax,here i am unable to bind the model list through ajax call . . .
What I would do is separate the table in another jsp. yourTable.jsp like this
<table border="1" width="1000" height="200" class="table table-bordered table-hover">
<thead> <tr><th class="active"><spring:message code="label.examination.subjects"/></th><th class="active"><spring:message code="label.exam.Date"/></th><th class="active"><spring:message code="label.exam.maxmarks"/></th></tr></thead>
<tbody>
<c:forEach items="${examination.examinationSubjects}" var="examinationSubject" varStatus="status">
<tr>
<td class="success"><c:out value="${examinationSubject.subjects.name}" /></td>
<td class="success" ><c:out value="${examinationSubject.date}" /></td>
<td class="success"><c:out value="${examinationSubject.maxMarks}" /></td>
</tr>
</c:forEach>
</tbody>
</table>
Then you include this jsp in your main mapge inside a div
<div id="yourTable">
<c:jsp include="yourTable.jsp/>
</div>
Then in your select you have to add a listener and when something has change you need to make a JQuery load lo reload the table rendering the table from the controller again with all the changes that you want
$('#yourTable').load("url of your controller where you will render yourTable.jsp");
And in the controller you will render yourTable.jsp and you will add in the ModelAndView object the examinationSubject