I have a problem with setting the nested field using jQuery using Struts2 framework.
I can't set the field of ModelDriven
object myModel
if this object has field on second level.
That is:
I cannot set the field like myModel.myObject.myField
, but I can set myModel.myField
.
Can somebody help and tell how to set the nested field in the model?
To be clear:
Code below works:
<script>
function myFunction(myVal) {
$.getJSON('login/open', {
myField : myVal
}, function(data) {
if(data.ajaxResponseCode == 0){
$("#myButton").remove();
$("#myId").html("id set to=" + data.idSet + '');
};
return false;
});
};
</script>
Code below does NOT work:
<script>
function myFunction(myVal) {
$.getJSON('login/open', {
myObject.myField : myVal
}, function(data) {
if(data.ajaxResponseCode == 0){
$("#myButton").remove();
$("#myId").html("id set to=" + data.idSet + '');
};
return false;
});
};
</script>
What is interesting setting the field with JSP Struts tags works:
<s:textfield name="myObject.myField" />