Reputation: 71
How can I access a hidden field (which was created in javascript) in Struts2 action class?
Example : var hidNode = document.createElement("input"); parNode.appendChild(hidNode);
hidNode.type = "hidden";
hidNode.id = "hidId";
hidNode.name = "hidName";
Now, after submitting the form, how can I access this hidden value in action class ?
Upvotes: 1
Views: 646
Reputation: 50203
The field will be injected in the Action through a Setter, matching by name.
so if you create with javascript a field like
<input type="hidden" name="hidName" id="hidId" />
, to retrieve it in the Action you must have the following:
private String hidName;
public void setHidName(String hidName){
this.hidName = hidName;
}
Upvotes: 1