3

コンポーネントに重大な問題がありp:tabViewます。とtabViewを設定dynamic="true"しました。cache="false"タブの 1 つには、設定されている入力コンポーネントがいくつかありますrequired="true"

毎回タブを変更すると、フォームの検証が行われ、FacesMessages がうなり声で表示されます。

タブは次のとおりです。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:p="http://primefaces.org/ui"
   template="/WEB-INF/templates/globalTemplate.xhtml">

   <ui:define name="title">#{adbBundle['home']}</ui:define>
   <ui:define name="content">
      <p:growl id="growl" showDetail="true" autoUpdate="true" />

      <p:tabView id="adminTabView" dynamic="true" cache="false">
         <p:tab title="#{adbBundle['admin.customerTab.title']}"
            id="customerTab">
            <ui:include src="/WEB-INF/includes/adminCustomer.xhtml" />
         </p:tab>
         <p:tab title="#{adbBundle['admin.activityTab.title']}"
            id="activityTab">
            <ui:include src="/WEB-INF/includes/addActivity.xhtml" />
         </p:tab>
      </p:tabView>

   </ui:define>

</ui:composition>

adminCustomer.xhtml には次のフォームが含まれています。

<ui:composition 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">

   <h:form id="customerForm">
      <p:panel id="addCustomerPanel" toggleable="true"
         header="#{adbBundle['admin.addCustomerPanel.header.new']}">
         <p:panelGrid columns="2" id="addCustomerTable"
            styleClass="addCustomerTable">
            <f:facet name="header">
               <p:outputLabel id="header"
                  value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.header']}" />
            </f:facet>

            <p:outputLabel for="customerName"
               value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerName']}" />
            <h:panelGroup layout="block">
               <p:inputText id="customerName" styleClass="customerName"
                  autocomplete="off"
                  label="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerName']}"
                  value="#{adminController.customerDTO.customerName}"
                  required="true" />               
            </h:panelGroup>

            <p:outputLabel for="customerId"
               value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerId']}" />
            <h:panelGroup layout="block">
               <p:inputText id="customerId" autocomplete="off"
                  label="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerId']}"
                  value="#{adminController.customerDTO.customerId}" required="true">
                  <f:validator validatorId="customerIDValidator" />
               </p:inputText>               
            </h:panelGroup>

            <p:outputLabel for="activeStatus"
               value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.activeStatus']}" />
            <h:panelGroup layout="block">
               <p:selectBooleanCheckbox id="activeStatus"
                  value="#{adminController.customerDTO.active}" />
            </h:panelGroup>

            <f:facet name="footer">
               <p:commandButton value="#{adbBundle['saveButton']}"
                  actionListener="#{adminController.saveCustomer}"
                  icon="ui-icon-check"
                  update=":growl, @form" />
            </f:facet>
         </p:panelGrid>
      </p:panel>
   </h:form>

</ui:composition>

自分が間違っていることと、それを解決する方法を見つけることができません。JSF Mojarra 2.1.7-jbossorg で Primefaces 3.4.2 を使用しています。どんなポインタでも私にとって非常に役に立ちます。

PrimeFaces フォーラムでもこの質問をしました。

4

2 に答える 2

4

これがどのように機能するかtabViewです。PrimeFacesトラッカーからの関連する問題は次のとおりです。

ご覧のとおり、最初のものはWontFixとしてマークされています。2つ目は重複していますが、最後に別の回避策が表示されます

そのスレッドを注意深く読むと、いくつかの回避策がまだ存在していることに気付くかもしれません。を使用せざるを得ない場合は、そのうちの1つを試してくださいtabView。別のタブで入力を使用する場合は、PrimeFaces-Wizardの使用も検討してください。

于 2012-12-26T06:03:04.740 に答える
0

私があなたの問題を正しく理解していれば、メッセージの重複表示を防ぐための非常に簡単な回避策があります。

うなり声を次のように変更します。

<p:growl id="growl" globalOnly="true" autoUpdate="true" showDetail="true" />

バッキング Bean 側からメッセージを追加する場合は、次のコードを使用して実行できます。

FacesContext.getCurrentInstance()
   .addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "title", "details");

また、完全に安全にしたい場合は、うなり声に for 属性を指定し、それを の最初のパラメーターとして使用することもできますaddMessage

于 2014-08-14T08:31:06.920 に答える