Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to update the object property on the server side by updating value in javascript before submit

 
jack fe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys:
I have a question. When the form submitted, the value of 'clientPageNumber' of 'pageInfo' of 'form' is still 0 instead of 5
during processing the action class on the server side.
How can I update the value of that?

Thanks.
The source is in the following:
jsp
<bean:define id="formPageInfo" name="TestForm" property="pageInfo"/>
<!-- pageInfo is a property object of form -->
<input type="hidden" id="tablePageNumber" name="tablePageNumber" value="<bean:write name="formPageInfo" property="clientPageNumber"/>"/>
<!-- clientPageNumber is a int property of pageInfo object -->

javascript
function submitFormFunction(){
document.getElementById("tablePageNumber").value= 5 + '';
document.myform.action = "/<%=StartupConstants.APPLICATION_WAR_VALUE%>/TestUpdateFormAction.do";
document.myform.submit();
}
 
Travis Hein
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here the the pageInfo bean is defined as a session (or request?) attribute, where the HTML form is submitting a tablePageNumber property, which will become a request parameter.

I'm not sure of any way using the javascript form submit thing there to automatically have the value loaded into the session object form bean. - this is what those struts taglibs do for us under the hood, but here we aren't using them.

What you can try to do in your action handler, is try to stuff the request paramter we are getting into the tablePageNumber property of the bean.

 
a kishore
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi jack fe


document.getElementById("tablePageNumber").value= 5 + '';



What you are trying to do with '5+', are you setting a value with increment ?


regards,
kishore
 
jack fe
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name of the input field is going to need to match the name of the property in your form. So the name of the input field should be pageInfo.clientPageNumber.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic