667481 members! Sign up to stay informed.

Sponsored Links


Resources

Enterprise Java
Research Library

Get Java white papers, product information, case studies and webcasts

News News News Messages: 13 Messages: 13 Messages: 13 Printer friendly Printer friendly Printer friendly Post reply Post reply Post reply XML XML XML

Java.net Article on Using Ajax with Struts

Posted by: paul browne on October 30, 2005 DIGG
Struts has been one of the major Java Frameworks for building Web applications for a number of years. Ajax is the latest buzz on building dynamic, user friendly web interfaces. How can Java Developers add the power of Ajax to these existing Struts Applications without having to tear out the existing code?

Sprinkle Some AJAX Magic in Your Struts Web Application, hosted on java.net, shows how.

How many ServerSide readers are actually developing using Ajax? Do they feel that it is living up to the hype? Are readers inclined to extend their existing (Struts based) apps, or go for a complete rebuild using something like DWR (Direct Web Remoting), Dojo, or other such frameworks?

Threaded replies

·  Java.net Article on Using Ajax with Struts by paul browne on Sun Oct 30 09:06:41 EST 2005
  ·  Java.net Article on Using Ajax with Struts by Vitaly Shevchuc on Mon Oct 31 07:45:36 EST 2005
    ·  Java.net Article on Using Ajax with Struts by Marina Prikaschikova on Mon Oct 31 09:32:09 EST 2005
    ·  Java.net Article on Using Ajax with Struts by paul browne on Tue Nov 01 04:21:10 EST 2005
  ·  Another option for the article by Elan H on Mon Oct 31 13:26:08 EST 2005
    ·  Another option for the article by paul browne on Tue Nov 01 04:23:27 EST 2005
    ·  AJAX returnnig HTML snippets by Brian Sayatovic on Thu Nov 03 07:35:31 EST 2005
      ·  Ajax In Portlets by vikramark singh on Fri Nov 04 10:22:09 EST 2005
  ·  Silly question by M L on Mon Oct 31 17:54:19 EST 2005
    ·  Silly question by paul browne on Tue Nov 01 04:17:18 EST 2005
      ·  Silly question by Marina Prikaschikova on Tue Nov 01 08:46:15 EST 2005
        ·  Silly question by paul browne on Tue Nov 01 15:48:31 EST 2005
  ·  The AJAX hypo is far reached by P s on Mon Nov 14 04:16:10 EST 2005
  ·  DWR and Struts? by Eric Ma on Sat Dec 31 10:51:09 EST 2005
  Message #189653 Post reply Post reply Post reply Go to top Go to top Go to top

Java.net Article on Using Ajax with Struts

Posted by: Vitaly Shevchuc on October 31, 2005 in response to Message #189602
The idea is good, but not too fresh ;)

AjaxAnywhere, AjaxTags and probably other open source projects already do the same thing without JavaScript coding.

http://ajaxanywhere.sourceforge.net/
http://ajaxtags.sourceforge.net/usage.html#ajax:htmlContent

Al least these two links should be present in your article to liberate your readers from unnecessary JavaScript coding.

  Message #189670 Post reply Post reply Post reply Go to top Go to top Go to top

Java.net Article on Using Ajax with Struts

Posted by: Marina Prikaschikova on October 31, 2005 in response to Message #189653
Check out this also from Coldtags suite:

http://www.servletsuite.com/servlets/ajaxdivtag.htm
http://www.servletsuite.com/jsp.htm#ajax

  Message #189717 Post reply Post reply Post reply Go to top Go to top Go to top

Another option for the article

Posted by: Elan H on October 31, 2005 in response to Message #189602
I just started playing around with AJAX to do something similar to the example in the article. The solution I choose was not mentioned in the article and it was to have the AJAX call return the HTML for the table. That way I don't need to have any messy Javacript code to parse the response. And I reuse the same JSP logic that created the table initially. For my needs at least this approach appears to work well and I don't have the need for the other frameworks as of yet.

btw, I was designing a treeview widget where a tree folder could be lazy-loaded.

  Message #189752 Post reply Post reply Post reply Go to top Go to top Go to top

Silly question

Posted by: M L on October 31, 2005 in response to Message #189602
In the tutorial, After posting to the struts action, the struts action forwards to index.jsp [ view ]

