0

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
AKZap
  • 1,181
  • 6
  • 17
  • 31

3 Answers3

1

For that you can call action method on mouseDown event and then on mouseUp event you can call your 2nd method setReturnValues(this,'memId').

Ahamed Mustafa M
  • 3,069
  • 1
  • 24
  • 34
Sunil Dodiya
  • 2,605
  • 2
  • 18
  • 21
0

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

<body onload="methodName()" >
Vimalnath
  • 6,373
  • 2
  • 26
  • 47
SilentBomb
  • 168
  • 2
  • 11
0

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>
Ahamed Mustafa M
  • 3,069
  • 1
  • 24
  • 34