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>

selectboxでonchangeすると、このフォームが送信され、私のpageValidate()が呼び出され、upadteStaff()リスナーメソッドが続きます。そのような送信が実行されたときに、onchange =''がpagevalidate()'selectboxisfired'内でキャプチャできるフラグ('selectboxisfired'文字列)を渡すことができるのだろうか?これにより、pagevalidate内のロジックが、selectboxによってトリガーされたことを示すことができます。

4

1 に答える 1

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

次にwindow.submitTrigger、検証ルーチンで変数を読み取って、たとえば、送信をトリガーした要素を特定できます。

/* 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
}

注目すべきは、このようにonchangeを使用するのは悪いスタイルだと思いますが、タペストリーを理解していないので、すでにそこにあるものに最も簡単な変更を加えて、うまくいくと思います...

于 2010-04-16T10:12:01.893 に答える