File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

ajax request processing issue

Sivakumar Subburaman

Joined: Jun 10, 2011
Posts: 13

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.

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

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
requestObject = xmlHttpRequestHandler.createXmlHttpRequest();
var url = "ServiceCatalog";"Get",url,true);
Action mapping:
<action name="ServiceCatalog" class="com.vzw.wsrr.action.ServiceCatalogAction">
<result name="success">services.jsp</result>

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!


I agree. Here's the link:
subject: ajax request processing issue
It's not a secret anymore!