2012-08-23 2 views
1

ui : repeat 또는 다른 반복 태그를 사용하여 배열 목록의 각 항목에 대해 한 번만 많은 구성 요소를 표시하려고합니다. JSF ui : 반복하여 렌더링

<!-- print multiple mandates --> 
     <ui:repeat id="mandates" var="mandate" value="#{taxheadDirectDebit.mandates}"> 




     <a4j:region id="remittanceDetailsSection" 
      rendered="#{(taxheadDirectDebit.accountFinancialInfo.registration.type != 'PREM') or (taxheadDirectDebit.accountFinancialInfo.registration.type != 'VAT')}"> 


      <!-- Remittance Details --> 
      <fieldset><legend class="sub"> <h:outputText 
       value="#{msg['remittanceDetails.title']}" /> </legend> 

      <!-- Estimated Liability --> 
      <div class="field"> 
      <div class="label"><label for="allocatedAmount"><h:outputText 
       for="estimatedLiability" 
       value="#{msg['remittanceDetails.estimatedLiability']}" /> </label><span 
       class="requiredFlag">*</span></div> 
      <div class="error"> 
       <rich:message styleClass="errorText" for="estimatedLiability" /> 
      </div> 
      <div class="input"> 
       <h:inputText id="estimatedLiability" size="30" 
       maxlength="11" label="#{msg['registerContractPage1.subTaxNumber']}" 
       value="#{taxheadDirectDebit.estimatedLiability}"> 
       <a4j:ajax event="change" render="remittanceFrequency" /> 
       </h:inputText> 
      </div> 

      <br class="clear" /> 

      </div> 

      <!-- Is Seasonal --> 
      <div class="field"> 
      <div class="label"><label for="isSeasonal"> <h:outputText 
       for="isSeasonal" 
       value="#{msg['remittanceDetails.isTheNatureSeasonal']}" /> </label><span 
       class="requiredFlag">*</span></div> 
      <div class="error"><rich:message styleClass="errorText" 
       for="isSeasonal" /></div> 
      <div class="input"><h:selectOneRadio id="isSeasonal" 
       label="#{msg['remittanceDetails.isTheNatureSeasonal']}" 
       value="#{taxheadDirectDebit.isSeasonal}" 
       styleClass="radioLabelTop"> 
       <ddo:twoOptionSelection /> 
      <a4j:ajax event="click" render="remittanceFrequency" /> 
      </h:selectOneRadio></div> 

      <br class="clear" /> 

      </div> 

      </fieldset> 

     </a4j:region> 

     <!-- Remittance Frequency --> 
     <a4j:outputPanel id="remittanceFrequency"> 

     <div class="field"> 
      <div class="label"><label for="allocatedAmount"><h:outputText 
       for="estimatedLiability" 
       value="#{msg['remittanceDetails.estimatedLiability']}" /> </label><span 
       class="requiredFlag">*</span></div> 
      <div class="error"> 
       <rich:message styleClass="errorText" for="estimatedLiability" /> 
      </div> 
      <div class="input"> 
       <h:inputText id="estimatedLiability" size="30" 
       maxlength="11" label="#{msg['registerContractPage1.subTaxNumber']}" 
       value="#{taxheadDirectDebit.estimatedLiability}"> 
       <a4j:ajax event="change" render=":remittanceDetails:mandates:remittanceFrequency" /> 
       </h:inputText> 
      </div> 

      <br class="clear" /> 

      </div> 

      <fieldset><legend class="sub"> <h:outputText 
       value="#{msg['remittanceDetails.frequency']}" /> </legend> 

      <!-- Amount to be Debited --> 
      <div class="field"> 
      <div class="label"><label for="amountEachMonth"><h:outputText 
       for="amountEachMonth" 
       value="#{msg['remittanceDetails.amountToBeDebited']}" /> </label></div> 
      <div class="error"><rich:message styleClass="errorText" 
       for="amountEachMonth" /></div> 
      <div class="input"><h:inputText id="amountEachMonth" size="30" readOnly="true" 
       maxlength="8" label="#{msg['remittanceDetails.amountToBeDebited']}" 
       value="#{mandate.remittanceDetails.amountEachMonth}"> 
       <a4j:ajax event="change" render="remittanceFrequencyNoDebitedEachMonth"/> 
      </h:inputText></div> 
      <br class="clear" /> 
      </div> 

      <a4j:outputPanel id="remittanceFrequencyNoDebitedEachMonth"> 
      <!-- Months --> 
      <div class="field"> 
       <div class="grid1"><h:outputText 
        value="&#160;" />&#160; 
       </div> 
       <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}"> 
        <div class="grid2"><div align="center"> 
         <h:outputText value="#{msg['reviewDetails.reduce']}"/><div align="center"></div> 
        </div></div> 
       </rich:panel> 
       <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.action == 'AMEND'}"> 
        <div class="grid3"> 
         <div align="center"> 
          <h:outputText value="#{msg['reviewDetails.suspend']}"/><div align="center"></div> 
         </div> 
        </div> 
       </rich:panel> 
       <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}"> 
        <div class="grid2"> 
         <div align="center"> 
          <h:outputText value="#{msg['reviewDetails.exclude']}"/><div align="center"></div> 
         </div> 
        </div> 
       </rich:panel> 
      <br class="clear" /> 

      <div class="floatleft"> 

        <div class="row3"> 
         <div class="row1"> 

         <!-- January --> 
          <!-- Months Column --> 
          <div class="grid1"> 
           <label> 
            <h:outputText readOnly="true" disabled="true" size="4" value="#{msg['calendar.month.0']}" /> 
           </label> 
          </div> 
          <!-- Reduce check box --> 
          <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}"> 
           <div class="grid2"> 
            <div align="center"> 
             <h:selectBooleanCheckbox 
              id="reduce12" 
              value="#{mandate.remittanceDetails.remittanceFrequencys[0].reduce}" 
              disabled="#{mandate.remittanceDetails.remittanceFrequencys[0].exclude}"> 
              <a4j:ajax event="click" render="remittanceFrequency" /> 
             </h:selectBooleanCheckbox> 
            </div> 
           </div> 
          </rich:panel> 
          <!-- Suspend check box --> 
          <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal != 1}"> 
           <div class="grid2hidden"> 
            <h:outputText value="&#160;" /> 
           </div> 
          </rich:panel> 
          <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.action == 'AMEND'}"> 
           <div class="grid3"> 
            <div align="center"> 
            <h:selectBooleanCheckbox 
             id="suspend0" 
             value="#{mandate.remittanceDetails.remittanceFrequencys[0].suspend}"> 
             <a4j:ajax event="change" /> 
            </h:selectBooleanCheckbox> 
            </div> 
           </div> 
          </rich:panel> 
          <!-- Exclude check box --> 
          <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal == 1}"> 
           <div class="grid2"> 
            <div align="center"> 
            <h:selectBooleanCheckbox 
             id="exclude0" 
             value="#{mandate.remittanceDetails.remittanceFrequencys[0].exclude}" 
             disabled="#{mandate.remittanceDetails.remittanceFrequencys[0].reduce}"> 
             <a4j:ajax event="change" render="remittanceFrequency" /> 
            </h:selectBooleanCheckbox> 
            </div> 
           </div> 
          </rich:panel> 
          <rich:panel styleClass="ddo-panel" rendered="#{taxheadDirectDebit.isSeasonal != 1}"> 
           <div class="grid2hidden"> 
            <h:outputText value="&#160;" /> 
           </div> 
          </rich:panel> 
          <div class="errorRemittance"> 
           <rich:message styleClass="errorText" for="remittanceAmount0"/> 
          </div> 
          <!-- Monthly Amount field --> 
          <div class="grid5"> 
           <h:inputText 
            id="remittanceAmount0" size="30" maxlength="8" readOnly="true" 
            value="#{mandate.remittanceDetails.remittanceFrequencys[0].amount}" 
            disabled="#{!mandate.remittanceDetails.remittanceFrequencys[0].reduce}" 
            label="#{msg['remittanceDetails.amountToBeDebited']}"> 
            <a4j:ajax event="change" render="remittanceFrequency" /> 
           </h:inputText> 
          </div> 
         </div> 
        </div> 

       <div class="errorText" font="bold"> 
        <rich:message styleClass="errorTextNoPadding" for="continue"/> 
       </div> 
       </div> 

       </div> 
       </a4j:outputPanel> 
       </fieldset> 
      </a4j:outputPanel> 

      <rich:message> 
       <rich:message for="remittanceFrequency" ajaxRendered="true" /> 
      </rich:message> 

     </ui:repeat> 

