Using JSF and PrimeFaces 6.1 I have an inputText field as such:
<p:inputText value="#{backingBean.stringField}">
<p:ajax event="valueChange" update="@form" />
</p:inputText>
and within the same form is a commandButton:
<p:commandButton id="btnDoThatThing"
ajax="true"
immediate="true"
update="@form"
process="@this"
action="#{backingBean.doThatThing}"/>
When I
- make a change to the inputText field,
- then click somewhere OTHER THAN the command button
- click the command button
everything works exactly as expected. BUT if I:
- make a change to the inputText field,
- immediately the command button
the button is NOT fired since the first click of the commandButton is triggering the valueChange event to happen in the inputText field.
if I click it a second time the button action finally happens.
now, if i change the p:ajax event="valueChange"
to p:ajax event="keyup"
the first click of the commandButton work as expected, but unfortunately the keyup event on a inputField is pretty hacky and you lose functionality within the field (copy/paste text, text selection, 'fast' typing' etc)
any thoughts on how to initiate the change event in the inputText field, AND fire the commandButton action when the user clicks the button immediately from typing in the inputText field?
thanks for your time!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…