0

我已经与 JSF 集成了 spring,但我面临着一个奇怪的行为:

  1. 我点击了命令按钮,托管 bean 中的操作方法被成功点击(我在下面的示例中删除了它)。
  2. Ajax 更新完美运行,表单也更新了。
  3. 我点击了另一个按钮,现在托管 bean 中的操作方法没有被点击。
  4. 面板恢复到初始视图并冻结在该视图上。
  5. 除非我刷新页面并重复这些步骤,否则我无法更新表单。

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>

Update: I created a very simple single page and I noticed that when I remove the <h:head></h:head> tags the ajax works like a charm BUT without the fancy primefaces UI, and when I add the tags the ajax stop (this is normal cause <h:head></h:head> tags fetch all the needed JSs and CSSs), What Can I Do?

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>

My Environment

  • Primefaces:3.5
  • JSF-Mojarra:2.2
  • Spring:3.2.3.RELEASE
4

1 回答 1

1

In case anyone faces the same issue. I noticed that the Primefaces showcase is using JSF-Mojarra-2.1.22. I downgraded my JSF-Mojarra version from 2.2 to 2.1.22 and it worked like a charm.

If I am not wrong, I guess it should be reported to primefaces (if it isn't a current issue).

于 2013-06-16T07:07:34.433 回答