简体   繁体   中英

How to call action method before onClick event

I got the trouble with this JSF. I like to call the action method first and then like to call the JavaScript OnClick Event.

<input value="Select" jsfc="ft:commandButton" style="width: 70px;" type="button" onclick="setReturnValues(this,'memId');" action="#{eem1001.EEM1001FormBean.memberChange(line.memId)}"/>

But JavaScript OnClick Event is call before action method.

How can I call action method before JavaScript OnClick Event.

为此,您可以在mouseDown事件上调用操作方法,然后在mouseUp事件上调用第二个方法setReturnValues(this,'memId')

You can call your desired method on body part. Like this

<body onload="methodName()" >

If it is possible for you to use JBoss Richfaces, you can add a4j:support to your button and with its oncomplete attribute you can call your javascript setReturnValues(this,'memId') after actual action eem1001.EEM1001FormBean.memberChange(line.memId) Like:

<input value="Select" jsfc="ft:commandButton" style="width: 70px;" type="button" >
  <a4j:support event="onclick" 
    action="#{eem1001.EEM1001FormBean.memberChange(line.memId)" 
    oncomplete="setReturnValues(this,'memId');"  
    disableDefault="true" />
</input>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM