trigger an sj:submit form an onchange event

456 views
Skip to first unread message

ava

unread,
Jul 13, 2012, 8:48:16 AM7/13/12
to struts2...@googlegroups.com
Hello everybody, simple question this time:
i've got a form containin
g an s:select element, and an sj:submit...simple as that.
Is it possible to call the sj:submit (ajax action) whenever the user changes the selected value of the s:select element?

ava

unread,
Jul 13, 2012, 11:51:56 AM7/13/12
to struts2...@googlegroups.com
Thank you for your answer! It works perfectly, but only on the first time the value changes... any clue?

ava

unread,
Jul 16, 2012, 6:53:17 AM7/16/12
to struts2...@googlegroups.com
Still can't make it work after the first time the selected value changes... has nobody experienced the same problematic?

jchin

unread,
Jul 16, 2012, 9:12:57 AM7/16/12
to struts2...@googlegroups.com
Can you post a sample code of what's not working?

ava

unread,
Jul 16, 2012, 10:25:52 AM7/16/12
to struts2...@googlegroups.com
2 pages:

main.jsp:
 
 <div id="filter" class="form">    
<s:form action="oPFilter" theme="simple">
               <s:select headerKey="-1" 
                         headerValue="select"
                         label="project" 
                         name="idPrj" 
                         list="%{listaPrj}" 
                         listKey="id" 
                         listValue="name" 
                         onchange="$.publish('submitFormTopic')" />
     
<sj:submit
indicator="indicator"
targets="moreFilter"
button="true"
value="select"
                                listenTopics="submitFormTopic"/>
                        </s:form>
   
<div id="moreFilter">
   
</div>    
       </div>

timeFilter.jsp containing another form


ava

unread,
Jul 16, 2012, 10:27:00 AM7/16/12
to struts2...@googlegroups.com
I forgot to say that timeFilter.jsp is the result page of the oPFilter action

jchin

unread,
Jul 16, 2012, 1:04:26 PM7/16/12
to struts2...@googlegroups.com
Your code looks okay to me. I suspect there must be some javascript error occurred after the div "moreFilter" is replaced by ajax.
Reply all
Reply to author
Forward
0 new messages