JSF的Ajax更新使commandLink未能在第一次点击 [英] JSF Ajax updates makes commandLink fails at the first click

查看:147
本文介绍了JSF的Ajax更新使commandLink未能在第一次点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的JSF页面我有一个组合框,更新时,组合框的一个项目被选中的表。

In my JSF page I have a combobox that updates a table when an item of the combobox is selected.

表包含与编辑联系的项目。

The table contains items with an edit link.

现在的问题是,当表由你需要点击两次的链接转到页组合框改变。第一次单击刚刚刷新页面。

The problem is when the table is changed by the combobox you need to click twice on the link to go to the page. The first click just refresh the page.

下面是XHTML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">
    <body>
        <ui:composition template="/template.xhtml">
            <ui:define name="windowTitle">Comment packages</ui:define>
            <ui:define name="content">
                <h3>Select the package to comment.</h3>
                <h:form prependId="false">
                    Section:
                    <h:selectOneMenu id="selectSection" value="#{platformService.currentSection}">
                        <f:ajax render=":list-packages" />
                        <f:selectItems value="#{platformService.releasePlatform.sections}" />
                    </h:selectOneMenu>
                </h:form>
                <p/>
                <h:panelGroup id="list-packages">
                    <h:dataTable id="packageList" var="package" value="#{packageService.packages}" border="1" >
                        <h:column>
                            <f:facet name="header">Package name</f:facet>
                            #{package.name}
                        </h:column>
                        <h:column>
                            <h:form>
                                <h:commandlink action="#{commentService.commentPackage}" value="Comment">
                                    <f:param name="packageName" value="#{package.name}" />
                                </h:commandLink>
                            </h:form>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
            </ui:define>
        </ui:composition>
    </body>
</html>

我也试过用的commandButton,但你还需要点击两次按钮。

I've also tried with commandButton but you also need to click twice on the button.

我在Maven中运行JSF 2.0.1-FCS /码头。

I'm running JSF 2.0.1-FCS in Maven/Jetty.

推荐答案

它的工作原理,当你把表内的单个&LT; H:形式GT; 。取出内&LT; H:形式GT;从列并替换&LT; H:panelGroup中的id =列表包&GT; &LT; H:表格ID =列表包&GT;

It works when you put the table inside a single <h:form>. Remove the inner <h:form> from the column and replace <h:panelGroup id="list-packages"> by <h:form id="list-packages">.

我不知道如何/为什么这个问题是由于(需要更多的时间来研究),但它可能与这样的事实表的状态,重要的是要知道哪些行被选中。

I am not sure how/why this problem is caused (requires more time to investigate) but it's probably related to the fact that the table's state is important to know which row was selected.

这篇关于JSF的Ajax更新使commandLink未能在第一次点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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