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

ajax request processing issue

Sivakumar Subburaman
Greenhorn

Joined: Jun 10, 2011
Posts: 13
Hi,

I am using struts 2.2.3 version and pretty new to Struts. I have 2 issues with respect to handling ajax request.

Issue 1:
I defined a method in Action class and mapped that method to struts.xml mapping and gave that action class name in ajax request URL as given below.

Javascript:
requestObject = xmlHttpRequestHandler.createXmlHttpRequest();
var url = "serviceContent";
requestObject.open("Get",url,true);
Action mapping:
<action name="serviceContent" class="com.vzw.wsrr.action.ServiceCatalogAction" method="displayServiceContent">
<result name="success">services.jsp</result>
</action>

It did not process the request and got the response as "Not found". Looks like it is not able to map.

Hence I decided to implement execute() method in my action class and changed the code as given below
Javascript:
requestObject = xmlHttpRequestHandler.createXmlHttpRequest();
var url = "ServiceCatalog";
requestObject.open("Get",url,true);
Action mapping:
<action name="ServiceCatalog" class="com.vzw.wsrr.action.ServiceCatalogAction">
<result name="success">services.jsp</result>
</action>

It works good. It is getting into execute() method.

Issue 2:
I wanted to pass some additional input to the execute method. I change ajax request url to as given below.
var url = "ServiceCatalog?userAction=serviceContent&serviceName="+serviceName;

Now it does not go to execute() method and simple does nothing. There is no error. I am getting the return status as success.

If I enter that URL(http://localhost:9080/StrutsProject/ServiceCatalog?userAction=serviceContent&serviceName=testService)
directly in the browser and the control goes to execute() method, since it is normal form submit.

I am not sure why it is not taking the additional input attributes in the request. I cant set those additional attributes as hidden controls, since am not submitting the form.

Any help appreciated!

Regards,
Siva




 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ajax request processing issue
 
Similar Threads
need help in wildcard mapping
struts2---Update problem:can not get Value from jsp,it shows:nullpointException(in the action)
specifying method name in struts2
retrieve request parameters in action class Struts2 URGENT
Action[/emaillayout] does not contain specified method (check logs)