0 Replies Latest reply on Jul 2, 2010 9:03 AM by Jurij Lender

    custom field validator and bypassUpdates in a:support

    Jurij Lender Newbie
      Hi,

      i have written a voi custum validation method which adds a facesMessage to the field on validation failure. however, the current field value is not submitted to the bean.
      maybe this is because i have been using bypassUpdates\=true. since i am calling a validation method i don't want to update the model when the method is invoked. how can i solve this issue for a custom field validation?

      view:
      <s:decorate id="username" template="../layout/edit.xhtml">
              <ui:define name="label">Username:</ui:define>
              <h:inputText id="usernameInput" value="#{userList.selectedUser.username}" required="true">
              <a:support
                              reRender="username"
                              bypassUpdates="true"
                              ajaxSingle="true"
                              event="onblur"
                      actionListener="#{userList.validateUsername()}">
                      <s:conversationId />
              </a:support>
              </h:inputText>
      </s:decorate>


      method:

              public void validateUsername() {
                      log.info(selectedUser.getUsername());
                      if(userHome.byUserName(selectedUser.getUsername()) != null) {
                              facesMessages.addToControl("usernameInput", "User already exists");
                      }
              }

      sorry for not having used code formating - somehow the backticks did not work.