0

I want to execute a method in Struts 2 from a checkbox but in ajax without refreshing the page any idea how to do that ? I'm using the struts 2 checkbox

<s:checkbox name="sie_cocherDecocher" fieldValue="true" />

I tried also the struts 2 dojo tags :

    <sx:a executeScripts="true" value="Enregistrer" targets="divajax" 
      onchange="document.getElementById('loading_4').style.display='block';" indicator="indicator" 
      href="%{sie_cocherDecocher}" cssClass="sect">
      <s:checkbox name="sie_cocherDecocher" fieldValue="true" />
    </sx:a> 

And I already mapped the action like that :

<action name="sie_cocherDecocher"
    class="com.controleur.Central"
    method="sie_cocherDecocher">
    <interceptor-ref name="createSession" />
    <interceptor-ref name="defaultStack" />
    <interceptor-ref name="allowAccessIntercept" />
    <result name="allowAccess">/WEB-INF/jsp/AllowAccess/connectAllowAccess.jsp
    </result>
    <param name="contentType">text/html;charset=ISO-8859-1</param>
    <result name="success">/WEB-INF/jsp/bord.jsp
    </result>
</action>
Brahim LAMJAGUAR
  • 1,254
  • 5
  • 19
  • 28
  • I tried just this method but with no success, currently I'm trying to see also the dojo struts tags but with no success I will update the question to show it – Brahim LAMJAGUAR Jun 17 '16 at 13:18
  • finally I found the solution in another answer of you Roman C Thanks a lot: http://stackoverflow.com/questions/20606540/calling-an-action-using-ajax-url-in-struts-2 , but just any idea when invoking an action through ajax there is a way to pass parameter to the method ? – Brahim LAMJAGUAR Jun 17 '16 at 14:18
  • Parameter to the method? Are you sure what are you asking. Do you mean a parameter in Java method? – Roman C Jun 17 '16 at 20:57
  • yes, because currently I can invoke a java method without refreshing through calling the action in ajax, the method is invoked through that call of action, but I don't know how to pass parameter with. – Brahim LAMJAGUAR Jun 18 '16 at 13:54
  • First you can read http://stackoverflow.com/a/35475615/573032, next you can ask a new question if you understand the topic from that answer. – Roman C Jun 18 '16 at 14:06

0 Answers0