0

How to pass values set inside hidden field in <s:form> by JavaScript function to action class on click of <s:submit> button of this <s:form>?

Roman C
  • 49,761
  • 33
  • 66
  • 176
PRINCE GUPTA
  • 43
  • 1
  • 7
  • Just put a setter for each parameter (hidden or not) in the action. – Andrea Ligios Oct 21 '15 at 08:02
  • By having an action property for it, just like a non-hidden field. The type of the property depends on what you are sending back, if it's not a collection it obviously shouldn't be in CSV format. – Dave Newton Oct 21 '15 at 13:25

1 Answers1

0

The values should be in the CSV format like in this answer.

That will also give you an idea about type of property which you should bind to the hidden field. For example you can use List<Integer> or Integer[] for the property that set the values 25, 27, 28.

Struts2 has a built-in converter that converts such values to the list or array automatically.

Also note the instance variable in the action class can't be used by OGNL (by default) if it is not accessible by security manager or has not public accessors like getters and setters. In Struts2 submitted values are populated to the instance variable by the params interceptor which is indeed invokes OGNL to do the job.

Roman C
  • 49,761
  • 33
  • 66
  • 176