Primefaces 验证码消失或不更新/刷新无效输入? [英] Primefaces Captcha disappears or doesn't update/refresh on invalid input?
问题描述
我在 h:form
<h:panelGrid id="captchaGrid">
<p:captcha id="captcha" label="Captcha" required="true"
requiredMessage="required"
validatorMessage="...">
</p:captcha>
<p:message id="captchaMessage" for="captcha" />
</h:panelGrid>
<p:commandButton id="submitButton" value="save"
actionListener="#{userBean.save}" update="captchaGrid"
onstart="doSomething()"
oncomplete="doSomethingElse(xhr, status, args)" icon="ui-icon-check">
</p:commandButton>
如果我正确输入验证码,这工作正常.但是,如果我输入了无效值,验证码组件就会消失.
This works fine if I enter the captcha correctly. However, if I enter an invalid value, the captcha component just disappears.
我尝试删除 update="captchaGrid"
属性.这一次,验证码没有消失.相反,它没有在视觉上刷新,而是(我猜)在内部刷新.因为正确输入这两个词仍然会产生验证错误.
I tried removing the update="captchaGrid"
attribute. This time, the captcha didn't disappear. Instead, it didn't refresh visually but (I guess) internally. Because typing the two words correctly still generates a validation error.
此外;我不想使用 ajax="false"
.
更新:我也试过 oncomplete="Recaptcha.reload()"
.没用.有一个错误.但我不知道是我的代码还是 Primefaces 3.0 :)
Update: I also tried oncomplete="Recaptcha.reload()"
. Didn't work. There is a bug. But I don't know if it's my code or Primefaces 3.0 :)
更新 2: 正如 maple_shaft 指出的那样,事实证明这是 Primefaces/Recaptcha 的问题.所以我正在寻找你可能建议的任何肮脏的黑客.
Update 2: As maple_shaft pointed out, it turns out that this is a problem with Primefaces/Recaptcha. So I'm looking for any dirty hacks you might suggest.
感谢任何帮助.
推荐答案
您不会喜欢我的回答,但这不是错误.
You are not going to like my answer, but this is not a bug.
Primefaces 问题 1642 被标记为无法修复.
Primefaces Captcha 使用 Recaptcha,它不支持也不能支持 Ajax 刷新.您必须执行整页回发才能使该组件正常工作.请记住,这也会影响在需要 Ajax 刷新面板的组件(例如选项卡视图或向导组件)中使用验证码的能力.
The Primefaces Captcha utilizes Recaptcha, which does not and cannot support Ajax refresh. You must do a full page postback for this component to work properly. Keep in mind this also affects the ability to use the Captcha in components that require Ajax refresh of a panel, such as a Tab View or Wizard component.
在另一个注意事项中,可能可以在 中使用验证码组件来实现类似的效果,但这似乎很脏黑客.抱歉,帮不上忙了.
On another note, it might be possible to use the captcha component within an <iframe>
to achieve a similar effect, but that seems like a dirty hack. Sorry I couldn't be more of a help.
这篇关于Primefaces 验证码消失或不更新/刷新无效输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!