I was under the impression, the action should refresh only a part of the page using Ajax. In this the view itself is bit different.

  Message #189796 Post reply Post reply Post reply Go to top Go to top Go to top

Silly question

Posted by: paul browne on November 01, 2005 in response to Message #189752
It's a good question.

To keep things simple , the action forwards to the same Index.jsp to display the page. The Page , using logic tags , decides which sections needs displayed.

It would be possible to forward to a different page as long as the <Span> tags are the same on both pages. The article mentions this (near the end), but does not go into detail.

FirstPartners.Net

  Message #189797 Post reply Post reply Post reply Go to top Go to top Go to top

Java.net Article on Using Ajax with Struts

Posted by: paul browne on November 01, 2005 in response to Message #189653
Thanks for suggesting AjaxAnywhere.

In my opinion, one of the many Ajax Libraries that have sprung up will win out and become a de-facto standard, similar to what Struts was for the previous generation of Web Applications.

The focus of the article was adding Ajax to existing applications , without having to add or replace libraries. Where you have choice of moving to new libraries, the projects like AjaxAnywyere and AjaxTags are worth taking a look at - several others , including DWR are mentioned in the article.


Paul
FirstPartners.Net

  Message #189798 Post reply Post reply Post reply Go to top Go to top Go to top

Another option for the article

Posted by: paul browne on November 01, 2005 in response to Message #189717
Looked at doing it that way - the difference between the two approaches is that the article can use an asynchronous call, so is more robust where there the network is not guaranteed (ie most internet and many intranets).


Paul
FirstPartners.Net

  Message #189822 Post reply Post reply Post reply Go to top Go to top Go to top

Silly question

Posted by: Marina Prikaschikova on November 01, 2005 in response to Message #189796
What is a POST back pattern right from ASP.NET
Do we really need a Struts?

Marina
http://www.servletsuite.com

  Message #189877 Post reply Post reply Post reply Go to top Go to top Go to top

Silly question

Posted by: paul browne on November 01, 2005 in response to Message #189822
Many people have been asking the question 'do we need Struts' for quite a long time , even though it has served the Java Community Well :-)

Struts is a Java - Web implementation of the Model-View-Controller pattern. I wouldn't be surprised if it was close to an ASP.Net pattern, given the amount of cross-pollination between the two.

Paul
FirstPartners.net

  Message #190060 Post reply Post reply Post reply Go to top Go to top Go to top

AJAX returnnig HTML snippets

Posted by: Brian Sayatovic on November 03, 2005 in response to Message #189717
I did a prototype like this. The AJAX call his the same Struts actions forwarding to JSPs and JSP fragments, returning the generated HTML to the XmlHttpRequest object. The client then just had to do element.innerHTML = req.responseText;

This had the advantage that I didn't have to write rendering code once in JSP and dynamic rendering code of the same markup in JavaScript. I just write it once and use it both ways.

However, we're now using a portal, and calling a portlet is different from calling an AJAX servlet, so reusing the same code just won't work without a lot of kludging.

  Message #190232 Post reply Post reply Post reply Go to top Go to top Go to top

Ajax In Portlets

Posted by: vikramark singh on November 04, 2005 in response to Message #190060
One can also go through the following article:

http://portlets-jsr168.blogspot.com/2005/11/ajax-in-portlets.html

Regards,
Vikramark.
http://portlets-jsr168.blogspot.com/

  Message #191015 Post reply Post reply Post reply Go to top Go to top Go to top

The AJAX hypo is far reached

Posted by: P s on November 14, 2005 in response to Message #189602
Please read

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IETechCol/dnwebgen/ie_leak_patterns.asp

http://codeproject.com/useritems/LeakPatterns.asp

One has really to think about using JavaScript for non-trivial stuff.

  Message #195687 Post reply Post reply Post reply Go to top Go to top Go to top

DWR and Struts?

Posted by: Eric Ma on December 31, 2005 in response to Message #189602
Has anyone used DWR to call Struts Action classes (or a thin wrapper on top of it)? We have a lot of existing Struts code and we would like to leverage it.

New content on TheServerSide.comNew content on TheServerSide.comNew content on TheServerSide.com

Dependency Injection in Java EE 6 - Part 1

Reza Rahman explores the features of the proposed JSR 299, Contexts and Dependency Injection for Java EE (CDI). When approved, it promises to be a key feature of Java EE 6. (November 2, Article)

