struts2struts2-jquery

How to use Struts2 jQuery plugin <sj:submit> button?


I have Struts 2 jQuery plugin <sj:submit> button, when I click the button it's not firing the action class, as Struts <s:submit> button is doing. I need to keep the same page after clicking a 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 <sj:submit/> only, the page is refreshing and working as Struts <s:submit>tag, but it should not be.


Solution

  • 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>