1 2 Previous Next 18 Replies Latest reply on Apr 3, 2009 10:43 AM by Jeremy Goodell

    <a4j:support> not working

    Jeremy Goodell Newbie

      I am trying to do live validation as specified in Seam in Action. I am just trying it on one field at the moment. The field is a shortName String field that I've set up with Hibernate validation annotations to be non null and between 2 and 32 characters in length.

      If you want to go straight to the generated html, scroll down to the bottom of this message. I've included the relevant snippet and pastebin'ed the rest.

      The validation works when I submit the form (see the screenshot below), but IT DOES NOT WORK when the field loses focus. Firefox Web Developerreports no JavaScript errors when I enter, edit, or exit the field, or when I submit the form. There are only some css warnings in the error console.


      Here's a snippet from the view:

      <s:decorate id="shortNameField" template="edit.xhtml">
       <ui:define name="label">Short Name</ui:define>
       <h:inputText styleClass="inField" id="shortName" value="#{editCoupon.shortName}"
       style="width: 180px;" required="true">
       <a4j:support id="shortNameCheck" event="onblur" reRender="shortName"
       ajaxSingle="true" bypassUpdates="true"/>

      Here's the edit template in its entirety
      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       <div class="label #{invalid ? 'errors' : ''}">
       <s:span><ui:insert name="label"/></s:span>
       <s:span styleClass="required" rendered="#{required}">*</s:span>
       <ui:insert styleClass="value #{invalid ? 'errors' : ''}"/>
       <span class="error">
       <h:graphicImage value="/img/error.gif"
       rendered="#{invalid}" styleClass="errors"/>
       <s:message styleClass="errors"/>

      and here's a snippet from the entity bean
      public class Coupon implements Serializable {
       private Long id;
       private String shortName;
       public Long getId() {
       return id;
       public void setId(Long id) {
       this.id = id;
       @Length(min=2, max=32)
       public String getShortName() {
       return shortName;
       public void setShortName(String shortName) {
       this.shortName = shortName;
       public void destroy() {}

      Here is the HTML source snippet showing the AJAX onblur code. I inserted some line breaks and indentation to make it readable.
       <input id="contentForm:shortNameField:shortName"
       type="text" name="contentForm:shortNameField:shortName"
       value="Buy a taco, get a taco" class="inField"
       'contentForm:shortNameField:shortNameCheck':'contentForm:shortNameField:shortNameCheck'} ,
       'actionUrl':'/rCMS/editCoupon.seam','control':this} )"
       style="width: 180px;" />

      The entire generated HTML source can be seen here: http://pastebin.com/m1dc1eb56

      Thanks again,
      Jeremy Goodell

        1 2 Previous Next