wood burning stoves 2.0*
The moose likes Struts and the fly likes ~ doubt of apply ajax into struts ~ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "~ doubt of apply ajax into struts ~" Watch "~ doubt of apply ajax into struts ~" New topic
Author

~ doubt of apply ajax into struts ~

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
hi good day to all, i recently play around ajax and found it is wonderful as it update small portion of page without refresh.

i using jsp to call servlet in my case , now, i would apply this technology into struts, there have 3 questions on my mind, i hope can get some guidance from expert here

1. should we send request to action or servlet ?
- if we send request to action, as we know, we need to define it in struts-config.xml, would it be better if we just using servlet in this case, at least , i can see calling servlet will be more direct?
- also, how we solve problem as action need return actionForward , is it using return null in this case ?

2. i need to apply ajax auto-completion technique, my question is, is that any client GUI kit to help up in this case? please name easy and good GUI client framework

3. i using prototype for ajax marshalling, and not using framework like DWR as i see myself need to learn all foundation of ajax , thus, i not tie to any framework at the moment, am i in right track ?

once again, thank you for your guidance in advance
RoshaniG Gopal
Ranch Hand

Joined: May 15, 2006
Posts: 180
Hi Nakata,

Please find answers to your questions here.

1. If you are using the Struts framework, request should be given to the Action class. The Action class is also called directly by Struts. Action Form is called internally by the framework.
You are right that Action Class needs forward object, but for this case you use the "PrintWriter-out" object and handle the response yourself. Thus you need to set setContentType("") and then use it. Then the actionForward object is null because you tell the class that you are handling the reponse yourself and framework need not worry.

2. There are some toolkits available for ajax dev. Google Web Toolkit is one example. You may do a google search for the same with 'Ajax toolkit', you will have many links.

3. Ajax is not a new. Its Javascript with XML. So its not tied to any framework or language as Java/ .Net. It may be used with both without any code change.

Regards,
Roshani


Regards,<br />Roshani
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 438
thanks RoshaniG Gopal for guidance ,

for

Q1 : is it better if we use servlet rather than action?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Roshani's excellent answer to question 1 is about what I would answer as well, so I'll just comment on questions 2 and 3.

Originally posted by Nakata kokuyo:

2. i need to apply ajax auto-completion technique, my question is, is that any client GUI kit to help up in this case? please name easy and good GUI client framework


I would definitely suggest using an existing JavaScript toolkit for this. For example, an auto-complete control is fairly complicated to code, especially if you want things like the ability to use the up and down arrow keys to navigate through the list of suggestions, etc. I'm a firm believer in not reinventing the wheel, so I think it's a good idea to take advantage of good code that's already been written to create these types of controls. dojo and scriptacuolous are both good javascript toolkits that have lots of these controls.

Originally posted by Nakata kokuyo:
3. i using prototype for ajax marshalling, and not using framework like DWR as i see myself need to learn all foundation of ajax , thus, i not tie to any framework at the moment, am i in right track ?

I agree it's a good idea to get a good understanding of how AJAX works, and it's definitely a good idea to write a few sample projects where you code the entire process just to get a feel for it. Once you start writing production code, however, why reinvent the wheel?

DWR provides a good framework that handles the marshalling and unmarshalling of the XML, and allows one to concentrate on the application logic, rather than the AJAX details. I've been using it for some time, and find that it's much more efficient than taking the time to code all the low level AJAX logic myself.
[ October 28, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
 
 
subject: ~ doubt of apply ajax into struts ~
 
Similar Threads
Any disadvantages of the struts framework.
link css style sheet
Good and easy use Ajax client GUI framework ?
shine J2EE service oriented framework
A couple of doubts in struts