Search code examples
jquerystruts2struts2-jquerystruts2-json-plugin

How to submit a form on sj dropdown select?


I am using Struts 2 jquery plugin's dropdown list. i want to submit the form which has this dropdown and want to give the target to some other div.please give some idea.Thanking you in advance. here is the code:

         <sj:select 
          list="dayList" 
          href="%{idDayList}"
          title="Select day"
          id="dayId" headerKey="-1"
          headerValue="-----Select Day-----" 
          targets="rightBottomDiv"/>   


<sj:div id="rightBottomDiv"  formIds="idLeftForm"  cssStyle="height:100%;width:100%;background-color:#dfdsf;"                                        draggableRevert="invalid" cssClass="accept ui-widget-content ui-corner-all" >
          <jsp:include page="templateRightBottomDiv.jsp"/>
          </sj:div>
<action name="daySubmitAction2"  method="divRefreshMethod" class="com.ebhasin.fitnessbliss.actions.templateExerciseAction">
                <result  name="success">/jsps/templateRightBottomDiv.jsp</result>
            </action>

Solution

  • try:

             <sj:select 
              list="dayList" 
              href="%{idDayList}"
              title="Select day"
              id="dayId" headerKey="-1"
              headerValue="-----Select Day-----" 
              targets="rightBottomDiv"
              onChangeTopics="somethingHappened"/>
    
    <script>
        $.subscribe('somethingHappened', function(){
            $("your-form-selector").submit();
        });
    </script> 
    

    UPDATE

    If you have a action like this:

    <action name="daySubmitAction2"  method="divRefreshMethod" class="com.ebhasin.fitnessbliss.actions.templateExerciseAction">
        <result name="success">/jsps/templateRightBottomDiv.jsp</result>
    </action>
    

    You can load your div easily like this:

    <s:url var="remoteUrl" action="daySubmitAction2"/>
    <sj:div href="%{remoteUrl}/>