SAML: It's Not just for Web services

SAML is an XML-based standard for exchanging authentication and authorization data between security domains. The single most important problem that SAML was created to solve is the Web browser Single Sign-On problem. Many organizations are debating whether to stay with version 1.1 or move to 2.0. This article makes observations about both options. (September 28, Article)

Programming is Also Teaching Your Team

Joe Ottinger takes a look at how people learn, and applies it to the practice of programming. He notes that understanding how people learn is an essential part of working in a programming team. (September 22, Article)

Can Java EE Deliver The Asynchronous Web?

Stephen Maryka gave us an article about the Asynchronous Web and posed a number of questions that get examined like an approach to delivering Asynchronous Web capabilities through extensions to existing Java EE technologies. (July 14, Article)

JSF Flex

JavaServer Faces Flex goal is to provide users capability in creating standard Flex components, part of flexSDK which is open sourced through MPL license, as normal JSF components. This article by Ji Hoon Kim will provide an overview of creating a simple multilingual JSF page consisting of JSF Flex tags. (June 29, Article)

The Rules of SOA - A Road to a Successful SOA Implementation

In this session Jeff explores the key characteristics of successful SOA projects. He covers some of the patterns, and anti-patterns, tool sets, and strategies that he himself learned the hard way. Last, he provides a strategy and blueprint for achieving a high likelihood of success in your SOA project. (June 23, Tech Talk)

Ari Zilka Talks About Terracotta 3.1

Ari Zilka, CTO of Terracotta, Inc., talks about the new features in Terracotta 3.1, announced during JavaOne and available now. (June 15, Tech Talk)

Enterprise Application Integration, and Spring

In this Tech Talk, Josh Long explores an integration challenge using Spring Integration and walks through the implementation, employing and expanding on the basic patterns of Enterprise Application Integration to tie together components into a function integration solution, and then demonstrates how Spring Integration helps address the integration requirements. (June 15, Tech Talk)

Google Web Toolkit: An Introduction

In this Tech Talk, David Geary teaches you: The basics of Google Web Toolkit; How to implement Ajax-enabled applications in Java; Internationalization; Hooking into the browser history mechanism; Remote procedure calls. (June 4, Tech Talk)

Just Enough Early Architecture to Guide Development

Jon Kern discusses the best architecture/technical solutions and ensure that they are repeated by all developers. By tackling the architecture up-front in a serial manner, subsequent parallel development will be much more manageable and predictable. (May 28, Tech Talk)

Productive Programmer: On the Lam from the Furniture Police

This keynote describes the frustrations of modern knowledge workers in their quest to actually get some work done, and solutions for how to guard yourself against all those distractions. Neal Ford talks about environments, coding, acceleration, automation, and avoiding repetition as ways to defeat the misguided attempts to sap your ability to produce good work. (May 26, Tech Talk)

Auto-Scaling Your Existing Web Application

Gil demonstrates how new, aggressive uses of already abundant compute capacity by common applications offer competitive value for application designers. (May 21, Tech Talk)

Automating Hibernate Mapping and Queries For Java Web Development

Chris Keene introduces WaveMaker as a new way to automate the ability to generate Hibernate classes in order to more quickly bring OR mapping into an application. (May 19, Article)

Auto-Scaling Your Existing Web Application

In this session Nati Shalom demonstrates how to take a standard Java EE web application and scale it out or down dynamically without changes to the application code. Seeing as most web applications are over-provisioned to meet infrequent peak loads, this is a dramatic change because it enables growing your application as needed, when needed, without paying for unutilized resources. (May 19, Tech Talk)

Free Book PDF Download: Mastering EJB Third Edition

Mastering EJB was one of the original and most influential EJB books in the industry. Mastering EJB III now returns with two new expert co-authors, updated for EJB 2.1 and 30% new chapters including security, integration, best practices, open source, and more.
(Book PDF Download)

Application Server Matrix

The Application Server Matrix is a detailed listing of J2EE vendors and their application server products, with information on latest version numbers, J2EE spec support and licensing, pricing, platform support, and links to product downloads and reviews.
(Application Server Comparison Matrix)

News | Blogs | Discussions | Tech talks | Patterns | Reviews | White Papers | Downloads | Articles | Media kit | About
Java Solutions
All Content Copyright ©2007 TheServerSide Privacy Policy
Site Map