【问题标题】:ice:commandButton works after second clickice:commandButton 在第二次点击后工作
【发布时间】:2013-11-11 08:46:37
【问题描述】:

我正在使用 jsf 2.0 和 icefaces 3.0。我已将我的应用程序从 icefaces 1.8 迁移到 3.0,但是 我在每个 jsf 页面上都面临一个 ice:commandbutton 问题。它每次都需要第二次点击,然后将响应发送到浏览器,我通过使用网络选项卡使用 IE 开发人员工具(IE 中的 F12)调试问题。所以当我第一次击球时,我会得到以下回复:

   <?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[8640112048343005235:64165239481062360]]></update><extension aceCallbackParam="validationFailed">{"validationFailed":false}</extension></changes></partial-response>

第二次点击它就可以工作了。

以下是我的按钮代码。

<ice:commandButton value="#{msgs['submit.label']}"
                                            id="submitCmd2" type="submit"
                                            actionListener="#{applicationController.submit}"
                                            rendered="true" styleClass="buttonpurple" onclick="showLoader();"
                                            style="width: 125px; " align="center" />

但我无法理解是什么原因以及我需要使用什么解决方案来解决这个问题。我也浏览过balusC链接commandButton/commandLink/ajax action/listener method not invoked or input value not updated

提前致谢。

【问题讨论】:

  • 你的按钮代码到底是什么?
  • @AlexandreLavoie 我已添加按钮代码,请查看此
  • @BalusC 请看这个..
  • 我想我的问题是关于生命周期问题。在 jsf 页面上我有 valuechangelisteners 并且每个 valuechangelistener 都有行 FacesContext.getCurrentInstance().renderResponse();我评论了那条线,然后它的工作,但我无法找到为什么他们在 valueChangeListener 的末尾使用 renderResponse.. 并且评论这条线是否有任何副作用......
  • @nicknamecomment-replies 仅在相关人员之前对帖子发表过评论时才有效。

标签: jsf jsf-2 icefaces


【解决方案1】:

不要使用actionListener 在ice:commandbutton 中尝试action。还有一些differences-between-action-and-actionlistener

<ice:commandButton value="#{msgs['submit.label']}"
                                        id="submitCmd2" type="submit"
                                        action="#{applicationController.submit}"
                                        rendered="true" styleClass="buttonpurple" onclick="showLoader();"
                                        style="width: 125px; " align="center" />

type='submit' 也不是必须的,默认是提交。

【讨论】:

  • @vels4j 谢谢,我同意你的观点,但我认为它不能解决问题,请查看我在问题中提到的 xml 响应..
  • onClick 中的 ShowLoader 是什么?也试试 partialSubmit="true"
  • 它仅用于显示一个加载图像并尝试使用 partialSubmit="true"...
  • 为此你可以使用 ice:outputConnectionStatus icefaces-showcase.icesoft.org/…
【解决方案2】:

您可以尝试here 中描述的解决方法

如果这不起作用,您可以尝试使用 jsf 命令按钮的 ajax,以它自己的最佳方式。

<h:commandButton value="#{msgs['submit.label']}"
                                    id="submitCmd2" 
                                    actionListener="#{applicationController.submit}"
                                    styleClass="buttonpurple" onclick="showLoader();"
                                    style="width: 125px; " align="center">
  <f:ajax execute="id1 id2 id3...." render="@form"/>
</h:commandButton>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-25
    • 2017-03-29
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 2019-09-28
    • 2017-01-28
    相关资源
    最近更新 更多