0 Replies Latest reply on May 7, 2010 4:29 AM by phlebiac

    FindComponent in ExtendedDataTable

      Hello folks,

       

      I am currently trying to highlight all UIInput elements that have a validation issue during form processing.

       

      I implemented a PhaseListener following this example : http://balusc.blogspot.com/2007/12/set-focus-in-jsf.html

       

      My implementation:

       

      {code}

      public void beforePhase(PhaseEvent event) {

           FacesContext facesContext = event.getFacesContext();

           String focus = null;

      // Iterate over all client ID's with  messages.

       

           Iterator<String> clientIdsWithMessages =  facesContext.getClientIdsWithMessages();

           List<String> l = new ArrayList<String>();

                while (clientIdsWithMessages.hasNext()) {

                     String clientIdWithMessages = clientIdsWithMessages.next();

                     l.add(clientIdWithMessages);

                     if (focus == null) {

                          focus = clientIdWithMessages;

                     }

       

                     if  (facesContext.getViewRoot().findComponent(clientIdWithMessages)  instanceof UIInput) {

                          UIInput input = (UIInput) facesContext.getViewRoot().findComponent(clientIdWithMessages);

       

                          input.getAttributes()
                               .put("styleClass", "highlight");

                     }

                }

                facesContext.getExternalContext().getRequestMap().put("focus",  focus);

      }

      {code}

       

      This works for nearly all my Input Elements but for those defined in Columns of rich:extendedDataTable:

       

       

      {code:xml}

      <rich:extendedDataTable

           value="#{controller.detailsDataModel}" var="item"

           width="100%" height="220px" enableContextMenu="false"

           sortMode="single" selectionMode="single"

           binding="#{controller.detailsDataTable}"

           id="tableTransportDetails"

           selection="#{controller.detailsSelection}"

           rows="5">

           <rich:column id="colTransportSelect" width="20%"

                label="#{msgs.labelTransportUnitCode_a}">

                <f:facet name="header">

                     <h:outputText value="#{msgs.labelCode_a}" />
                </f:facet>

                <h:selectOneMenu style="width:100%;"

                     styleClass="inputRequired"

                     valueChangeListener="#{movementController.valueChangeResetStyleClassRequired}"

                     id="transportUnitCodeSelect"

                     value="#{item.transportUnitCode}">

       

                     <f:selectItems

                          value="#{codeListController.currentCodeListC0035}" />

                          <f:validator validatorId="codeListSelectionValidator" />

                          <a4j:support event="onchange" ajaxSingle="true"/>

                </h:selectOneMenu>

       

           </rich:column>

           <rich:column width="20%" id="colIdOfTransportUnits"

                label="#{msgs.labelIdentityOfTransportUnits_b}">

                     <f:facet name="header">

                          <h:outputText value="#{msgs.labelIdentityOfTransportUnits_b}" />

                     </f:facet>

                     <h:inputText style="width:100%;"

                          styleClass="inputRequired"

                          valueChangeListener="#{movementController.valueChangeResetStyleClassRequired}"

                          id="identityOfTransportUnits"

                          value="#{item.identityOfTransportUnits}">

                     <a4j:support event="onblur" ajaxSingle="true"/>
                     </h:inputText>
           </rich:column>
      {code}

       

      What do I have to do, to access a single element inside an extendedDataTable row?

       

      Any help is much appreciated.

      I am using Richfaces 3.3.3 final