나는 많은 코드를 여기에서 가져 왔으므로 macthed divs 등이있을 수 있지만 아이디어는 거기에 있습니다.

  • 당신은 몇 가지 구성 요소가 ID를 기반으로 다른 구성 요소를 렌더링 변경 이벤트를 볼 수 있습니다

    나는 두 가지 문제가있다. 이들은 반복 안에서 작동하지 않습니다.

  • 웹 플로우를 사용하고 메시지 컨텍스트에 메시지를 추가하여 메시지 태그가 유효성 검증 메시지를 표시 할 수 있지만 반복에서도 작동하지 않습니다.

나는 tr : iterator, c : forEach, a4j : repeat, tr : forEach를 시도했다. 나는 내가하려고하는 것이 가능하지 않다는 것을 확신한다. 비슷한 것을 성취하려고 노력한 경험이 있다면 도움이 될만한 가치가있다. 내가 사용하고 있지만 아마 jQuery를 사용할 수있는 MVC 프레임 워크를 변경할 수는 없습니다.

답변

0

나는 ajax 영역을 반복 외부로 이동시키고 전체 영역에서 렌더링을 호출함으로써이를 해결했습니다. 내가 알 수있는 가장 아름다운 해결책은 아는 것이 아니라 내가 찾던 가장 빠른 해결책입니다.

메시지 앞면에서 나는 단순히 메시지에 반복되는 목록의 항목 색인을 추가합니다.

"remittanceDetails:mandates:"+taxhead.getMandates().indexOF(mandate)+":remittanceAmount" + frequency.getMonth().getCode() 

나머지는 JSF가 처리합니다.