• Post Reply Bookmark Topic Watch Topic
  • New Topic

Handling validations of multiple forms in single jsp

Janarthanan Chandrasekaran
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp that handles two forms. The jsp goes like this. " If the user clicks on the "manual" radio button, the "createHolidayAction" will be invoked on pressing the "save" button of that form, and if the user clicks on the "file upload' radio button , the "uploadHolidayAction" will be invoked on pressing the "upload" button on that form.

Now when the user submits the "manual" form it is checked for some validations. On failure the input jsp is retained with the error messages.

The error messages is visible on both the forms of the jsp. How to hide the error messages on another form..? Say if validation fails on "manual" form , the error message should be visible only on that form. (but when i click the "file upload" radio button, the error message of "manual" is also still visible)

the code for upload_holiday_main.jsp is here...

<script src="datetimepicker_css.js"></script>
<script type="text/javascript">
function chooseEntryMethod(hiddenbox) {
var box = document.getElementsByTagName("div");
for(var x=0; x<box.length; x++) {
name = box[x].getAttribute("name");
if (name == 'entryMethod') {
if (box[x].id == hiddenbox) {
if (box[x].style.display == 'block') {
box[x].style.display = 'none';
else {
box[x].style.display = 'block';
}else {
box[x].style.display = 'none';

<div id="template" style="padding-bottom:1%;">
<div id="tagline">
<p><bean:message key="ems.hdlabel.holidayconfig" /></p>

<input type="radio" checked="checked" name="method" value="Manual" id="manual" onclick="javascript:chooseEntryMethod('manual');"/><span style="font-family:Tahoma;font-size:13px;color:#000000;border-style:none;">Manual</span>
<input type="radio" name="method" value="File Upload" id="fileupload" onclick="javascript:chooseEntryMethod('fileupload');"/><span style="font-family:Tahoma;font-size:13px;color:#000000;border-style:none;">File Upload</span>

<div class="error">
<html:errors />
<html:errors name="dateexists" />

<html:form action="/createHolidayAction">

<div class="uploadlayout" name="entryMethod" id="manual" style="display:block;">

<label style="width:100px;">
<bean:message key="ems.hdlabel.date" />
<span id="mandatory"> <bean:message key="ems.hdlabel.mandatory" /> </span>
<html:text style="width:200px;" readonly="true" styleId="dp" property="hcDate" />
<img style="margin-right:55%;" src="images/datepicker.png" class="datepicker" onclick="javascript:NewCssCal('dp')" style="cursor:pointer;" />

<label style="width:100px;">
<bean:message key="ems.hdlabel.comments" />
<html:textarea property="comments" />

<html:submit property="saveholiday" style="width:50px;margin-left:12.5%;" styleId="formbuton" styleClass="save" value=" Save " />
<html:cancel style="width:54px;margin-left:2%;padding-left:1%;" styleId="formbuton" styleClass="cancel" value=" Cancel " />


<html:form action="/uploadHolidayAction" method="post" enctype="multipart/form-data">

<div class="uploadlayout" name="entryMethod" id="fileupload" style="display:none;">

<p style="margin-left:8%;" class="title"><bean:message key="ems.hdlabel.uploadtitle" /></p>

<label style="width:120px;">
<bean:message key="ems.hdlabel.upload" />
<span id="mandatory"> <bean:message key="ems.hdlabel.mandatory" /> </span>
<html:file property="holidayFile" styleClass="cancel"/>

<html:submit style="width:54px;margin-left:15%;" styleId="formbuton" styleClass="save" value=" Upload " />
<html:cancel style="width:54px;margin-left:2%;" styleId="formbuton" styleClass="cancel" value=" Cancel " />

<label style="width:130px;">
<bean:message key="ems.hdlabel.downloadtemplate" />
<a href="SampleCSV.csv" target="_blank"><img style="padding-left:0%;width:120px;height:35px;" src="images/d2.png" title="Click to download CSV template file" /></a>


the struts-config.xml is as below (only snippets are posted)

<action path="/createHolidayAction"
name="createHolidayForm" validate="true" input="upload_holiday.jsp"
cancellable="true" scope="request">

<forward name="success" redirect="true"
path="/listHolidays.do" />


<action path="/uploadHolidayAction" name="uploadHolidayForm"
validate="true" input="upload_holiday.jsp" cancellable="true">
<forward name="success" redirect="true" path="/listHolidays.do"/>

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!