GeeCON Prague 2014*
The moose likes Other Application Frameworks and the fly likes AJAX with WebWork or Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "AJAX with WebWork or Struts" Watch "AJAX with WebWork or Struts" New topic
Author

AJAX with WebWork or Struts

vikas prasad
Ranch Hand

Joined: Nov 06, 2005
Posts: 44
i want to use AJAX in my web application. at present i am using free marker, webwork,spring and hibernate together. i found various example of using AJAX with other technologies. what i wan to know is that what changes should i make in my xwork.xml so that i can handle ajax request. i also want to know how should i send response from my Action to AJAX request.
i know how to use AJAX with simple servlet doget, dopost methods. but if any body can help me or show me simple example to use it with web work than it will be great.
thanks in advance.
Vikas


Vikas Prasad<br />SCJP 1.4 SCWCD1.4 SCBCD1.3
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

what i wan to know is that what changes should i make in my xwork.xml so that i can handle ajax request

You don't have to do anything special at all, just define your action as usual.
i know how to use AJAX with simple servlet doget, dopost methods. but if any body can help me or show me simple example to use it with web work than it will be great.

With WebWork, there is no difference at all.
All what you can do with raw Servlets you can do with WebWork action.

vikas prasad
Ranch Hand

Joined: Nov 06, 2005
Posts: 44
but the problem is after the action runs, and it maps to :
<action name="admission" class="frontPageAction" method="aboutUs">
<result name="success" type="freemarker">
<param name="location">/template/home/content/Admission.ftl</param>
</result>
</action>

parameter as defined in my result. it reloads the page. i think do i need to use simple servlet dopost methods or doget methods where i dont return any thing. then it will work.
because when we return Success in my execute method it maps to the param that i have defined. i my Xwork.
so is there any other way i can do this
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

i think do i need to use simple servlet dopost methods or doget methods where i dont return any thing.

If you don't return any thing, why you are using Ajax?
The most basic use of Ajax is to update parts of the page.
parameter as defined in my result. it reloads the page.

What is the type of your result, forward or redirect?
I think you have to set it forward (if it not already is).
 
GeeCON Prague 2014
 
subject: AJAX with WebWork or Struts