0

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?

DoubleDotM
  • 61
  • 4
  • Just see an action/field errors. – Aleksandr M Dec 10 '14 at 18:07
  • You are setting a wrong value that cannot be converted to integer. – Roman C Dec 10 '14 at 18:35
  • Also reading [this](http://stackoverflow.com/a/23450365/1654265) might help understanding the whole thing – Andrea Ligios Dec 10 '14 at 23:06
  • Server returns input, so we'll need to see the action to be sure. – Quaternion Dec 11 '14 at 00:54
  • @AndreaLigios - Thanks for the link. I have defaultStack in my struts.xml. The problem is with knowing why a "Yes" value would pass to SUCCESS while a "No" value would give INPUT. The variables are the same only, in both cases. Another doubt is, incase of a 100 variables, do we actually go about checking which variable is giving the INPUT result manually or is there another way of achieveing it? – DoubleDotM Dec 11 '14 at 17:48

0 Answers0