
Originally Posted by
RobertGloverJr
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>