Input two domain classes(Person and Address) that linked through third Domain class in single form

22 views
Skip to first unread message

vogdb

unread,
May 20, 2011, 5:45:46 AM5/20/11
to JQuery Validation UI Plugin
Hi there again and thank You for such great plugin! I'm now actively
testing it.
I've got next problem: Input two domain classes(Person and Address)
that linked through 3rd Domain class in single form.
Domain classes:

class Person {
String name
Contact contact

static constraints = {
name blank:false
}
}

class Contact {
Address workAddress

static constraints = {
}
}

class Address {
String code

static constraints = {
code(size: 2..10)
}
}

My next tryings didn't succes:
1.
<jqvalui:renderValidationScript
for="org.grails.jquery.validation.ui.Person" form="personForm"
also="contact.workAddress"/>
Error executing tag <jqvalui:renderValidationScript>: String index out
of range: -1 in both cases when contact and workAddress existed and
didn't exist.
2.
<jqvalui:renderValidationScript
for="org.grails.jquery.validation.ui.Person" form="personForm"/>
<jqvalui:renderValidationScript
for="org.grails.jquery.validation.ui.Contact" form="personForm"/>
No errors, but Contact didn't have any validation

This problem is very important for me. Please give me some hint to
solve it. I even prepared to work on the plugin to resolve this issue.

limcheekin

unread,
May 20, 2011, 9:51:00 AM5/20/11
to JQuery Validation UI Plugin
Thanks for report this issue. I will look into it over this weekend.

Best regards,
Chee Kin

limcheekin

unread,
May 20, 2011, 11:55:57 PM5/20/11
to JQuery Validation UI Plugin
Hi there,

The plugin doesn't support this feature, adding this feature will
increase the complexity of the plugin implementation. Is it possible
to flatten the domain object?

Best regards,
Chee Kin

vogdb

unread,
May 23, 2011, 5:37:07 AM5/23/11
to JQuery Validation UI Plugin
Thanks for such fast response. If there is no way I'll flat objects,
but in future I'll try to implement this feature as standalone
separate or some branch for plugin, don't know.

Chee Kin Lim

unread,
May 23, 2011, 8:58:10 AM5/23/11
to jquery-valida...@googlegroups.com
You're welcome. If you implement this feature, please contribute the codes back to the plugin.

Thanks,
Chee Kin
Message has been deleted

vogdb

unread,
Jun 6, 2011, 4:03:13 AM6/6/11
to JQuery Validation UI Plugin
I've done some research recently and here are the results. I need the
following to be done.
1. Generate and validate scripts for several classes in single form.
For this I need:
<jqvalui:renderValidationScript
for="DomainClass1,DomainClass2....DomainClassN"/> and do some changes
in corresponding method
JQueryValidationUiTagLib.renderValidationScript

2. In case when there are two inputs with same name, only the
message for current (user picked) input should br displayed, not the
first input from the DOM tree.
Here I want to change this block in JQueryValidatorUI.remote :

var errors = {};
var message = (previous.message =
response.message || validator.defaultMessage( element, constraint ));
errors[element.name] =
$.isFunction(message) ? message(value) : message;
validator.showErrors(errors);

on something like this

var message = (previous.message =
response.message || validator.defaultMessage(element, constraint));
validator.errorList.push({
message: message,
element: element
});
validator.successList =
$.grep(validator.successList, function(formElement) {
return !(formElement.name == element);
});
validator.showErrors();

also replace generating javascripts for same name inputs with this:

$("#lastname").each(function() {
$(this).rules("add", {
minlength: 10,
messages: {
minlength: "too min"
}
});
});

In summary, what part of my foregoing changes you want to see in
plugin?

Chee Kin Lim

unread,
Jun 6, 2011, 4:34:38 AM6/6/11
to jquery-valida...@googlegroups.com
Hi there,

Thanks for taking the time to do the research on changes required.

May I know did you made the changes?

Best regards,
Chee Kin

vogdb

unread,
Jun 6, 2011, 5:30:12 AM6/6/11
to JQuery Validation UI Plugin
Soon will work on them and release some patch.

vogdb

unread,
Jun 8, 2011, 7:49:30 AM6/8/11
to JQuery Validation UI Plugin
Look at 15 issue. Attached patch to it.

Chee Kin Lim

unread,
Jun 8, 2011, 9:07:32 AM6/8/11
to jquery-valida...@googlegroups.com
Noted. Thanks.
Reply all
Reply to author
Forward
0 new messages