Announcement Announcement Module
Collapse
No announcement yet.
SWF Inventory of Javascript examples Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SWF Inventory of Javascript examples

    Below is a complete inventory of the provided SWF examples of usage of Dojo via Spring Javascript. Removed from the list below are duplicate examples. Note that only one provided SWF sample project contains any examples of Spring Javascript. That project is:
    spring-webflow-2.0.1.RELEASE\projects\spring-webflow-samples\booking-mvc

    bookingForm.jsp contains these Spring Javascript examples. (Only one of each representative type is shown below for this and all that follow):

    <div class="input">
    <form:input path="checkinDate"/>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : "checkinDate",
    widgetType : "dijit.form.DateTextBox",
    widgetAttrs : { value : dojo.date.locale.parse(dojo.byId("checkinDate").va lue, {selector : "date", datePattern : "yyyy-MM-dd"}), required : true }}));
    </script>
    </div>
    <div id="radio" class="input">
    <form:radiobutton id="smoking" path="smoking" label="Smoking" value="true"/>
    <form:radiobutton id="non-smoking" path="smoking" label="Non Smoking" value="false"/>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : 'smoking',
    widgetType : "dijit.form.RadioButton",
    widgetModule : "dijit.form.CheckBox",
    widgetAttrs : { value : true }));
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : 'non-smoking',
    widgetType : "dijit.form.RadioButton",
    widgetModule : "dijit.form.CheckBox",
    widgetAttrs : { value : false }));
    </script>

    </div>
    <div class="input">
    <form:input path="creditCard"/>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : "creditCard",
    widgetType : "dijit.form.ValidationTextBox",
    widgetAttrs : { required : true, invalidMessage : "A 16-digit credit card number is required.",
    regExp : "[0-9]{16}" }}));
    </script>
    </div>
    <div class="input">
    <form:input path="creditCardName" maxlength="40"/>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : "creditCardName",
    widgetType : "dijit.form.ValidationTextBox",
    widgetAttrs : { required : true }}));
    </script>
    </div>

    <input type="submit" id="proceed" name="_eventId_proceed" value="Proceed"
    onclick="Spring.remoting.submitForm('proceed', 'booking', {fragments:'messages,bookingForm'}); return false;"/>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ValidateAllDecoration({elementId:'proceed', event:'onclick'}));
    </script>
    bookingsTable.jsp contains these Spring Javascript examples. (Only one of each representative type is shown below for this and all that follow):

    <a id="cancelLink_${booking.id}" href="deleteBooking?id=${booking.id}">Cancel</a>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.AjaxEventDecoration({
    elementId:"cancelLink_${booking.id}",
    event:"onclick",
    params: {fragments:"bookingsTable"}
    }));
    </script>
    hotelSearchForm.jsp contains these Spring Javascript examples. (Only one of each representative type is shown below for this and all that follow):

    <div class="input">
    <form:input id="searchString" path="searchString"/>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : "searchString",
    widgetType : "dijit.form.ValidationTextBox",
    widgetAttrs : { promptMessage : "Search hotels by name, address, city, or zip." }}));
    </script>
    </div>
    login.jsp contains these Spring Javascript examples. (Only one of each representative type is shown below for this and all that follow):

    <div class="output">
    <input type="checkbox" name="_spring_security_remember_me" id="remember_me" />
    <script type="text/javascript">
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : "remember_me",
    widgetType : "dijit.form.CheckBox"}));
    </script>
    </div>
    search.jsp contains these Spring Javascript examples. (Only one of each representative type is shown below for this and all that follow):

    <a id="changeSearchLink" href="index?searchString=${searchCriteria.searchSt ring}&pageSize=${searchCriteria.pageSize}">Change Search</a>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.AjaxEventDecoration({
    elementId: "changeSearchLink",
    event: "onclick",
    popup: true,
    params: {fragments: "hotelSearchForm"}
    }));
    </script>
    <a id="prevResultsLink" href="search?searchString=${searchCriteria.searchS tring}&pageSize=${searchCriteria.pageSize}&page=${ searchCriteria.page - 1}">Previous Results</a>
    <script type="text/javascript">
    Spring.addDecoration(new Spring.AjaxEventDecoration({
    elementId: "prevResultsLink",
    event: "onclick",
    params: {fragments: "body"}
    }));
    </script>
    I feel it would be a tremendous help to the SWF community if more examples of Spring Javascript usage can be devised and propagated throughout the Spring community! For example, needed immediately is an example of how to use Spring Javascript to set the focus on a control (usually a textbox) when a form is initially displayed.

  • #2
    I would like to see more Dojo widget examples using spring faces tag library as well for JSF users.

    Comment


    • #3
      I have pasted below a Dojo code example I created, which took me about six hours to get to work. I actually use this in a production program. It demonstrates a dojo widget which I think is the most popular type and which, so far, is not represented in any SWF example program. Here 'tis:
      <table align="center" border=0>
      <tr><td>This is a list of <fmt:formatNumber type="number" value="${listOfAllNotSubscribedLotusNotesEmailAddr esses_size}" />
      Lotus Notes emails that are not subscribed to Friday News.
      To select Lotus Notes email to subscribe from Friday News, begin by typing the first letter of the
      last name, typing additional letter to narrow the choices. Finally, click the "Subscribe" button.
      <br><br></td></tr>
      <tr><td align="center" >
      <form name="formGoToAdmEmailInternalNew"
      id="formGoToAdmEmailInternalNew"
      method="post"
      action="admEmailInternalNew.controller">

      <select id="idNewsSubscribeEmail" name="idNewsSubscribeEmail" autocomplete="false" >
      <option> </option>
      <c:forEach items="${listOfAllNotSubscribedLotusNotesEmailAddr esses}" var="newsSubscribeEmail" varStatus="varStatus_lnse">
      <option value="${newsSubscribeEmail.idNewsSubscribeEmail}" >${newsSubscribeEmail.lastNameFirstName}</option>
      </c:forEach>
      </select>
      <script type="text/javascript">
      Spring.addDecoration(new Spring.ElementDecoration({
      elementId : "idNewsSubscribeEmail",
      widgetType : "dijit.form.FilteringSelect",
      widgetAttrs : { hasDownArrow : false, ignoreCase : true, pageSize: 20, autoComplete : false }}));
      </script>
      <script type="text/javascript">
      dojo.addOnLoad(
      function(){
      dijit.byId("idNewsSubscribeEmail").focus();
      }
      );
      </script>

      </td></tr>

      <tr>
      <td align="center" ><br>
      <table width="100%">
      <tr>
      <td align="center">
      <input type="image" src="images/btnreset.gif" id="resetNewInternalEmail"
      onclick="document.formGoToAdmEmailInternalNew.rese t();dijit.byId('idNewsSubscribeEmail').focus();ret urn false;"
      value="Add" />
      <td>
      <td align="center">
      <input type="image" src="images/btnSubscribe.gif" id="submitNewInternalEmail"
      onclick="return validateTheForm(this)"
      value="Add" />
      <script type="text/javascript">
      function validateTheForm(f) {
      var userToSubscribe = dijit.byId("idNewsSubscribeEmail").getValue();
      if ('null'==userToSubscribe || undefined==userToSubscribe || null===userToSubscribe || null==userToSubscribe || ''==userToSubscribe) {
      alert('Please select a Friday News Lotus Notes email user to be Subscribed.');
      dijit.byId('idNewsSubscribeEmail').focus();
      return false;
      }
      var confAnswer = confirm('Subscribe ' + userToSubscribe + ' to Friday News?');
      if (confAnswer) {
      return true;
      }
      dijit.byId('idNewsSubscribeEmail').focus()
      return false;
      }
      </script>

      <td>
      </tr>
      </table>

      Comment


      • #4
        Dojo TabContainer usage example

        Here is an example of using a Dojo tab container widget. This can be pasted directly into a jsp page in swf-booking-mvc sample app.

        Code:
           	<div id="mainTabContainer" 
                style="width:500px;height:100px">
        		<div id="tab1">
        			First tab content is here.
        		</div>
        		<script type="text/javascript">
        			Spring.addDecoration(new Spring.ElementDecoration({
        				elementId : "tab1",
        				widgetType : "dijit.layout.ContentPane",
        				widgetAttrs : { title: "First Tab" },
        				}));
        		</script>
        		<div id="tab2">
        			Second tab content is here.
        		</div>
        		<script type="text/javascript">
        			Spring.addDecoration(new Spring.ElementDecoration({
        				elementId : "tab2",
        				widgetType : "dijit.layout.ContentPane",
        				widgetAttrs : { title: "Second Tab", selected : true, closable: true },
        				}));
        		</script>
        		<div id="tab3">
        			Third tab content is here.
        		</div>
        		<script type="text/javascript">
        			Spring.addDecoration(new Spring.ElementDecoration({
        			elementId : "tab3",
        			widgetType : "dijit.layout.ContentPane",
        			widgetAttrs : { title: "Third Tab"},
        			}));
        		</script>
        	</div>
        	<script type="text/javascript">
        		Spring.addDecoration(new Spring.ElementDecoration({
        			elementId : "mainTabContainer",
        			widgetType : "dijit.layout.TabContainer"}));
        	</script>

        Comment


        • #5
          How to use the Spring JS

          Hi ,
          My JSP is as below. When I click on the dummy , I am getting 'Spring' undefined error. I have the Spring 2.0 related all the jars in my /lib.
          How to solve this error ?

          Regards
          Diana


          <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
          I am in footer <a href = "addToCart.do?_flowId=addToCart" id="dummyId" >dummy</a>
          <script type="text/javascript">
          Spring.addDecoration(new Spring.AjaxEventDecoration({
          elementId:"dummyId",
          event:"onclick",
          params: {fragments:"body"}
          }));
          </script>

          Comment


          • #6
            RobertGloverJr

            I have pasted below a Dojo code example I created, which took me about six hours to get to work.
            Thanks so much for share your effort. little cumbersome in learn Dojo and then Integrate with Spring, I would agree about the amount of the code examples (more are need it), same idea about fragments maybe.

            It seems that when are talk about SWF 2.0 , Dojo get more attention

            Best Regards

            Comment


            • #7
              Originally posted by dianacharles View Post
              Hi ,
              My JSP is as below. When I click on the dummy , I am getting 'Spring' undefined error. I have the Spring 2.0 related all the jars in my /lib.
              How to solve this error ?
              Spring-js support is in Spring Web Flow 2.0 jars which in turn need Spring 2.5 jars or later to run (not Spring 2.0).

              HTH,
              Paul

              Comment


              • #8
                Good idea Robert. I'd like to see more examples and docs myself.

                It ain't much, but here's a dialog/popup box.

                Code:
                <div id="dialog1">
                	this is some dialog
                </div>
                
                <button id="showDialogBtn" onclick="dijit.byId('dialog1').show()">Show Dialog</button>
                
                <script type="text/javascript">
                	Spring.addDecoration(new Spring.ElementDecoration({
                		elementId : "dialog1",
                		widgetType : "dijit.Dialog"
                	}));
                </script>
                It does work, but I was unable to get the dojo styles applied to the button -- seems applying the style via the Spring.addDecoration() resets everything including the events... maybe onclick could be set after adding the decoration with something like this (but I didn't try it):

                Code:
                Spring.addDecoration(new Spring.ElementDecoration({
                	elementId : "showDialogBtn",
                	widgetType : "dijit.form.Button"
                }));
                
                <script type="text/javascript">
                    var e = document.getElementById('showDialogBtn');
                    e.onclick = function () {dijit.byId('dialog1').show();}
                </script>

                Comment


                • #9
                  Hi thank you all for your examples.

                  I have following code:
                  Code:
                  <div id="form">
                  	<form:form id="publicLoginForm" modelAttribute="publicLoginForm" method="post" action="j_spring_security_check">
                  		<fieldset>
                  			<form:input path="j_username" maxlength="50" size="50" title="Username"/>
                  			<form:errors path="j_username" />
                  			<c:if test="${status.error}">
                  				<c:out value="${status.errorMessage}"/>
                  			</c:if>
                  			<script type="text/javascript">
                  				Spring.addDecoration(
                  					new Spring.ElementDecoration({
                  						elementId : "j_username",
                  						widgetType : "dijit.form.ValidationTextBox",
                  						widgetAttrs : { 
                  							required : true,
                  							invalidMessage : "<spring:message code="public.account.login.username.error" />"
                  						}
                  					})
                  				);  
                  			</script><br>
                  			<form:input path="j_password" maxlength="255" size="50" title="Password"/>
                  			<form:errors path="j_password" />
                  			<script type="text/javascript">
                  				Spring.addDecoration(
                  					new Spring.ElementDecoration({
                  						elementId : "j_password",
                  						widgetType : "dijit.form.ValidationTextBox",
                  						widgetAttrs : { 
                  							required : true,
                  							invalidMessage : "<spring:message code="public.account.login.password.error" />"
                  						}
                  					})
                  				);  
                  			</script><br>
                  			<input type="submit" value="Login" style="color: black"/>
                  			<script type="text/javascript">
                  				Spring.addDecoration(new Spring.ValidateAllDecoration({
                  					elementId:'submit',
                  					event:'onclick'}));
                  				Spring.addDecoration(new Spring.AjaxEventDecoration({
                  					elementId:'submit',
                  					event:'onclick',
                  					formId:'publicLoginForm',
                  					params:{fragments:'error', 'form', 'header'}}));
                  			</script>
                  		</fieldset>
                  	</form:form>
                  </div>
                  It successfully shows required field message.
                  But how can I know if the form is valid when login button clicked. So if form required fields are empty it never submits the data. If form is valid it can submits the data.

                  Any ideas?
                  I'm newbie in spring-js.
                  Sorry for my bad english!

                  Comment


                  • #10
                    Originally posted by digz6666 View Post
                    Hi thank you all for your examples.
                    It successfully shows required field message.
                    But how can I know if the form is valid when login button clicked. So if form required fields are empty it never submits the data. If form is valid it can submits the data.

                    Any ideas?
                    I'm newbie in spring-js.
                    Sorry for my bad english!
                    Hi, I have to somewhat sheepishly admit that after spending a day on Spring/dojo and posting my results, I was forced by work requirements to move on to other subjects. I can just barely remember writing those posts which you refer to.
                    I'm finding that Spring has become so enormously complicated that it's no longer possible to keep up with all of it. I don't mean this in a bad way, but rather in a truthful way.
                    Day to day on the job, all I really need from Spring is an MVC simple form controller, Spring email, Spring iBatis, Spring Velocity, Spring Database, Spring Quartz, Spring Task scheduler, and similar, simple Spring things that have not changed all that much since Spring 1.x.
                    For example, I spent a lot of time carefully reading a book on Spring Web Flow version 1. By the time I'd finished the book, Spring Web Flow version 2 had come out. Despite my best efforts, I couldn't figure out from the Spring examples of Web Flow v2 how to get even a simple, trivial usage of it to work in a real application because the examples used every modern device imaginable (annotations, fancy new fangled controllers, etc.), and there were practically no comments in the example.
                    Similarly, the last time I checked the Spring documentation on Dojo integration was about 3 pages long.
                    So in summary, I really wish you well but I haven't had time to pursue the Spring/Dojo subject. There are too many competing areas and it's impossible to keep on top of everything.
                    Regards,
                    Robert

                    Comment


                    • #11
                      I think you need to give your submit button an "id" attribute and use that value for elementId in your ValidateAllDecoration:

                      Code:
                      			<input type="submit" id="blah" value="Login" style="color: black"/>
                      			<script type="text/javascript">
                      				Spring.addDecoration(new Spring.ValidateAllDecoration({
                      					elementId:'blah',
                      					event:'onclick'}));
                      				Spring.addDecoration(new Spring.AjaxEventDecoration({
                      					elementId:'submit',
                      					event:'onclick',
                      					formId:'publicLoginForm',
                      					params:{fragments:'error', 'form', 'header'}}));
                      			</script>

                      Comment


                      • #12
                        Originally posted by RobertGloverJr View Post
                        Hi, I have to somewhat sheepishly admit that after spending a day on Spring/dojo and posting my results, I was forced by work requirements to move on to other subjects. I can just barely remember writing those posts which you refer to.
                        I'm finding that Spring has become so enormously complicated that it's no longer possible to keep up with all of it. I don't mean this in a bad way, but rather in a truthful way.
                        Day to day on the job, all I really need from Spring is an MVC simple form controller, Spring email, Spring iBatis, Spring Velocity, Spring Database, Spring Quartz, Spring Task scheduler, and similar, simple Spring things that have not changed all that much since Spring 1.x.
                        For example, I spent a lot of time carefully reading a book on Spring Web Flow version 1. By the time I'd finished the book, Spring Web Flow version 2 had come out. Despite my best efforts, I couldn't figure out from the Spring examples of Web Flow v2 how to get even a simple, trivial usage of it to work in a real application because the examples used every modern device imaginable (annotations, fancy new fangled controllers, etc.), and there were practically no comments in the example.
                        Similarly, the last time I checked the Spring documentation on Dojo integration was about 3 pages long.
                        So in summary, I really wish you well but I haven't had time to pursue the Spring/Dojo subject. There are too many competing areas and it's impossible to keep on top of everything.
                        Regards,
                        Robert
                        Thank you anyway!
                        I've fixed my problem.

                        Here's the code:
                        Code:
                        <form:form id="publicLoginForm" modelAttribute="publicLoginForm" method="post" action="j_spring_security_check">
                        	<fieldset>
                        		<form:input path="j_username" maxlength="50" size="50" title="Username" />
                        		<form:errors path="j_username" />
                        		<c:if test="${status.error}">
                        			<c:out value="${status.errorMessage}"/>
                        		</c:if>
                        		<script type="text/javascript">
                        			Spring.addDecoration(
                        				new Spring.ElementDecoration({
                        					elementId : "j_username",
                        					widgetType : "dijit.form.ValidationTextBox",
                        					widgetAttrs : { 
                        						required : true,
                        						promptMessage : "<spring:message code="public.account.login.j_username.error" />",
                        						invalidMessage : "<spring:message code="public.account.login.j_username.error" />"
                        					}
                        				})
                        			);
                        		</script><br>
                        		<form:password path="j_password" maxlength="255" size="50" title="Password" />
                        		<form:errors path="j_password" />
                        		<script type="text/javascript">
                        			Spring.addDecoration(
                        				new Spring.ElementDecoration({
                        					elementId : "j_password",
                        					widgetType : "dijit.form.ValidationTextBox",
                        					widgetAttrs : { 
                        						required : true,
                        						promptMessage : "<spring:message code="public.account.login.j_password.error" />",
                        						invalidMessage : "<spring:message code="public.account.login.j_password.error" />"
                        					}
                        				})
                        			);
                        		</script><br>
                        		<script type="text/javascript">
                        			function checkForm() {
                        				if((dojo.byId('j_username')).value == '' || (dojo.byId('j_password')).value == '') {
                        					alert("u: " + (dojo.byId('j_username')).value + " p: " + (dojo.byId('j_password')).value);
                        					return false;
                        				} else {
                        					alert("u: " + (dojo.byId('j_username')).value + " p: " + (dojo.byId('j_password')).value);
                        					return true;
                        				}
                        			}
                        		</script>
                        		<input type="submit" value="Login" style="color: black" onclick="return checkForm();"/>
                        		<script type="text/javascript">
                        			Spring.addDecoration(new Spring.ValidateAllDecoration({
                        				elementId:'submit',
                        				event:'onclick'}));
                        			Spring.addDecoration(new Spring.AjaxEventDecoration({
                        				elementId:'submit',
                        				event:'onclick',
                        				formId:'publicLoginForm',
                        				params:{fragments:'error', 'form', 'header'}}));
                        		</script>
                        	</fieldset>
                        </form:form>
                        In this code I've called checkForm function from onclick event of submit and alerted the username and password.
                        Is there any better way?

                        I'm thinking of contributing to the documentation when I finish my project in July. (if no significant progress in the current documentation by July I'll contribute xD!)

                        I've got another problem.
                        How can I use custom text field validator like mentioned here.

                        I've written my code as follows but not working:
                        Code:
                        <form:form id="publicRegisterForm" modelAttribute="publicRegisterForm" method="post" action="${flowExecutionUrl}&_eventId=processRegister">
                        	<fieldset>
                        		<form:input path="userId" maxlength="50" size="50" title="Username"/>
                        		<form:errors path="userId" />
                        		<c:if test="${status.error}">
                        			<c:out value="${status.errorMessage}"/>
                        		</c:if>
                        		<script type="text/javascript">
                        			Spring.addDecoration(
                        				new Spring.ElementDecoration({
                        					elementId : "userId",
                        					widgetType : "dijit.form.ValidationTextBox",
                        					widgetAttrs : {
                        						required : true,
                        						promptMessage : "<spring:message code="public.account.login.j_username.error" />",
                        						invalidMessage : "<spring:message code="public.account.login.j_username.error" />"
                        					}
                        				})
                        			);
                        		</script><br>
                        		<form:password id="password1" path="password" maxlength="255" size="50" title="Password"/>
                        		<form:errors path="password" />
                        		<script type="text/javascript">
                        			Spring.addDecoration(
                        				new Spring.ElementDecoration({
                        					elementId : "password1",
                        					widgetType : "dijit.form.ValidationTextBox",
                        					widgetAttrs : {
                        						required : true,
                        						promptMessage : "<spring:message code="public.account.login.j_password.error" />",
                        						invalidMessage : "<spring:message code="public.account.login.j_password.error" />",
                        						validator : "return validatePassword(this, dijit.byId('password2'));"
                        					}
                        				})
                        			);
                        		</script><br>
                        		<form:password id="password2" path="password" maxlength="255" size="50" title="Confirm password"/>
                        		<form:errors path="password" />
                        		<script type="text/javascript">
                        			Spring.addDecoration(
                        				new Spring.ElementDecoration({
                        					elementId : "password2",
                        					widgetType : "dijit.form.ValidationTextBox",
                        					widgetAttrs : {
                        						required : true,
                        						promptMessage : "<spring:message code="public.account.login.j_password.error" />",
                        						invalidMessage : "<spring:message code="public.account.login.j_password.error" />",
                        						validator : "return validatePassword(this, dijit.byId('password1'));"
                        					}
                        				})
                        			);
                        		</script><br>
                        		<!--<input type="hidden" name="_eventId" value="processLogin"/>-->
                        		<script type="text/javascript">
                        			function checkForm() {
                        				if((dojo.byId('userId')).value == '' ||
                        					(dojo.byId('password')).value == '') {
                        					return false;
                        				} else {
                        					return true;
                        				}
                        			}
                        			
                        			function validatePassword(dojoPwd1, dojoPwd2) {
                        				alert('yeees');
                        				return dojoPwd1.getValue() == dojoPwd2.getValue();
                        			}
                        		</script>
                        		<input type="submit" value="Login" style="color: black" onclick="return checkForm();"/>
                        		<script type="text/javascript">
                        			Spring.addDecoration(new Spring.ValidateAllDecoration({
                        				elementId:'submit',
                        				event:'onclick'}));
                        			Spring.addDecoration(new Spring.AjaxEventDecoration({
                        				elementId:'submit',
                        				event:'onclick',
                        				formId:'publicLoginForm',
                        				params:{fragments:'error', 'form', 'header'}}));
                        		</script>
                        	</fieldset>
                        </form:form>
                        Last edited by digz6666; Apr 2nd, 2009, 04:40 AM.

                        Comment


                        • #13
                          Hi guys!
                          I've fixed my problem. It now validates if the to password is the same by dojo way (not pure javasctipt). I've modified the validator of the ValidationTextBox widget.
                          I've highlighted the important code parts.

                          Code:
                          <script type="text/javascript">
                          function checkForm() {
                          	if((dojo.byId('userId')).value == '' ||
                          		(dojo.byId('password')).value == '') {
                          		return false;
                          	} else {
                          		return true;
                          	}
                          }
                          
                          function confirmPassword(value, constraints) {
                          	var isValid = false;
                          	if(constraints && constraints.other)  {
                                  	var otherInput =  dijit.byId(constraints.other);
                                  	if(otherInput) {
                                  		var otherValue = otherInput.value;
                                  		isValid = (value == otherValue);
                                  	}
                              	}
                          	return isValid;
                          }
                          
                          </script>
                          <div id="form">
                          <form:form id="publicRegisterForm" modelAttribute="publicRegisterForm" method="post" action="${flowExecutionUrl}&_eventId=processRegister">
                          	<fieldset>
                          		<form:input path="userId" maxlength="50" size="50" title="Username"/>
                          		<form:errors path="userId" />
                          		<c:if test="${status.error}">
                          			<c:out value="${status.errorMessage}"/>
                          		</c:if>
                          		<script type="text/javascript">
                          			Spring.addDecoration(
                          				new Spring.ElementDecoration({
                          					elementId : "userId",
                          					widgetType : "dijit.form.ValidationTextBox",
                          					widgetAttrs : {
                          						required : true,
                          						promptMessage : "<spring:message code="public.account.login.j_username.error" />",
                          						invalidMessage : "<spring:message code="public.account.login.j_username.error" />"
                          					}
                          				})
                          			);
                          		</script><br>
                          		<form:password id="password1" path="password" maxlength="255" size="50" title="Password"/>
                          		<form:errors path="password" />
                          		<script type="text/javascript">
                          			Spring.addDecoration(
                          				new Spring.ElementDecoration({
                          					elementId : "password1",
                          					widgetType : "dijit.form.ValidationTextBox",
                          					widgetAttrs : {
                          						required : true,
                          						promptMessage : "<spring:message code="public.account.login.j_password.error" />",
                          						invalidMessage : "<spring:message code="public.account.login.j_password.error" />",
                          						intermediateChanges : false
                          					}
                          				})
                          			);
                          		</script><br>
                          		<form:password id="password2" path="password" maxlength="255" size="50" title="Confirm password"/>
                          		<form:errors path="password" />
                          		<script type="text/javascript">
                          			Spring.addDecoration(
                          				new Spring.ElementDecoration({
                          					elementId : "password2",
                          					widgetType : "dijit.form.ValidationTextBox",
                          					widgetAttrs : {
                          						required : true,
                          						promptMessage : "<spring:message code="public.account.login.j_password.error" />",
                          						constraints : {'other': 'password1'},
                          						validator : this.confirmPassword,
                          						intermediateChanges : false
                          					}
                          				})
                          			);
                          		</script><br>
                          		<input type="submit" value="Login" style="color: black" onclick="return checkForm();"/>
                          		<script type="text/javascript">
                          			Spring.addDecoration(new Spring.ValidateAllDecoration({
                          				elementId:'submit',
                          				event:'onclick'}));
                          			Spring.addDecoration(new Spring.AjaxEventDecoration({
                          				elementId:'submit',
                          				event:'onclick',
                          				formId:'publicLoginForm',
                          				params:{fragments:'error,form,header'}}));
                          		</script>
                          	</fieldset>
                          </form:form>

                          Comment


                          • #14
                            public.account.login.j_password.error

                            if i replace the string "<spring:message code="public.account.login.j_password.error" />",
                            with a string like "password error" it doesn't work

                            Comment


                            • #15
                              spring roo + dijit

                              i created below by spring roo . how would i add custom validator for dijit like confirm password text field
                              if i seeing your example it doesn't work

                              <div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:form="http://www.springframework.org/tags/form" xmlns:spring="http://www.springframework.org/tags">
                              <script type="text/javascript">dojo.require("dijit.TitlePane");dojo.r equire("dijit.form.DateTextBox");dojo.require("dij it.form.FilteringSelect");</script>
                              <div id="_title_div" style="width: 100%">
                              <spring:message code="label.employee" var="entity_label"/>
                              <spring:message arguments="${entity_label}" code="entity.create" var="title_msg"/>
                              <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_title_div', widgetType : 'dijit.TitlePane', widgetAttrs : {title: '${title_msg}'}})); </script>
                              <spring:url value="/employee" var="form_url"/>
                              <form:form action="${form_url}" method="POST" modelAttribute="employee">
                              <div id="roo_employee_password">
                              <label for="_password">Password:</label>
                              <form:input cssStyle="width:250px" id="_password" maxlength="30" path="password" size="0"/>
                              <br/>
                              <form:errors cssClass="errors" id="_password_error" path="password"/>
                              <spring:message arguments="Password" code="field.invalid" var="field_invalid"/>
                              <spring:message code="field.required" var="field_required"/>
                              <spring:message argumentSeparator="," arguments="Password,(${field_required})" code="field.simple.validation" var="field_validation"/>
                              <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : "_password", widgetType : "dijit.form.ValidationTextBox", widgetAttrs : {promptMessage: "${field_validation}", invalidMessage: "${field_invalid}", required : true}})); </script>
                              </div>


                              Thanks in advance for your reply

                              Comment

                              Working...
                              X