Submitted by Rafez Noorullah on Sep 20, 2010 10:57:40 AM

Client Side JavaScript Libraries in XPages

Submitted by Rafez Noorullah on Sep 20, 2010 10:57:29 AM

Client Side JavaScript Libraries in XPages

There seems to be a Typo for the code for Example 1: Adding a Dojo widget to an XPage.

DdjoType should actually be dojoType

Thus the code should read

Submitted by Paul S. Withers on Sep 1, 2009 6:10:57 AM

Conflict of functionality

If you use XSP.attachValidator with a xp:radioGroup, xp:checkBoxGroup or xp:listBox control, the validation throws an error with e.select. Presumably this is because the control cannot be selected.

Also, attachValidator always triggers client-side validation, regardless of the setting on the control or the database. Is there a way to override this?

Submitted by Teresa Monahan on Jan 9, 2009 7:06:19 AM

Response to "Error in code?"

Thanks for your comment. Yes, there is indeed an error in the code.

As you correctly pointed out EmployeeIDValidator is not an extension of the XSP class so the correct code to use this function is

new EmployeeIDValidator("Error, incorrect employee number entered"));

I have updated the code sample in the article to reflect this and have also replaced the special character you mentioned with a simple double quote.

Thanks again for pointing this out.

Submitted by Jens H Polster on Jan 2, 2009 11:58:04 AM

Error in code?

Thanks, great tutorial!

In the Output Script for the Employee ID it says

XSP.addOnLoad(

function addEmployeeIDValidator() {

XSP.attachValidator("#{id:employeeID}",new XSP.RequiredValidator("You must enter an employee number"), null,

new XSP.EmployeeIDValidator(“Error, incorrect employee number entered"));

}

);

From what I can see the EmployeeIDValidator is not an extension of the XSP class, so shouldn't it be

XSP.addOnLoad(

function addEmployeeIDValidator() {

XSP.attachValidator("#{id:employeeID}",new XSP.RequiredValidator("You must enter an employee number"), null,

new EmployeeIDValidator("Error, incorrect employee number entered"));

}

);

instead?

Oh, and to make it easier to copy&paste it would be nice if the starting quote before "Error, incorrect..." would be changed to a simple double quote. It currently is a special character.

Thanks

Submitted by Teresa Monahan on Oct 30, 2008 10:02:44 AM

Nice tutorial

Thanks for your feedback. Answers below, I hope they help

a) when you have defined you own client validator could you link it to a input element in the properties instead of onload code?

No, this is currently not possible.

However, you can create custom validation directly on input controls using an Expression Validator. More details on using this type of validation are available in the "Advanced Validation Using All-Properties" sections of the article "Validation On An XPage" available at http://www-10.lotus.com/ldd/ddwiki.nsf/dx/validation-on-an-xpage.htm

b) How to overwrite the client validator routine. I rather have a Dojo Dialog showing all problems in one go... or use the ErrorControls like the backend.

This can be achieved by overloading the XSP.validationError() function in XSPClientDojo. I've added details on how to do this to the end of my article.

Submitted by Stephan H. Wissel on Oct 29, 2008 12:27:31 PM

Nice tutorial

2 Questions:

a) when you have defined you own client validator could you link it to a input element in the properties instead of onload code?

b) How to overwrite the client validator routine. I rather have a Dojo Dialog showing all problems in one go... or use the ErrorControls like the backend.