user2444474 user2444474 - 2 months ago 36
Java Question

Struts2 jQuery plugin - submit button

I have Struts2 jQuery plugin submit button, when click the button its not firing the action class as struts submit button. I need to keep the same page after click the button.Please look into below code difference.

Struts submit button - Working good

<s:form action="product!list" id="searchForm" theme="simple" method="Post">
<s:submit action="product" method="list" value="Find" />
</s:form>


Converting struts submit to struts-jquery submit submit button - Not Working good

<s:form action="product!list" id="searchForm" theme="simple" method="Post" >
<sj:submit />
</s:form>


if using only form action
<sj:submit/>
, the page the refreshing and working as Struts tag, but it should not be.

Answer

In order <sj:submit> to work properly targets attribute must be set to some value and form must have id attribute.

<s:form action="product!list" id="searchForm">     
  <sj:submit targets="results"/>
</s:form>
Comments