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?
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 SubmitTag.
If you make an Ajax call via <sj:submit>
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.
Just add id
attribute in the form tag and targets
attribute in the <sj:submit>
tag.
<s:form id="myForm" action="part!list">
<sj:submit targets="result"/>
</s:form>
You should use <s:submit/>
if there is not a requirement to trigger a ajax call. <s:submit/>
uses the html mechanism to submit a form, but <sj:submit />
is making an ajax call, check out the source HERE, it explains how it works. If you need this form to make an ajax call, then just like @AleksandrM said, define the attribute targets = "result"
, then you should have something like <div id="result"/>
, which contains the result of the ajax call.