I have page in which I am uploading one Excel file. If it has errors, I display those errors in a tabular format using display tag.
Everything works fine until the displaying. But if I have to sort or export the data then it stops working again and it redirects to same page without any data.
I guess for every action (like sort and export) it is hitting the database and hence at the next request it is not showing any data because it is not getting the file name.
Can anybody explain if I am right or wrong? I am new to this display tag.
Here is my JSP src code:
</head>
<body>
<form:form id="formAdd" method="post" action="locationSave.do"
commandName="location">
<form:hidden path="id" />
<form:hidden path="isDeleted" />
<form:hidden path="remarks" />
<form:hidden path="status" />
<form:hidden path="updatedDt" />
<input type="hidden" value="${locationCodes}" id="codes">
<table style="width: 1000px; border:0; cellspacing:1; cellpadding=0; class=table_border; align :center;">
<tr>
<td colspan="6" class ="H1">
Location Master
</td>
</tr>
<tr>
<td colspan="6" class="H2">
Add Location
</td>
</tr>
<tr>
<td style="width: 16%;" class ="tdheader_left"><form:label path="code">
<spring:message code="label.loccode" />
</form:label></td>
<td style="width: 16%;" class="tdheader_textbox"><form:input
path="code" accesskey="o" cssClass="input" size="7" maxlength="5"
id="code" /></td>
<td style="width: 16%;" class ="tdheader_left"><form:label path="name">
<spring:message code="label.locname" />
</form:label></td>
<td style="width: 16%;" class="tdheader_textbox"><form:input
path="name" accesskey="n" class="input" maxlength="20" size="25"
id="name" /></td>
<td style="width: 16%;" class ="tdheader_left"><form:label path="locGrp">
<spring:message code="label.locGrp" />
</form:label></td>
<td style="width: 16%;" class="tdheader_dropdown"><form:select accesskey="g"
path="locGrp.id" class="input" id="grpId">
<form:option value="-1" label="--- Select ---" />
<form:options items="${locGrp}" />
</form:select></td>
</tr>
<tr>
<td colspan="6" align="center" class="H1">
<input id="save" accesskey="s" type="submit" value="Save"/>
<input id="reset" accesskey="r" type="reset" value="Reset" />
<input type="button" accesskey="c" value="Cancel" onclick="window.location = 'location.do';" />
<input type="button" id="upload_file"
accesskey="a" value="Upload File"
/></td>
</tr>
</table>
</form:form>
<div id="formUpload" style="text-align:center;display:block;">
<form:form id="formFile" method="post" action="locationFileUpload.do" commandName="file" enctype="multipart/form-data">
Please select a file to upload : <input type="file" name="file" />
<input type="submit" value="upload" id="success" />
<c:if test="${locErrorList != null}">
<div id="uploaderror">
Following locations could not be uploaded
<display:table uid="2" name="locErrorList" class="displaytag" id="locError" pagesize="10" excludedParams="*" requestURIcontext="true"
defaultorder="ascending" requestURI="locationFileUpload.do" export="true" >
<display:column property="code" sortable="true" title="Location Code" headerClass="sortable" />
<display:column property="name" sortable="true" title="Location Name" headerClass="sortable" />
<display:column property="error" sortable="true" title="Reason For Failure" headerClass="sortable" />
</display:table>
</div>
</c:if>
</form:form>
</div>
</body>
</html>
The sort and pagination links generated by displaytag have the same request parameters as the ones sent in the request displaying the table. So, if you post a form with the request parameters foo=1
and bar=2
, and display a table as the result of this request submission, the generated links will have an href looking like this:
<a href="theRequestURI?foo=1&bar=2&d-...">
So, when you click on the links, you'll send a new request to your server, and this request should use the parameters sent to get back the list of data to display and make them accessible to the JSP. The display tag in the JSP will regenerate the table, and use the displaytag-specific parameters (the ones beginning with d-
) to sort the data and display only the appropriate page.