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
--
View this message in context:
http://struts.1045723.n5.nabble.com/ajax-request-processing-issue-tp4518316p4518316.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]