Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: SWF Inventory of Javascript examples

  1. #11

    Default

    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>

  2. #12
    Join Date
    Dec 2008
    Location
    Ulaanbaatar, Mongolia
    Posts
    123

    Default

    Quote 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 at 03:40 AM.

  3. #13
    Join Date
    Dec 2008
    Location
    Ulaanbaatar, Mongolia
    Posts
    123

    Default

    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>

  4. #14
    Join Date
    Nov 2009
    Posts
    5

    Default 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

  5. #15
    Join Date
    Nov 2009
    Posts
    5

    Default 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

  6. #16
    Join Date
    Nov 2009
    Posts
    5

    Default below is the error i get when i used the script

    org.apache.jasper.JasperException: /WEB-INF/views/employee/create.jspx(6,22) The entity name must im
    mediately follow the '&' in the entity reference.

  7. #17

    Default Spring/DOJO API

    Hi all,

    I have made a new post regarding the Spring-JS/Dojo usage located at:

    http://forum.springsource.org/showth...ht=spring+dojo

    I'd welcome any comments or ideas?

    Eggsy

  8. #18
    Join Date
    Oct 2008
    Posts
    286

    Default

    i am using the below Spring JS code but would like to set the form id parameter depends on the defined form id..

    Code:
    Spring.remoting.submitForm('selectedTaishoHaniSentei.analyzeId', 'bookingForm', { _eventId:'updateTaishoHaniSenteiByAnalyzeId' });
    anybody knows how to get the form id...
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

  9. #19

    Default Form id

    Rather than using Spring.remoting could you use the Spring.addDecoration method like so:

    Code:
    Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'proceed', event:'onclick',formId:'booking', params:{fragments:'messages'}}));
    A bit more information here:

    http://static.springsource.org/sprin...l/ch11s04.html

  10. #20
    Join Date
    Oct 2008
    Posts
    286

    Default

    Quote Originally Posted by eggsy84 View Post
    Rather than using Spring.remoting could you use the Spring.addDecoration method like so:

    Code:
    Spring.addDecoration(new Spring.AjaxEventDecoration({elementId:'proceed', event:'onclick',formId:'booking', params:{fragments:'messages'}}));
    A bit more information here:

    http://static.springsource.org/sprin...l/ch11s04.html
    if you were intended to answer my inquiry, it seems you misunderstood...
    I am asking for a variable form id...and also it is given that we may use the both ways... because its enclosed by the sciprt tag..

    anyway Sir, i found the answer... its just a basic javascript...

    Spring.remoting.submitForm('selectedTaishoHaniSent ei.analyzeId', document.forms[0].id, { _eventId:'updateTaishoHaniSenteiByAnalyzeId' });
    thanks
    Eros

    Environment:
    JSP 2.0
    Dojo 1.4.1
    Ext JS 3.1 (testing)
    Spring MVC 2.5.6.SEC01 (planning to Spring 3 using STS)
    STS
    SWF 2.0.9.RELEASE
    Tiles 2.0.5
    iBatis: ibatis-sqlmap-2.3.4.726

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •