cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 25303] - Enhanced validation for selection lists
Date Mon, 08 Dec 2003 12:12:49 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25303>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25303

Enhanced validation for selection lists





------- Additional Comments From agallardo@agsoftware.dnsalias.com  2003-12-08 12:12 -------
Currently we can make use of:

form.validator = myFormValidator;
form.showForm("yourForm-display");

The first line sets a customised validator for the form.

The myFormValidator() allow us to validate right after woody makes all his
validations. They are not exclusive. The function allow write complex
validations for a form. Here is an example in Javascript:

function myFormValidator(form)
{
  var emp_id = parseInt(cocoon.request.emp_id);
  factory = cocoon.getComponent(Packages.o.a.c.ojb.jdo.components.JdoPMF.ROLE);
  bean = empresaHandler.retrieve(emp_id, factory);
  if (!(bean instanceof Packages.test.Employee)) {
    form.getWidget("errorMessages").addMessage("Select an Employee on list");
    return false;
  } else {
    return true;
  }
}

The above funtion must return false if the validation failed (there are some
errors). Otherwise return true (data are OK).

Maybe this is not perfect, but we are using in the definition a <wd:messages> as
follow:

  <wd:messages id="errorMessages">
    <wd:label>The operation failed. Please</wd:label>
  </wd:messages>

This element allow us to show the problems to the user. If we don't use the
addMessage() funtion, then the widget is not showed at all.

Mime
View raw message