So, I have an issue where when I submit a form, instead of the corresponding ActionForm being populated with the correct field data, it remains unpopulated for a reason unknown to me. Here is the form on my JSP page(js functions provided for clarity, very simple):
<script> function encryptSSN(){ document.ssnLookupForm.submit(); } function showError(){ document.getElementById('error').style.display='block'; document.getElementById('box1').style.display='none'; } function validateSSN(){ var ssn = document.ssnLookupForm.ssn.value; if( /^\d{3}-\d{2}-\d{4}$/.test(ssn) == false ){ showError(); }else{ encryptSSN(); } } </script> <html:form method="post" action="/SSNLookupEncrypt"> <div style="text-align: center; font-family: arial;"> <div class="productsdiv" style="margin: 0 auto; padding: 5px; text-align: left; width: 43%"> <div> SSN: <input type="text" name="ssn" value="<%=ssnLookupForm.getSSN()%>"/> <div class="spacer"> </div> Format: XXX-XX-XXXX </div> <div class="spacer"> </div> <div style="text-align: center;"> <input type="button" value="Encrypt" onclick="validateSSN()"/> </div> <div class="textBox" id="box1" style="text-align: center; display:block"> <div class="spacer"> </div> Encrypted Value: <%=ssnLookupForm.getEncryptedSSN()%> </div> </div> <div class="spacer"> </div> </div> </html:form> ------------------------------------------------------ This is the corresponding ActionForm: public class SSNLookupForm extends ActionForm{ private static Logger log = Logger.getLogger(SSNLookupForm.class.getName()); private String ssn = "XXX-XX-XXXX"; private String encryptedSSN = "[Encrypted Value]"; public String getSSN(){ return ssn; } public void setSSN(String ssn){ this.ssn = ssn; } public String getEncryptedSSN(){ return encryptedSSN; } public void setEncryptedSSN(String encryptedSSN){ this.encryptedSSN = encryptedSSN; } public void reset(ActionMapping mapping, HttpServletRequest request) { this.ssn = "XXX-XX-XXXX"; this.encryptedSSN= "[Encrypted Value]"; } } ------------------------------------------------------------------------------- What should happen is that the user enters the SSN in xxx-xx-xxxx format into the box, and clicks the Encrypt button(the javascript validation works fine, I've tested it). Then, the form should get populated with the data so that the Action class can do the background work, and display the page with the SSN that was input and the value that was created from the encryption. I can't figure out why the data isn't being submitted. I tried using the Struts library tags like <html:text> and <html:button> and whatnot, but for some reason the elements wouldn't display on the page when I would use them, so I just reverted to the regular HTML counterparts. The problem is with the form being populated with the data, because I hard coded in a value for the SSN in my action class and the encryption happened perfectly fine and the page showed up as it should have, but I can't get user input data to make it to the form, and I'm totally at a loss. Any help would be greatly appreciated. Keep in mind this is the first time I've ever had to use anything like Struts. -- View this message in context: http://old.nabble.com/Losing-ActionForm-Data-on-submit-tp26627694p26627694.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org