title: Spring-roo ajax dojo/jquery input
body: <p>I have a spring-roo application that I need to use ajax with, be it dojo or jquery. On my create page I need one of the input fields to be dynamic (typing text into one field populates the same text in another field). Roo uses dojo by default to validated these input fields. I've attempted to use jquery to handle this but so far I haven't been able to get the values from the field</p>
  
  <p>Create.jsp</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  &lt;![CDATA[
  $().ready(
           function() {
               $("#c_com_my_event_object_id_case").keypress(function() {
                   var str= $(this).val();
                       console.log(str);
                  });
               });
   ]]&gt;
              &lt;/script&gt;
      &lt;form:create id="fc_com_my_event_object" modelAttribute="object" path="/objects" render="${empty dependencies}" z="user-defined"&gt;
          &lt;field:input readonly="false" disableFormBinding="true" field="id.case" id="c_com_my_event_object_id_case" required="true" z="user-defined"/&gt;
          &lt;field:input readonly="false" disableFormBinding="true" field="id.version" id="c_com_my_event_object_id_version" z="user-defined"/&gt;
          &lt;field:input readonly="false" field="path" id="c_com_my_event_object_path" z="user-defined"/&gt;
          &lt;field:input readonly="false" field="target" id="c_com_my_event_object_target" z="user-defined"/&gt;   
      &lt;/form:create&gt;
  </code></pre>
  
  <p>The javascript console from the above script logs "undefined"</p>
  
  <p>My input.tag</p>
  
  <pre><code>    &lt;jsp:root xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:fn="http://java.sun.com/jsp/jstl/functions" xmlns:spring="http://www.springframework.org/tags" xmlns:form="http://www.springframework.org/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"&gt;
    &lt;jsp:output omit-xml-declaration="yes" /&gt;
  
    &lt;jsp:directive.attribute name="id" type="java.lang.String" required="true" rtexprvalue="true" description="The identifier for this tag (do not change!)" /&gt;
    &lt;jsp:directive.attribute name="field" type="java.lang.String" required="true" rtexprvalue="true" description="The field exposed from the form backing object" /&gt;
    &lt;jsp:directive.attribute name="label" type="java.lang.String" required="false" rtexprvalue="true" description="The label used for this field, will default to a message bundle if not supplied" /&gt;
    &lt;jsp:directive.attribute name="labelCode" type="java.lang.String" required="false" rtexprvalue="true" description="Key for label message bundle if label is not supplied" /&gt;
    &lt;jsp:directive.attribute name="required" type="java.lang.Boolean" required="false" rtexprvalue="true" description="Indicates if this field is required (default false)" /&gt;
    &lt;jsp:directive.attribute name="disabled" type="java.lang.Boolean" required="false" rtexprvalue="true" description="Specify if this field should be enabled" /&gt;
    &lt;jsp:directive.attribute name="validationRegex" type="java.lang.String" required="false" rtexprvalue="true" description="Specify regular expression to be used for the validation of the input contents" /&gt;
    &lt;jsp:directive.attribute name="validationMessageCode" type="java.lang.String" required="false" rtexprvalue="true" description="Specify the message (message property code) to be displayed if the regular expression validation fails" /&gt;
    &lt;jsp:directive.attribute name="validationMessage" type="java.lang.String" required="false" rtexprvalue="true" description="Specify the message to be displayed if the regular expression validation fails" /&gt;
    &lt;jsp:directive.attribute name="min" type="java.lang.String" required="false" rtexprvalue="true" description="Specify the minimum length of the input contents" /&gt;
    &lt;jsp:directive.attribute name="max" type="java.lang.String" required="false" rtexprvalue="true" description="Specify the maximum length of the input contents" /&gt;
    &lt;jsp:directive.attribute name="decimalMin" type="java.lang.String" required="false" rtexprvalue="true" description="Specify the minimum size of the input contents" /&gt;
    &lt;jsp:directive.attribute name="decimalMax" type="java.lang.String" required="false" rtexprvalue="true" description="Specify the maximum size of the input contents" /&gt;
    &lt;jsp:directive.attribute name="disableFormBinding" type="java.lang.Boolean" required="false" rtexprvalue="true" description="Set to true to disable Spring form binding" /&gt;
    &lt;jsp:directive.attribute name="type" type="java.lang.String" required="false" rtexprvalue="true" description="Set field type (default 'text', or 'password')" /&gt;
    &lt;jsp:directive.attribute name="render" type="java.lang.Boolean" required="false" rtexprvalue="true" description="Indicate if the contents of this tag and all enclosed tags should be rendered (default 'true')" /&gt;
  
    &lt;jsp:directive.attribute name="readonly" type="java.lang.Boolean" required="false" rtexprvalue="true" description="Specify if this field should be readonly" /&gt;
  
    &lt;jsp:directive.attribute name="z" type="java.lang.String" required="false" description="Used for checking if element has been modified (to recalculate simply provide empty string value)" /&gt;
  
  
    &lt;c:if test="${empty render or render}"&gt;
  
      &lt;c:if test="${empty type}"&gt;
        &lt;c:set value="text" var="type" /&gt;
      &lt;/c:if&gt;
  
      &lt;c:if test="${empty readonly}"&gt;
      &lt;c:set value="false" var="readonly"/&gt;
      &lt;/c:if&gt;
  
  
      &lt;c:if test="${empty disabled}"&gt;
        &lt;c:set value="false" var="disabled" /&gt;
      &lt;/c:if&gt;
  
      &lt;c:if test="${empty label}"&gt;
        &lt;c:if test="${empty labelCode}"&gt;
          &lt;c:set var="labelCode" value="${fn:substringAfter(id,'_')}" /&gt;
        &lt;/c:if&gt;
        &lt;spring:message code="label_${fn:toLowerCase(labelCode)}" var="label" htmlEscape="false" /&gt;
      &lt;/c:if&gt;
  
      &lt;c:if test="${empty validationMessage}"&gt;
        &lt;c:choose&gt;
          &lt;c:when test="${empty validationMessageCode}"&gt;
            &lt;spring:message arguments="${fn:escapeXml(label)}" code="field_invalid" var="field_invalid" htmlEscape="false" /&gt;
          &lt;/c:when&gt;
          &lt;c:otherwise&gt;
            &lt;spring:message arguments="${fn:escapeXml(label)}" code="${validationMessageCode}" var="field_invalid" htmlEscape="false" /&gt;
          &lt;/c:otherwise&gt;
        &lt;/c:choose&gt;
      &lt;/c:if&gt;
  
      &lt;c:if test="${empty required}"&gt;
        &lt;c:set value="false" var="required" /&gt;
      &lt;/c:if&gt;
  
      &lt;c:set var="sec_field"&gt;
        &lt;spring:escapeBody javaScriptEscape="true" &gt;${field}&lt;/spring:escapeBody&gt;
      &lt;/c:set&gt;
  
      &lt;div id="_${fn:escapeXml(id)}_id"&gt;
        &lt;label for="_${sec_field}_id"&gt;
          &lt;c:out value="${fn:escapeXml(label)}" /&gt;
          :
        &lt;/label&gt;
        &lt;c:choose&gt;
          &lt;c:when test="${disableFormBinding}"&gt;
            &lt;input id="_${sec_field}_id" name="${sec_field}" type="${fn:escapeXml(type)}" /&gt;
          &lt;/c:when&gt;
          &lt;c:otherwise&gt;
            &lt;c:choose&gt;
              &lt;c:when test="${type eq 'password'}"&gt;
                &lt;form:password id="_${sec_field}_id" path="${sec_field}" disabled="${disabled}" /&gt;
              &lt;/c:when&gt;
              &lt;c:otherwise&gt;
              &lt;c:choose&gt;
                              &lt;c:when test="${readonly eq true}"&gt;
                                  &lt;form:input disabled="${disabled}" id="_${sec_field}_id"
                                      path="${sec_field}" readonly="${readonly}"&gt;&lt;/form:input&gt;
                              &lt;/c:when&gt;
                              &lt;c:otherwise&gt;
  &lt;form:input disabled="${disabled}" id="_${sec_field}_id" path="${sec_field}"&gt;&lt;/form:input&gt;
  &lt;/c:otherwise&gt;
  
  
                          &lt;/c:choose&gt;
                          &lt;/c:otherwise&gt;
  
            &lt;/c:choose&gt;
            &lt;br/&gt;
            &lt;form:errors cssClass="errors" id="_${sec_field}_error_id" path="${sec_field}" /&gt;
          &lt;/c:otherwise&gt;
        &lt;/c:choose&gt;
        &lt;c:choose&gt;
          &lt;c:when test="${required}"&gt;
            &lt;spring:message code="field_required" var="field_required" htmlEscape="false" /&gt;
            &lt;spring:message argumentSeparator="," arguments="${label},(${field_required})" code="field_simple_validation" var="field_validation" htmlEscape="false" /&gt;
          &lt;/c:when&gt;
          &lt;c:otherwise&gt;
            &lt;spring:message argumentSeparator="," arguments="${label}, " code="field_simple_validation" var="field_validation" htmlEscape="false" /&gt;
          &lt;/c:otherwise&gt;
        &lt;/c:choose&gt;
        &lt;c:set var="sec_field_validation"&gt;
          &lt;spring:escapeBody javaScriptEscape="true"&gt;${field_validation}&lt;/spring:escapeBody&gt;
        &lt;/c:set&gt;
        &lt;c:set var="sec_field_invalid"&gt;
          &lt;spring:escapeBody javaScriptEscape="true" htmlEscape="true"&gt;${field_invalid}&lt;/spring:escapeBody&gt;
        &lt;/c:set&gt;
        &lt;c:set var="sec_field_required"&gt;
          &lt;spring:escapeBody javaScriptEscape="true"&gt;${field_required}&lt;/spring:escapeBody&gt;
        &lt;/c:set&gt;
        &lt;c:set var="sec_validation_regex" value="" /&gt;
        &lt;c:if test="${!empty validationRegex}"&gt;
          &lt;c:set var="sec_validation_regex" value="regExp : '${validationRegex}', " /&gt;
        &lt;/c:if&gt;
        &lt;script type="text/javascript"&gt;
          Spring.addDecoration(new Spring.ElementDecoration({elementId : '_${sec_field}_id', widgetType : 'dijit.form.ValidationTextBox', widgetAttrs : {promptMessage: '${sec_field_validation}', invalidMessage: '${sec_field_invalid}', required : ${required}, ${sec_validation_regex} missingMessage : '${sec_field_required}' }})); 
        &lt;/script&gt;
      &lt;/div&gt;
      &lt;br /&gt;
    &lt;/c:if&gt;
  &lt;/jsp:root&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>