On Tue, March 14, 2006 9:32 am, Ashish Kulkarni said:
> Hi
> I have a couple of questions below
> 1 What is the best soluction to have struts and AJAX
> work together?
> I have read about DWR, Java Web parts, AjaxAnywhere,
> But which is the good one, and why?

Well, of course I'm going to say AjaxTags in Java Web Parts :)  I think it
is unique among AJAX solutions at this time because it is almost entirely
declarative.  There is (in most cases) zero client-side code to write, yet
it also offers a great deal of extensibility to make it even more
powerful.  This makes it, I think, attractive to many people, those that
don't quite have the client-side skill but have a ton of server-side
skill.  It can in essence grow with your Javascript skills.

However, I will say that I recently used DWR for a project and I totally
love it!  It's very clean, very easy (*IF* you have some Javascript
knowledge) and really, in my experience, works very well.  It also offers
some ready-made integration with popular libraries like Struts, Spring and
Hibernate.  I have no problem at all recommending DWR (I liked it so much
that I'm hoping at some point I can contribute to it).

(FYI, because of the extensibility AjaxTags in JWP offers, I'm thinking of
writing a handler to integrate with DWR, so you'll be able to use it, to a
limited degree at least, in the same declarative fashion).

Dojo also gets a lot of rave reviews, as does Scriptaculous.  I think it
all depends on what your looking to accomplish... DWR and JWP are a bit
more low-level than some of the others... for instance, they don't offer
widgets and such.  If your after some of the more high-level things like
widgets and special effects and such, Dojo and Scriptaculous are
definitely worth exploring.

> 2 What is better for response XML file or comman
> delimeted string, or build HTML in action class and
> pass it to java script to replace it.

Very much depends on what your doing.  I will say that contrary to the X
in AJAX, my experience has been that people tend to NOT use XML at all. 
XML parsing on the client is a somewhat expensive operation, so certainly
if your returning more than a small chunk of XML, you might want to
consider if XML is the best choice.  In the end though, it depends on what
your returning.

(FYI: I'm not sure this is common knowledge, but I wrote a client-side
implenentation of Commons Digester, which can be found in Java Web Parts. 
It doesn't offer the full Digester capabilities of course, but if you like
Digester for XML parsing, as I do, you may want to have a look).

> 3 Also if i have my own java script to do Ajax
> what do i return in Action class, normally in action
> class i do
> mapping.findForward("success"); after loading the
> form, this will redirect response to the required JSP.
> How does this change in AJAX, how do i reload only
> part of JSP.

You can do one of two things... first, you can render the entire response
in your Action, and then return null.  This tells Struts that teh response
is fully formed and no forward/redirect is required.

Alternatively, and again I'm not so sure this is common knowledge, you can
simply forward to a JSP like always and allow IT to render the AJAX
response.  For instance, if your rendering some XML, how easy is that to
do with JSTL and Struts tags?  Pretty easy!  No need to write a bunch of
out.println's in an Action, just use a JSP!  The client doesn't know how
the response was generated, it just takes the response as-is.

Hope that helps!

Frank

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: [EMAIL PROTECTED]
Java Web Parts -
http://javawebparts.sourceforge.net
Supplying the wheel, so you don't have to reinvent it!

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to