I have a piece of code with about 100 variables in my Action Class. They are not directly accessible in the JSP Page i.e. the name attribute of the JSP page is different from the variable name in the Java Action Class. The values in the JSP page are set according to changes in Javascript.
For eg :
<!-- HTML -->
<!--js is called on page load-->
<s:hidden name="optionJava"></s:hidden>
<s:select id="optionValues" name="values">
<option>SelectedA</option>
<option>SelectedB</option>
</s:select>
//Struts2 - Action class
private int optionJava;
//Javascript
if(document.getElementById('optionJava').value==1){
if(document.getElementById('optionValues').selectedIndex==1){
document.getElementById('values').value==10;
//Based on the 10 that is now the selected option's value , another field is triggered.
}
}
Based on such a structure, the optionJava values keep changing to display either another field if 1 is selected or display nothing if 2 is selected.
Now, because of this 1 and 2, the values that I am getting with 1 (which can be considered as 'Yes') work perfectly in the application i.e. the Page returns SUCCESS. However if i select 2 (which can be considered as 'No' for a particular field), the other field is not triggered and the page returns INPUT.
With over a 100 variables in my page, I am not sure which variable(s) are causing this issue.
What is the practice to be followed while checking for INPUT - Validation and presence of variable in the Java class is a must I know, but I don't understand why the same code works when 1 is selected and goes to INPUT when 2 is selected?