必须按两次命令按钮 [英] have to press command button twice

查看:73
本文介绍了必须按两次命令按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个网页,现在注意到我必须按两次命令按钮.任何命令按钮都具有相同的问题,因此我认为我会在其中一个上添加和操作侦听器,以查看是否可以看到某些内容.

I'm working on building a web page and notice now that I have to press the command button twice. Any command button has the same problem, so I figured I would add and action listener on one of them to see if I could see something.

<h:form id="formP">
    <p:commandButton id="temp" value="photos" actionListener="#{viewBacking.debugBreakpoint()}" action="userPhoto" />
</h:form>

后备豆具有

public void debugBreakpoint() {
    int i = 0;
    i++;
}

不幸的是,这确实有帮助.仅在第二次按下后才达到我的断点.我怀疑某个地方的某个字段未通过验证,但是我想使用某种方法来检测到底出了什么问题-为什么我需要第二次推送?我可以在Glassfish中打开某些选项,还是可以查看调试信息转储的其他选项?我可以忽略转储,直到一切稳定为止,然后当我第一次按下按钮时,看看发生了什么.

Unfortunately, this does help. It hits my breakpoint only after the second press. I suspect that some field somewhere isn't passing validation but I would like some method of detecting what exactly is going wrong - why do I need the second push? Is there some option I can turn on in Glassfish, or something else where I can look at a dump of debug information? I can ignore the dump until everything is stable and then see what exactly is happening when I press the button for the first time.

有没有我可以使用的工具?

Is there any such tool which I can use?

推荐答案

当给定<h:form>的父级组件已由另一个带有<f:ajax>的命令按钮/链接呈现/更新时,可能会发生这种情况.然后,给定的表单将失去其视图状态,只有在首次提交表单后才会返回该视图状态.随后,所有后续提交都将以通常的方式工作.这是由 JSF问题790 中描述的JSF JS API中的错误引起的在即将发布的JSF 2.2中.

That can happen when a parent component of the given <h:form> has been rendered/updated by another command button/link with <f:ajax>. The given form will then lose its view state which it would only get back after submitting the form for the first time. Any subsequent submits will then work the usual way. This is caused by a bug in JSF JS API as descibred in JSF issue 790 which is fixed in the upcoming JSF 2.2.

您需要用<f:ajax>修复另一个命令按钮/链接,以在render中明确包含给定<h:form>的客户端ID.

You need to fix the another command button/link with <f:ajax> to explicitly include the client ID of the given <h:form> in the render.

<f:ajax render=":somePanel :formP" />

另一种方法是用PrimeFaces <p:commandLink><p:commandButton>替换此<f:ajax>,这样您就无需显式包括所有表单的客户ID. PrimeFaces自己的JS API即已包含此修复程序.

Another way is to replace this <f:ajax> by a PrimeFaces <p:commandLink> or <p:commandButton> so that you don't need to explicitly include the client ID of all the forms. PrimeFaces's own JS API has namely already incorporated this fix.

这篇关于必须按两次命令按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