• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

AJAX Frameworks that integrate with Struts

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anyone summarize AJAX frameworks that are currently available?
Their pros and cons?
[ January 09, 2008: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's a pretty big order. Perhaps you could list a few that you are interested in and those familiar with them could comment? Asking someone to spend a couple of hours typing in information on all the available frameworks is rather a stretch.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is 500+ frameworks out there...

What are you looking for in a framework?

Eric
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Struts and looking for an AJAX framework that supports Struts well,
especially Struts tags (error tags,...). I can build my own, but, if someone had it done already, I would like to take a look.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're more likely to get a response from a Struts user, so I've shuffled this along to the Struts forum with a suitable change in title.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used DWR in Struts 1 applications and have found that it integrates quite well.

If you're using Struts 2, AJAX features are already integrated into the framework.
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Merrill Higginson:
I've used DWR in Struts 1 applications and have found that it integrates quite well.

If you're using Struts 2, AJAX features are already integrated into the framework.



DWR? It must be a joke.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, wrong URL. This is the right one.

http://getahead.org/dwr
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Struts1. I did not see how DWR handles Struts errors tag.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DWR is a framework for coding AJAX in an application. It doesn't automatically "handle" anything unless you write code to make it handle something.

If you'd like to post a brief description of what you're trying to accomplish, I can tell you whether DWR can do it or not, and maybe point you in the right direction as to how to do it.
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I�m building a member search web application. The search criteria are state, city and member name. Users select a state from the dropdown list, and the application uses AJAX to display a city dropdown list according to the selected state and a name field for more inputs. The user selects a city from the list, enters the member�s name, and submits the search request.

If there is no match found in the server, an error message will be displayed using Struts� <html:errors> tag, which is coded in the same JSP. The original state, city, and member names should be kept with the error message. How does DWR integrate with Struts to keep the names?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From what you've described, when a user has selected City, State and Name, they will press a submit button and perform a normal submit. AJAX will not be involved in this interaction at all. When the page is redisplayed, you can populate the City dropdown just as you normally would, because you already know what the State is.

The only part of this process for which you would use DWR is to populate the City dropdown after the user has entered a State. In this case, you would just write a plain Java Class with a getCities() method that takes a state as a parameter and then declare this method in your DWR config file. In your JSP, you would then write JavaScript code triggered by the onchange event of the State dropdown that would use DWR to call this method and populate the City Dropdown from the results received.
 
Matt Brown
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Merrill Higginson:
From what you've described, when a user has selected City, State and Name, they will press a submit button and perform a normal submit. AJAX will not be involved in this interaction at all. When the page is redisplayed, you can populate the City dropdown just as you normally would, because you already know what the State is.

The only part of this process for which you would use DWR is to populate the City dropdown after the user has entered a State. In this case, you would just write a plain Java Class with a getCities() method that takes a state as a parameter and then declare this method in your DWR config file. In your JSP, you would then write JavaScript code triggered by the onchange event of the State dropdown that would use DWR to call this method and populate the City Dropdown from the results received.



In this example, AJAX is only involved to populate the city list.

I was hopping that DWR remembers previous value of city (& city list) and name (struts remembers the the selected state) when error happens. I can do it using Javascript and struts action. It seems DWR does not very helpful in this case.
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the high-level question about Ajax frameworks that integrate with Struts 1.x....I have only played around a little with DWR, but it looks like a good option for integrating Ajax into a standard form based web application (the type of application that Struts is useful for). I have been using AjaxAnywhere not because it is great from the technical side, but because it makes it easy to add some Ajax features into an existing Struts application. I would not recommend AjaxAnywhere for a small application or a new project.

On your search page: Do your search fields (City, State and Name) show up on the same page as the results? I have seen various pages where you can enter search fields at the top of the page and the search results show up at the bottom. If this is the case then Ajax is a good fit to get rid of the full page refresh. If the search page takes the user to another page where the results are shown, then I am not sure Ajax buys you much. If you really want to show the error message without refreshing the page you will need to hook into the onclick of the submit button and call an Ajax/DWR function. It might be easier if you did not use the Struts error tag for this.

- Brent
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used both DWR and Struts1(and struts2) quite a bit.

IMO, you will be able to integrate most AJAX framework into Struts, because the AJAX framework is working on the JavaScript land, so the 'integration' have to be done manually. At least that is the case with DWR.

ALso, before you do this you need to have a clear picture of what you want to achieve with your AJAX components. Do you want to us AJAX only to retrieve data? or to do submission as well? for validation? The role of the AJAX component must be very clear.

In our case, we decided to use AJAX to do dynamic data retrieval and form validation. But normal retrieval and submission, we still us Struts2.

If you happen to use the same strategy, then the following might help. This is how we partition the components inside the webapp to implement that strategy. This example is for 'login' action.

----------

(1) the form
loginForm.jsp (uname,pwd) -#submit-> /Login.action

(2) the action mapping
/Login.Action = some.package.LoginController

(3) the controller
LoginController.execute()
{
1. parse uname & pwd for processing
2. invoke LoginManager.authenticate(uname, pwd)
}

(4) app logic
LoginManager = a simple POJO class where the application logic is implemented.

-----

Note that it is important to separate (3) and (4) because (4) have to be a simple POJO so that the app logic is reusable by both DWR and Struts.

Now in our AJAX 'channel', we have:

-----

(1) the form
loginForm.jsp -#uses-> /interface/LoginAJAXController.js
(and can invoke method inside that interface)

(2) interface mapping
/interface/LoginAJAXController.js = some.other.package.LoginAjaxController

(3) LoginAJAXController
{
1. implements method that the page requires
2. uses LoginManager to do stuff
}

Here, it is up to you whether you want to implement the authentication login in LoginAjaxController, or in LoginController (struts). In our case, we decided that data submission is STruts' job, so we implemented it in LoginController.

What we implement in LoginAJAXCOntroller instead, is a method to get last 10 login so that the login page can display who are the last 10 user that have logged in to the application (dynamically, updated within a set time interval) without refreshing the page.

In conclusion, in our web app structure we make 2 'channel' of MVC, one using DWR and one using Struts, both channel eventually using the POJO 'managers'. We felt that the Struts channel is very suited for data submission, and DWR is very suited for data retrieval.
[ January 18, 2008: Message edited by: Zenikko Sugiarto ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've used Prototype quite successfully with Struts 1.

What you are trying to do is write code to handle a chained selector. I've written a generic javascript function called "chainSelect" to handle my chained selectors successfully. I've posted a slightly older version of the code in the HTML/Javascript forum. Basically, it accepts the id of the "originating" select box, the "destination" select box, and a Struts action that returns a JSON array/object to populate the destination box.

In my struts action, I do whatever I need to do to get the information to populate the destination select box, then convert it to JSON using JSON-lib (http:json-lib.sourceforge.net). Then I get set the response content type to "application/json", then use the response's default writer to output the JSON to the output stream. The javascript processes the info and fills in the select box.

The only caveat: make sure that you have excluded the output of this action from being decorated if you use Sitemesh like I do...

This should work with most AJAX frameworks, but my chainSelect function is pretty Prototype-specific.

Jason
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently using Struts 1.2x and DWR 2.0.3. I am looking for a sample code that shows Struts 1 and DWR integration. Is there any demo sample for such integration.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In my struts action, I do whatever I need to do to get the information to populate the destination select box, then convert it to JSON using JSON-lib (http:json-lib.sourceforge.net). Then I get set the response content type to "application/json", then use the response's default writer to output the JSON to the output stream. The javascript processes the info and fills in the select box.



I am trying to use dwr and struts 1 to add some Ajax to my current application. In my case, I have problem displaying the results from the sever function calls on my jsp page. So, can you give me more details or sample code regarding converting like an ArrayList of objects returned from a server getBeanDAO function to some htmls so I can display them on my jsp page like a table or options with some css? Your help will be greatly appreciated.

Teresa
 
Deha Peker
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am running DWR 2.0.1 with Struts 1.2.7 on WebLogic 8.1 SP6
I am getting the following exception during the JSP page loading.

It seems like it is trying to load configuration using org.directwebremoting.impl.ContainerUtil.configureFromAnnotations
even though it is not running in Java5 environment? My initialization is using regular dwr.xml under WEB-INF. Can any body any have suggestions?

####<Feb 26, 2008 7:18:33 PM EST> <Error> <HTTP> <CGMCRDW161> <limitsServer> <ExecuteThread: '14' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-101017> <[ServletContext(id=7130942,name=limitweb,context-path=/limitweb)] Root cause of ServletException.
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at org.directwebremoting.impl.ContainerUtil.configureFromAnnotations(ContainerUtil.java:332)
at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:428)
at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)
at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1099)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:975)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:954)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:893)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:598)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:406)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
Caused by: java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:333)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:233)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.directwebremoting.util.CommonsLoggingOutput.<init>(CommonsLoggingOutput.java:35)
at org.directwebremoting.util.Logger.<init>(Logger.java:62)
at org.directwebremoting.util.Logger.getLogger(Logger.java:33)
at org.directwebremoting.annotations.AnnotationsConfigurator.<clinit>(AnnotationsConfigurator.java:335)
... 25 more
>
####<Feb 26, 2008 7:18:33 PM EST> <Info> <HTTP> <CGMCRDW161> <limitsServer> <ExecuteThread: '14' for queue: 'weblogic.kernel.Default'> <<anonymous>> <> <BEA-101047> <[ServletContext(id=7130942,name=limitweb,context-path=/limitweb)] dwr-invoker: init>
####<Feb 26, 2008 7:18:33 PM EST> <Error> <HTTP> <CGMCRDW161> <limitsServer> <ExecuteThread: '14' for queue: 'weblogic.kernel.Default'> <<WLS Kernel>> <> <BEA-101017> <[ServletContext(id=7130942,name=limitweb,context-path=/limitweb)] Root cause of ServletException.
java.lang.NoClassDefFoundError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at org.directwebremoting.impl.ContainerUtil.configureFromAnnotations(ContainerUtil.java:332)
at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:428)
at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)
at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1099)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:975)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:954)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:893)
at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:598)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:406)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:348)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7047)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)
>
 
Deha Peker
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I also see this exception in dwr log files

022608--20:20:25,396 --DEBUG -- CommonsLoggingOutput -- Configuring from servlet resource: /WEB-INF/dwr.xml
022608--20:20:25,412 --DEBUG -- CommonsLoggingOutput -- - adding creator: NewCreator for LimitsUsrProRemote
022608--20:20:25,427 --FATAL -- CommonsLoggingOutput -- Rethrowing Error:java.lang.ExceptionInInitializerError
022608--20:20:25,427 --FATAL -- CommonsLoggingOutput -- ExceptionInInitializerError. Nested exception:
java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:333)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:233)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.directwebremoting.util.CommonsLoggingOutput.<init>(CommonsLoggingOutput.java:35)
at org.directwebremoting.util.Logger.<init>(Logger.java:62)
at org.directwebremoting.util.Logger.getLogger(Logger.java:33)
at org.directwebremoting.annotations.AnnotationsConfigurator.<clinit>(AnnotationsConfigurator.java:335)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at org.directwebremoting.impl.ContainerUtil.configureFromAnnotations(ContainerUtil.java:332)
at org.directwebremoting.impl.ContainerUtil.configureContainerFully(ContainerUtil.java:428)
at org.directwebremoting.servlet.DwrServlet.init(DwrServlet.java:79)
at weblogic.servlet.internal.ServletStubImpl$ServletInitAction.run(ServletStubImpl.java:1099)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.ServletStubImpl.createServlet(ServletStubImpl.java:975)
at weblogic.servlet.internal.ServletStubImpl.createInstances(ServletStubImpl.java:954)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:893)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:3456)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3413)
at weblogic.servlet.internal.WebAppServletContext.preloadServlets(WebAppServletContext.java:3399)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:3382)
at weblogic.servlet.internal.WebAppServletContext.setStarted(WebAppServletContext.java:6262)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:892)
at weblogic.j2ee.J2EEApplicationContainer.start(J2EEApplicationContainer.java:2181)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2222)
at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:2169)
at weblogic.management.deploy.slave.SlaveDeployer$Application.setActivation(SlaveDeployer.java:3111)
at weblogic.management.deploy.slave.SlaveDeployer.setActivationStateForAllApplications(SlaveDeployer.java:1769)
at weblogic.management.deploy.slave.SlaveDeployer.resume(SlaveDeployer.java:352)
at weblogic.management.deploy.DeploymentManagerServerLifeCycleImpl.resume(DeploymentManagerServerLifeCycleImpl.java:229)
at weblogic.t3.srvr.SubsystemManager.resume(SubsystemManager.java:136)
at weblogic.t3.srvr.T3Srvr.resume(T3Srvr.java:965)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:360)
at weblogic.Server.main(Server.java:32)
022608--20:48:04,902 --INFO -- CommonsLoggingOutput -- DWR Version 2.0.1 starti
 
Every snowflake is perfect and unique. And every snowflake contains a very tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic