• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling validations of multiple forms in single jsp

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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';
}
}
}
}</script>
</head>



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


<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" />
</div>

<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>
</label>
<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" />
</label>
<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 " />

</div>
</html:form>

<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>
</label>
<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" />
</label>
<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>

</div>
</html:form>


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

<action path="/createHolidayAction"
type="com.stg.ems.actions.EMSCreateHolidayAction"
name="createHolidayForm" validate="true" input="upload_holiday.jsp"
cancellable="true" scope="request">

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

</action>

<action path="/uploadHolidayAction" name="uploadHolidayForm"
type="com.stg.ems.actions.EMSUploadHolidayAction"
validate="true" input="upload_holiday.jsp" cancellable="true">
<forward name="success" redirect="true" path="/listHolidays.do"/>
</action>





 
reply
    Bookmark Topic Watch Topic
  • New Topic