You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by beya! <an...@jibeya.com> on 2004/11/16 13:41:18 UTC

Nested Widget Validation...

Hi,
I have created a widget as so:

<fd:widgets>
     <fd:field id="quantity">
       <fd:label>Quantity</fd:label>
       <fd:datatype base="integer"/>
     </fd:field>
</fd:widgets>

Quantity is an attribute of an orderitem, so what I want the validation 
to do is:

1. If neworder.getOrderItems() is null, submit the form only if the 
quantity field has an integer value.
2. If neworder.getOrderItems() is not null, submit the form if quantity 
has an integer value or not.

How do I represent this in my widget definition?

many thanks


Andrew






Re: Nested Widget Validation...

Posted by beya! <an...@jibeya.com>.
Jorg,
here you go ;-)

<?xml version="1.0"?>

<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
<fd:validation>
   	<fd:javascript>
   		var success = true;
   		var items = neworder;
   		var quantity = widget.lookupWidget("quantity");
   		if (items.getOrderItems() == null &amp;&amp; quantity.value ==  
null) {
   			quantity.setValidationError(new  
Packages.org.apache.cocoon.forms.validation.ValidationError("Please  
enter a value", false));
   			success = false;
   		}
   		return success;
   	</fd:javascript>
</fd:validation>

<fd:widgets>
     <fd:field id="quantity">
       <fd:label>Quantity</fd:label>
       <fd:datatype base="integer"/>
     </fd:field>
</fd:widgets>

</fd:form>

regards

Andrew


On 16 Nov 2004, at 14:37, Jorg Heymans wrote:

> No worries :)
>
> Care to contribute your solution to the list maybe?
>
> Regards
> Jorg
>
> beya! wrote:
>> Problem solved......
>> thanks for your help
>> regards
>> Andrew
>> On 16 Nov 2004, at 12:41, beya! wrote:
>>     Hi,
>>     I have created a widget as so:
>>     <fd:widgets>
>>     <fd:field id="quantity">
>>     <fd:label>Quantity</fd:label>
>>     <fd:datatype base="integer"/>
>>     </fd:field>
>>     </fd:widgets>
>>     Quantity is an attribute of an orderitem, so what I want the
>>     validation to do is:
>>     1. If neworder.getOrderItems() is null, submit the form only if  
>> the
>>     quantity field has an integer value.
>>     2. If neworder.getOrderItems() is not null, submit the form if
>>     quantity has an integer value or not.
>>     How do I represent this in my widget definition?
>>     many thanks
>>     Andrew
>> ---------------------------------------------------------------------- 
>> --
>> * +The home of urban music
>> + http://www.beyarecords.com
>> *
>> ---------------------------------------------------------------------- 
>> --
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>

Re: Nested Widget Validation...

Posted by Jorg Heymans <jh...@domek.be>.
No worries :)

Care to contribute your solution to the list maybe?

Regards
Jorg

beya! wrote:
> Problem solved......
> 
> thanks for your help
> 
> 
> regards
> 
> 
> Andrew
> On 16 Nov 2004, at 12:41, beya! wrote:
> 
>     Hi,
>     I have created a widget as so:
> 
>     <fd:widgets>
>     <fd:field id="quantity">
>     <fd:label>Quantity</fd:label>
>     <fd:datatype base="integer"/>
>     </fd:field>
>     </fd:widgets>
> 
>     Quantity is an attribute of an orderitem, so what I want the
>     validation to do is:
> 
>     1. If neworder.getOrderItems() is null, submit the form only if the
>     quantity field has an integer value.
>     2. If neworder.getOrderItems() is not null, submit the form if
>     quantity has an integer value or not.
> 
>     How do I represent this in my widget definition?
> 
>     many thanks
> 
> 
>     Andrew
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
> 
> * +The home of urban music
> + http://www.beyarecords.com
> *
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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


Re: Nested Widget Validation...

Posted by beya! <an...@jibeya.com>.
Problem solved......

thanks for your help


regards


Andrew
On 16 Nov 2004, at 12:41, beya! wrote:

> Hi,
> I have created a widget as so:
>
> <fd:widgets>
>     <fd:field id="quantity">
>       <fd:label>Quantity</fd:label>
>       <fd:datatype base="integer"/>
>     </fd:field>
> </fd:widgets>
>
> Quantity is an attribute of an orderitem, so what I want the 
> validation to do is:
>
> 1. If neworder.getOrderItems() is null, submit the form only if the 
> quantity field has an integer value.
> 2. If neworder.getOrderItems() is not null, submit the form if 
> quantity has an integer value or not.
>
> How do I represent this in my widget definition?
>
> many thanks
>
>
> Andrew
>
>
>
>
>
>