cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Scheel <>
Subject problem with the fd:messages field type and ajax
Date Thu, 01 Nov 2007 12:59:59 GMT

I have a problem with the fd:messages field in combination with ajax.
My cocoon version is 2.1.10.

The goal of that form is to have some field values, each contains an identifier value.
The method 'validateIdentity(widget)' executes a biz action to check if there is no other
element with equal identifier values.
That means if this validation fails i must have a parent widget which invalidates all of its
children and print out the error message.
To group all identifiers a group widget is defined in this form.
To print out the error message the group widget contains an fd:messages element.

Ajax is required to request the suggestion list elements. 

Here is the form definition fragment:

<fd:form xmlns:fd=""
    <fd:group id="identifiers">
      <!-- widgets to setup id values for the new game -->

        <fd:field id="title" required="true">
          <fd:datatype base="string" />
        <fd:field id="category" required="true">
          <fd:datatype base="string" />
          <fd:suggestion-list type="javascript">
              function addSuggestion(value){
                  value: value,
                  label: value
              var suggestions = [];
              if(filter) {
                var filterValue = "" + filter;
                var phase = cocoon.request.getParameter("phase");
                if(phase && "init".equals(phase)) {
                } else if(filterValue.length > 1) {
                  // FIXME dont know how to trim a filter value
                  // String.trim() doesnt work
                  suggestions = getCategorySuggestions(filterValue);
                  if(suggestions.length == 0) {
              return suggestions;

        <!-- locale -->
        <fd:field id="localeISOCode">
          <fd:datatype base="string" />
          <fd:selection-list type="flow-jxpath" list-path="localeSelection"
            value-path="value" label-path="label" />
        <fd:field id="platformName">
          <fd:datatype base="string" />
          <fd:selection-list type="flow-jxpath" list-path="platformSelection"
            value-path="value" label-path="label" />
        <fd:messages id="validationErrors"/>
          return validateIdentity(widget);

    <!-- more widgets -->

This is my template code:

<?xml version="1.0"?>
<page xmlns:ft=""

		uri="resource://org/apache/cocoon/forms/generation/jx-macros.xml" />

		<link rel="stylesheet" type="text/css" href="${cocoon.request.contextPath}/styles/advancedForm.css"/>
		<!-- display search result header -->
		<ft:form-template action="${cocoon.request.contextPath}/products/new/continue" method="POST"

			<ft:group id="identifiers">
					<tr><td colspan="2"><ft:widget id="validationErrors"/></td></tr>
					<tr><td><ft:widget-label id="title"/></td><td><ft:widget
					<tr><td><ft:widget-label id="category"/></td><td><ft:widget
id="category" type="suggest"/></td></tr>
					<tr><td><ft:widget-label id="localeISOCode"/></td><td><ft:widget
					<tr><td><ft:widget-label id="platformName"/></td><td><ft:widget
			<!-- more widgets -->

The validation method is implemented like this:

function validateIdentity(widget) {
  var result = doTheValidationRequest(getFieldValues(widget));
  if(true != result) {
    // invalid
    widget.getChild("validationErrors").addMessage(new I18nMessage("duplicate.product"));
    return false;
  return true;

If the result is not valid and the validation method try's to access the fd:messages field
an error dialog appears with the message: 
no element 'identifiers.validationErrors' in source document

Please ... can anybody tell me what the problem is ???


Oliver Scheel

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message