views:

116

answers:

1
<form jwcid="@Form" listener="listener:updateStaff">


<select jwcid="staffselect@Select" multiple="ognl:false" validators="validators:required" onchange="this.form.submit()" listener="listener:updateStaff">
               <span jwcid="@For" source="ognl:hrStaff" value="ognl:currentHrStaff" index="ognl:currentHrStaffIndex">
                   <option class="text11" jwcid="@Option" selected="ognl:hrStaffSelection[currentHrStaffIndex]" label="ognl:currentHrStaff"/>
               </span>
           </select>


</form>

when onchange on selectbox, this form will be submitted and my pageValidate() will be called follow by upadteStaff() listener method. I wonder, when such submission is fired, can onchange='' pass a flag ('selectboxisfired' string) that i able to capture inside pagevalidate() 'selectboxisfired'? this will allow my logic inside pagevalidate to indicate is triggered by selectbox.

+1  A: 
onchange="window.submitTrigger=this; this.form.submit();"

Then you can read the window.submitTrigger variable in your validation routines to work out which element triggered the submission, for example

/* somewhere in pagevalidate() routine */
/* note here that I am assuming the html id of the selectbox is "staffselect"
   -> I'm not familiar with Tapestry so simply had to make the assumption
      that this is the correct id - if not, change the string you're searching
      for accordingly */
if (window.submitTrigger.id = "staffselect") {
  //do something here
}

Of note, is that I think it's bad style to use onchange in this way, however not understanding Tapestry, I'm just giving you the most simple change to what's already there which I assume will work...

Graza
on pagevalidate(), how to get this window.submittrigger?
cometta
The statement `window.submitTrigger=this;` creates a property attached to the window object called `submitTrigger` (it could be any name you like, submitTrigger was just an example), and sets it to `this` (where `this` is the current element. I'll edit my answer to give an example of what you might do in pagevalidate()
Graza