Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Any hint of JQuery on struts2 tutorial, thanks!

 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because our team is using struts2 to develop the web application and I'm in charge of the UI part, I have to restrict the UI to struts2.

I heard that JQuery is very popular and I love it. Also, I know some people are using it in struts2. However, I couldn't find any related tutorial. Any tutorial online or shall I buy some book about this issue?

Thank you very much!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing special about using jQuery with S2; just use it as you would with any other framework. There's a plugin in the sandbox; I'm not sure of its current status. It's meant for simple use-cases.
 
vishwa venkat
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JQuery is not a part of Struts2. You can include JQuery in any JSP/HTML pages as a javascript utilities. Refer to JQuery documentation. Firts try to experimaent with JQUERY in HTML page and you can move the similar stuff onto JSP.
 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what I need to do is two steps:
1. implement JQuery in html as www.jquery.com
2. implement JQuery in jsp as javascript

If I'm right, in step 1, is there any tutorials highly recommended? I followed 2 of the tutorials of www.jquery.com yesterday.

For step 2, shall I use JSON to translate Java info into javascript?

I'm new to struts2, therefore, my questions may seem stupid. Thank you
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO there's no reason to do it in HTML first. Whether or not to use JSON depends on what you're actually trying to accomplish; you can also get HTML back and put it in a DOM element.

S2 supports returning JSON via the JSON plugin/result and the REST plugin if you need raw data back in JSON format.
 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:IMO there's no reason to do it in HTML first. Whether or not to use JSON depends on what you're actually trying to accomplish; you can also get HTML back and put it in a DOM element.

S2 supports returning JSON via the JSON plugin/result and the REST plugin if you need raw data back in JSON format.


Thanks, David, Any online tutorial regarding this issue(JSON, JQuery,Struts2)?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
None that I'm aware of, but there might be.

The S2 part of it is very simple; either play around with the JSON result or the REST plugin. Both have documentation pages, and the REST plugin has a showcase example. The jQuery side of things is the same regardless of the backend, so any jQuery tutorials that consume JSON should be more than adequate.
 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:None that I'm aware of, but there might be.

The S2 part of it is very simple; either play around with the JSON result or the REST plugin. Both have documentation pages, and the REST plugin has a showcase example. The jQuery side of things is the same regardless of the backend, so any jQuery tutorials that consume JSON should be more than adequate.


Thank you, David.

Is this(http://cwiki.apache.org/S2PLUGINS/json-plugin.html) the JSON documentation page you mentioned? Shall I also use SMD?

As for jQuery tutorials that consume JSON, I didn't find it online. Could you please give any more info?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the JSON plugin docs, yes. The REST plugin is something different. I've never known what SMD is, or is for.

For JavaScript/jQuery information as in the JavaScript forum. When I searched for "jquery +ajax +json" I got all sorts of relevant links, so I'm not sure what you did wrong there.
 
will zhang
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:That's the JSON plugin docs, yes. The REST plugin is something different. I've never known what SMD is, or is for.

Thanks, David

For JavaScript/jQuery information as in the JavaScript forum. When I searched for "jquery +ajax +json" I got all sorts of relevant links, so I'm not sure what you did wrong there.


SMD is Simple Method Definition/Description, utilized in the link: http://cwiki.apache.org/S2PLUGINS/json-plugin.html , dojo RPC is also used there. Are they necessary or not? If not, any better way to execute action methods from JQuery and return the output? Thanks!

for "jquery +ajax +json", I found most tutorials are jquery+ajax+json+php, few about struts2, The only tutorial I found: http://www.arya199.com/struts-2/ajax-json-with-struts-2, From your point of view, is it a helpful one?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said previously it doesn't matter what the back-end is: if you're interested in consuming JSON, then any jQuery tutorial that consumes JSON is relevant--just replace the back-end with S2.

Whether or not you use SMD is up to you: I've never used it, but that doesn't mean it isn't useful--I've just never used it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic