Diogo Matos wrote:
I'm trying to set a error message on a widget using the i18n transformer
and for some strange reason i cannot.
On the forms definition file i'm setting a widget like:
<fd:field id="generic_error" state="output">
<fd:datatype base="string"/>
</fd:field>
On my AppleController java class I'm setting the widget value to:
form.getChild("generic_error").setValue("4202");
On the form template file I'm doing:
<i18n:text><ft:widget id="generic_error"/></i18n:text>
The problem is that it's not displaying the translated error message
for the key 4202, instead it's displaying the string "4202"
Does anyone know how to do this? Am I using the wrong approach for this
kind of validation of the CForms?
I don't know the specifics of your form, but normally I handle custom
messages in one of two ways:
1) Validation message attached to a specific field:
form.lookupWidget("path/to/field").setValidationError(
new ValidationError(new I18nMessage("my_i18n_key"))
);
Look at the I18nMessage javadoc[1] for other constructors that let you
specify the catalogue use parameterized messages.
2) Validation message not attached to any one specific field:
First I include a messages widget in my form:
Definition:
<fd:messages id="messages" />
Template:
<ft:widget id="messages" />
Controller:
form.lookupWidget("messages").addMessage(
new I18nMessage("my_i18n_key")
);
Hope that helps.
--Jason
[1]
http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/util/I18nMessage.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]