You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Maria Grigorieva <ma...@hotmail.com> on 2010/02/08 00:14:10 UTC

Cocoon 2.1.11 forms validation "on-value-changed"

Hello, dear mailing-list )

Please help if it's possible: I have a form-model with widgets and the
values of the fields 

passes to the database "on-value-changed" action (I haven't any "Submit"
buttons at all)

And for each field I have the validation rules:

<fd:field id="density" required="true">
		<fd:label>Density</fd:label>
		<fd:datatype base="float">
			<fd:convertor type="plain" />
		</fd:datatype>
		<fd:validation>
			<fd:range min="0" max="5000">
				<fd:failmessage>ERROR!!!</fd:failmessage>
			</fd:range>
		</fd:validation>
		<fd:on-value-changed>
			<javascript>
				var value = event.source.value;
				var form =  event.source.form;
                             var id = new
java.lang.Integer(form.getAttribute("id").intValue());
				matmodel.setR0(id,value);
		</javascript>
		</fd:on-value-changed>
	</fd:field>

Please, help! How can I use the validation rules to show the message to the
user on-value-changed action ??? 


-- 
View this message in context: http://old.nabble.com/Cocoon-2.1.11-forms-validation-%22on-value-changed%22-tp27493446p27493446.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon 2.1.11 forms validation "on-value-changed"

Posted by Thomas Markus <t....@proventis.net>.
use your own validator (or use an existing) and call validate

<fd:field id="density" required="true">
...
<fd:validation>
    <fd:javascript>
        var value = widget.value;
        if (value <=0 || value >= 500) {
            var i18nkey = 'your.key';
            var error = new
Packages.org.apache.cocoon.forms.validation.ValidationError(
                new
Packages.org.apache.cocoon.forms.util.I18nMessage(i18nkey)
            );
            // widget should be ValidationErrorAware
            widget.setValidationError(error);
            return false;
        }
        return true;
    </fd:javascript>
</fd:validation>
<fd:on-value-changed>
<javascript>
    if (event.source.validate()) {
        // your action
    }
<javascript>
<fd:on-value-changed>

...


Am 08.02.2010 00:14, schrieb Maria Grigorieva:
> Hello, dear mailing-list )
>
> Please help if it's possible: I have a form-model with widgets and the
> values of the fields 
>
> passes to the database "on-value-changed" action (I haven't any "Submit"
> buttons at all)
>
> And for each field I have the validation rules:
>
> <fd:field id="density" required="true">
> 		<fd:label>Density</fd:label>
> 		<fd:datatype base="float">
> 			<fd:convertor type="plain" />
> 		</fd:datatype>
> 		<fd:validation>
> 			<fd:range min="0" max="5000">
> 				<fd:failmessage>ERROR!!!</fd:failmessage>
> 			</fd:range>
> 		</fd:validation>
> 		<fd:on-value-changed>
> 			<javascript>
> 				var value = event.source.value;
> 				var form =  event.source.form;
>                              var id = new
> java.lang.Integer(form.getAttribute("id").intValue());
> 				matmodel.setR0(id,value);
> 		</javascript>
> 		</fd:on-value-changed>
> 	</fd:field>
>
> Please, help! How can I use the validation rules to show the message to the
> user on-value-changed action ??? 
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org