aspose file tools*
The moose likes Struts and the fly likes Actionform not populating JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Actionform not populating JSP" Watch "Actionform not populating JSP" New topic
Author

Actionform not populating JSP

Syed Mahdi
Ranch Hand

Joined: Aug 27, 2004
Posts: 45
Hi All,

I have an actionform with getter setters for some fields. I set these fields into the (actionForm) form object in the action class's execute(). Then i do mapping.forward("tothesameJSP")

Whats happening is that I have some fields corresponding to the same action form but they dont get populated. I am assuming that when I set fields in an action form and do a forward through mapping.forward the form is also taken to the JSP and if the <html:text fields are there corresponding to the fields in the action form then they get populated. Am I right here?

What could i be doing wrong:

Also. is there a way to debug if the actionform coming from action back to JSP has the values that I have set in the action class?? like can i write a scriptlet or jsp tag to output the a property in the ><html:form> <sometag/> </html:form> tag

my action form is : decisionForm.java in struts its mapped in a <form-bean name=DecisionForm type=DecisionForm/>
there is an action where path=/decision name="DecisionForm" is also present, the html:from tag on jSP looks like this:
<html:form action="/decision" enctype="multipart/form-data" method="POST">


Any help will be appreciated

Thanks
Sar
Alpesh Padra
Ranch Hand

Joined: Jan 10, 2010
Posts: 41
Please verify your form scope. if it is request then make it session for testing and verify it.
Syed Mahdi
Ranch Hand

Joined: Aug 27, 2004
Posts: 45
thanks for the reply:

I did that as well.. changing the scope of the action mapping in struts-config.xml.. and then actually doing session.setAtribute("DecisionForm",decisionForm);


Actually what is happening is that the page does not get reloaded with new inputs.. i think the forward doesnt work somehow.

Here is what is happening.

I load this JSP, i select an option from dropdown and that selection reverts the request back to the DynaAction class's getDecision method which retrieves the decision object as per the selection and then populates the DecisionForm object and then does the forward to the same JSp..



what I did then is that upon the first reload i copied the code of the method that forwards to jsp with the decisionform filled into the first method which only populates the dropdown and everything works fine but when i select the dropdown choice (and i debugged the java code) it goes into the assigned method in actionclass executes properly fills the form object and then does the forward so my code in action class is like that

Syed Mahdi
Ranch Hand

Joined: Aug 27, 2004
Posts: 45
hi ,
Ok found what was wrong. It was somewhere I didnt realize it would ever be.

Anyways.. I had a javascript function called onchange of the dropdown which actually directed me to the actionclass's method

i was using jquery
$.post(url, {somevar:somevalue})

I didnot mention a callback method as in
$.post(url,{somevar:someval},myCallBackFunction)

and i should have a myCallBackFunction(){} defined as well thats why it was not loading anything

Anyways I removed the jquery thing and just used simple javascript

window.location=url to direct request to action class method
so i just did window.location='/decision.do?parameter=fetchById&somevar='+someval;

i anyone can tell me how to do the jquery thing that will be very neat as well. What i donot know is how to use the callback method to retreive the values or the form or fields in the form.

i think if i only set the form back in the document it should be enough but how to get the form from the parameters: of function myCallBackFunction(responseText, textStatus, XMLHttpRequest)
thanks in advance.
sqr
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Actionform not populating JSP