So when user hits 'Save Draft Form' in our page we do below things in our Beehieve Controller
//Set the save form attribute to hide the buttons that are not allowed on saved forms, and show the "upload" button
HttpServletRequest req = this.getRequest();
req.setAttribute("SAVE","TRUE");
getResponse().setHeader("Content-Disposition","attachment;filename=OneDraft.htm");
In Our Jsp We Have This Condition To Allow "Upload" Button To Display Only For Locally Saved Html Files
<% boolean localFile;
String save = (String) request.getAttribute("SAVE");
if (save == null || !save.equalsIgnoreCase("TRUE")) {
localFile = false;
} else {
localFile = true;
}
%>
<% if(!localFile) {%>
<netui:button action="saveForm" value="Save Draft Copy" type="submit" alt="Save draft copy" />
<% } else {%>
<netui:button type="submit" value="Upload Form" action="UploadForm" />
<%}
%>
So as we can see javascript code will get executed when user tries to hit "Save draft copy" button and as "SAVE" attribute is already stored in request scope in our Beehieve Controller so "upload" button will get executed.
And once the user hits "upload" button "UploadForm" action gets called in our Beehieve Controller and we load the jsp with the existing form which has few details saved previously.
Hope this explanation helps.
No comments:
Post a Comment