Within my Action
class, there exists an object of the class that is a POJO.
public class ConfigureTspThresholdAction extends
ActionSupport implements SessionAware, ModelDriven<GmaThresholdParameter>{
private Map<String,Object> session;
private String circleId;
private String tspId;
private String thresholdTypeFlag;
GmaThresholdParameter gmaThresholdParameters = new GmaThresholdParameter();
The GmaThresholdParameter
serves as the POJO (also known as my Entity
class), containing various members with values intended to be filled by the user.
The data is retrieved from user input in textfields within my JSP:
JSP:
<s:div id="thresholdParametersDiv" cssStyle="display: none">
<table>
<tr>
<td>Minimum Number of OG Calls</td>
<td><s:textfield id="thresholdParameter_1"
name="minNumberOc"
onkeypress="return isNumber(event,'thresholdParameter_1')"></s:textfield></td>
</tr>
<tr>
<td>Minimum Duration of OG Calls (in secs)</td>
<td><s:textfield id="thresholdParameter_2"
name="minDurationOc"
onkeypress="return isNumber(event,'thresholdParameter_2')"></s:textfield></td>
</tr>
<tr>
<td>Maximum Number of IC Calls</td>
<td><s:textfield id="thresholdParameter_3"
name="maxNumberIc"
onkeypress="return isNumber(event,'thresholdParameter_3')"></s:textfield></td>
</tr>
..........and so forth for other textfields
</table>
The name
attribute in these textfields refers to the member variables of GmaThresholdParameter
, which need to be populated.
To capture and populate the values from these textfields into my
GmaThresholdParameter gmaThresholdParameters = new GmaThresholdParameter();
in my Action
class.
While primitive variables are handled through getter/setters and sent in the AJAX call using matching names in the Action
class like:
JS:
$.ajax({
type: 'POST',
traditional: true,
url: '/gma/updateThresholdParameters.action',
data:
{
circleId: circleId,
tspId: tspId,
thresholdTypeFlag: thresholdTypeFlag,
// How can I send my GmaThreshholdParameter object here to fill the object in the action class?
}
I am looking to transfer my GmaThreshholdParameter
object from JavaScript to the Action
class in order to update my object. What would be the best approach to achieve this?
Would it be feasible to gather values from textfields into an array for transmission or create a JavaScript Object
that aligns with the Java POJO object? Is there a recommended solution for this scenario?