开发者

Ajax event never fires in <p:inptText> when required="true"

In PrimeFaces when I use:

开发者_StackOverflow中文版
<p:inputText required="true"
             requiredMessage="message"
             value="#{backingBean.value}">

<p:ajax event="focus"
        update="infoText"
        listener="#{backingBean.something()}" />

</p:inputText>

The Ajax-event is never fired. However, if I remove the required="true" everything works fine and the event fires.

Can anyone tell me how to use p:inputText with p:ajax and required="true"?


This is probably occurring because when you gain focus to the text field an ajax event occurs that posts back the ViewState for the components on the page.

When it does this it is attempting to set the current value of the text field to #{backingBean.value} which is empty, causing a ValidatorException to be thrown. Because this validation error occurred the action event #{backingBean.something()} is never being fired.

Try adding the property immediate="true" to the <p:ajax> tag and see if that allows the event to fire before the validation phase.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