0 Replies Latest reply on Aug 12, 2008 11:43 PM by darthmaul

    Ajax Form Validation Alongside Custom Converter

    darthmaul

      I am doing JSF form validation precisely in the manner described in the Seam documentation, and things are working just fine for all but one case where I am using a custom converter.


      Here is the Facelet snippet:


      <s:decorate id="paymentDecoration" template="../templates/fieldValidation.jspx">
            <ui:define name="labelText">Amount</ui:define>
            <ui:define name="formField">
               <h:inputText value="#{payment.amount}"
                            id="amountBox"
                            required="true"
                            tabindex="1" accesskey="N">
                  <a4j:support event="onblur" reRender="paymentDecoration" bypassUpdates="true"/>
               </h:inputText>
            </ui:define>
      </s:decorate>
      



      Here is the Hibernate Validator annotation on the entity:


      @Column(name = "AMOUNT", nullable = true)
      @Digits(integerDigits = 10, fractionalDigits = 2, message = "#{messages['currency.invalid.format']}")
      public BigDecimal getAmount() {
            return amount;
      }
      



      Finally, I wrote a custom converter to BigDecimal:


      @Name("bigDecimalConverter")
      @Converter(forClass = BigDecimal.class)
      public class BigDecimalConverter extends NumberConverter {
      .
      .
      .
      }
      



      The problem is that the converter does its work before the @Digits validation takes hold, so my converter throws a ParseException when I pass in bad values like g.


      I would appreciate any insight into how to approach this scenario.


      Thanks.