第二次不调用Primefaces命令按钮操作

时间:2013-06-10 16:09:49

标签: ajax jsf primefaces

我有一个与JSF集成的Spring,我面临一个奇怪的行为:

  1. 我点击了命令按钮,成功点击了托管bean中的action方法(我在下面的示例中删除了它。)
  2. Ajax更新工作正常,表单已更新。
  3. 我点击了另一个按钮,现在托管bean中的操作方法没有被点击。
  4. 面板将恢复到初始视图,并在此视图中冻结。
  5. 我无法更新表单,除非我刷新页面并重复这些步骤。
  6. DealerInfo.xhtml:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html>
    <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"
        xmlns:p="http://primefaces.org/ui">
    
    <ui:composition template="/WEB-INF/templates/default.xhtml">
        <ui:define name="content">
            <h:form id="toolBarForm">
                <p:toolbar style="margin-bottom:5px;">
                    <p:toolbarGroup align="right">
                        <p:commandButton value="Add"
                            update=":toolBarForm" icon="ui-icon-plusthick" />
                        </p:toolbarGroup>
                    </p:toolbar>
                <p:messages id="dealerInfoMessages" />
                <ui:include src="/pages/dealers/DealerMainInfo.xhtml" />
            </h:form>
        </ui:define>
    </ui:composition>
    </html>
    

    信息页/经销商/ DealerMainInfo.xhtml

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html>
    <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"
        xmlns:p="http://primefaces.org/ui">
    
    <ui:composition>
        <p:panel id="dealerMainInfoPanel" header="Dealer Main Info"
            style="margin-bottom:5px;">
            <h:panelGrid columns="2">
                <p:outputLabel for="dealerCode" value="Dealer Code" />
                <p:inputText id="dealerCode" required="true"
                    value="#{dealerMainInfoBO.dealerCode}" style="width:200px;" />
    
                <p:outputLabel for="dealerName" value="Dealer Name" />
                <p:inputText id="dealerName" required="true"
                    value="#{dealerMainInfoBO.dealerName}" style="width:200px;" />
            </h:panelGrid>
        </p:panel>
    </ui:composition>
    </html>
    

    更新 我创建了一个非常简单的单页,我注意到当我删除<h:head></h:head>标签时,ajax的工作方式就像魅力 BUT 而没有花哨的primefaces UI,当我添加标签时,ajax停止(这是正常原因<h:head></h:head>标签获取所有需要的JS和CSS),我该怎么办?

    Example.xhtml

    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE html>
    <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"
        xmlns:p="http://primefaces.org/ui">
    
    <f:view contentType="text/html">
        <h:head>
        </h:head>
        <h:body>
            <h:form id="toolBarForm">
                <p:toolbar style="margin-bottom:5px;">
                    <p:toolbarGroup align="right">
                        <p:commandButton value="Add" update=":toolBarForm"
                            action="#{bean.add}" />
                    </p:toolbarGroup>
                </p:toolbar>
                <p:messages id="operationDefinitionMessages" />
                <h:panelGrid columns="2">
                    <p:outputLabel for="text" value="Text" />
                    <p:inputText id="text" required="true" value="#{bean.text}" />
                </h:panelGrid>
            </h:form>
        </h:body>
    </f:view>
    </html>
    

    我的环境

    • Primefaces:3.5
    • JS​​F的钻嘴鱼科:2.2
    • 弹簧:3.2.3.RELEASE

1 个答案:

答案 0 :(得分:1)

如果有人遇到同样的问题。我注意到Primefaces showcase正在使用JSF-Mojarra-2.1.22。我将JSF-Mojarra版本从2.2降级为2.1.22,它就像魅力一样。

如果我没有错,我想它应该报告给primefaces(如果它不是当前的问题)。