jspstruts2struts2-jquery

What's the difference between Struts tag <s:submit> and Struts jQuery tag <sj:submit>?


Struts tag <s:submit> and Struts jQuery tag <sj:submit> both submit in the same way. I mean, they refresh the page and forward to another to page. But I thought Struts jQuery tag implemented Ajax so the page should not be change while submitting. Am I correct?

I have implemented both tags in form, while submitting both are working same way.

<s:form action="part!list" >
  <s:submit  action="part" method="list" />
</s:form>

<s:form action="part!list" >
  <sj:submit />
</s:form>

If I use <sj:submit> it works, but I add some struts tag button <s:submit> in the same form then it doesn't work. So, Struts tag won't work?


Solution

  • You have probably forgot to include <sj:head/> tag in the body of the <head>. This tag links JQuery stylesheet onto the page and other initial things, without it Ajax call is not made. See examples of correct submitting <sj:submit>.

    If you make an Ajax call via <sj:submit> tag, the page should not refresh but the targets could be updated on successful result. If didn't include JQuery in the head of the page I don't think the form make any of the HTTP requests, it's behaving like you are not included the action attribute.