I need to integrate AJAX functionality into a Struts 2 web application. I was looking at some tutorials and was going to try using the Dojo Plugin but quickly realized it has been deprecated as of Struts 2.1.
我需要将AJAX功能集成到Struts 2 Web应用程序中。我正在看一些教程,并试图使用Dojo插件但很快意识到它已经被弃用了Struts 2.1。
The AJAX documentation for Struts 2 gives a lot of potential solutions and I'm trying to narrow it down a little.
Struts 2的AJAX文档提供了许多潜在的解决方案,我试图将其缩小一点。
I realize this question is a little general and there are some existing Questions here about specific alternatives, but I'd like to get a feel from the community as to what is the most commonly used approach.
我意识到这个问题有点笼统,这里有一些关于具体替代方案的现有问题,但我想从社区中了解最常用的方法是什么。
I'm also interested in whether it is more common to use one of the AJAX taglib plugins (ie. struts2-jquery) or straight AJAX widgets independent of Struts.
我还对使用AJAX taglib插件(即struts2-jquery)或独立于Struts的直接AJAX小部件更常见感兴趣。
I understand the basic concepts of AJAX but don't have much hands-on experience with any of the libraries. I don't mind putting in some time getting up to speed on something if necessary.
我理解AJAX的基本概念,但没有太多关于任何库的实践经验。我不介意花一些时间在必要时加快速度。
Thanks much for any suggestions!
非常感谢任何建议!
2 个解决方案
#1
3
I'd recommend doing it manually via some JS library and them moving to a taglib plugin once you understand exactly what the plugin is abstracting away for you. I think that getting that hands-on experience with the libraries is a better educational / training investment. That way when you move on to another web framework you'll have a better understanding of the javascript API side of things.
我建议通过一些JS库手动完成它,并且一旦你完全理解了插件为你抽象的东西,它们就会转移到taglib插件。我认为,获得图书馆的实践经验是一项更好的教育/培训投资。这样,当您转到另一个Web框架时,您将更好地理解javascript API方面的内容。
jQuery is probably your best choice so you could move on to the struts2-jquery plugin if you decide it's worth it. The Struts 2 jQuery plugin is actively maintained (albeit a few versions behind on jquery/jquery-ui) and I have friends that are using it quite happily. Still, I personally tend to stick with direct jQuery ajax calls to Struts 2 actions that return JSON or FreeMarker snippets for autocompletion, updating search results, etc.
jQuery可能是你最好的选择,所以你可以继续使用struts2-jquery插件,如果你认为它是值得的。 Struts 2 jQuery插件是积极维护的(尽管jquery / jquery-ui背后有几个版本),我有很多朋友正在愉快地使用它。尽管如此,我个人倾向于坚持使用直接的jQuery ajax调用Struts 2操作,这些操作返回JSON或FreeMarker片段以进行自动完成,更新搜索结果等。
#2
3
Use whatever JS framework(s) you want to and don't bother with a plugin unless it offers you a compelling reason to use it.
使用你想要的任何JS框架,不要打扰插件,除非它为你提供了一个令人信服的理由使用它。
If you haven't used a JS framework before and are looking for suggestions, I'd recommend jQuery.
如果您以前没有使用过JS框架并且正在寻找建议,我建议使用jQuery。
#1
3
I'd recommend doing it manually via some JS library and them moving to a taglib plugin once you understand exactly what the plugin is abstracting away for you. I think that getting that hands-on experience with the libraries is a better educational / training investment. That way when you move on to another web framework you'll have a better understanding of the javascript API side of things.
我建议通过一些JS库手动完成它,并且一旦你完全理解了插件为你抽象的东西,它们就会转移到taglib插件。我认为,获得图书馆的实践经验是一项更好的教育/培训投资。这样,当您转到另一个Web框架时,您将更好地理解javascript API方面的内容。
jQuery is probably your best choice so you could move on to the struts2-jquery plugin if you decide it's worth it. The Struts 2 jQuery plugin is actively maintained (albeit a few versions behind on jquery/jquery-ui) and I have friends that are using it quite happily. Still, I personally tend to stick with direct jQuery ajax calls to Struts 2 actions that return JSON or FreeMarker snippets for autocompletion, updating search results, etc.
jQuery可能是你最好的选择,所以你可以继续使用struts2-jquery插件,如果你认为它是值得的。 Struts 2 jQuery插件是积极维护的(尽管jquery / jquery-ui背后有几个版本),我有很多朋友正在愉快地使用它。尽管如此,我个人倾向于坚持使用直接的jQuery ajax调用Struts 2操作,这些操作返回JSON或FreeMarker片段以进行自动完成,更新搜索结果等。
#2
3
Use whatever JS framework(s) you want to and don't bother with a plugin unless it offers you a compelling reason to use it.
使用你想要的任何JS框架,不要打扰插件,除非它为你提供了一个令人信服的理由使用它。
If you haven't used a JS framework before and are looking for suggestions, I'd recommend jQuery.
如果您以前没有使用过JS框架并且正在寻找建议,我建议使用jQuery。