You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Thorsten Mauch <ma...@imkenberg.de> on 2006/03/18 12:58:35 UTC

[CFORMS] Set required attribute to widget from flow

Hi
I have a form that have some widget that's are hided by default (additional
delivery address). If the user choose the to enter the additional delivery
address, then the widgets are shown and become mandatory. For that reason it
try to change the required attribute from flow script, but I get the error:

java.lang.IllegalStateException: Attempt to modify an immutable
WidgetDefinition

I called:
form.lookupWidget("deliveryaddress_street").getFieldDefinition().setRequired
(true);

Is there a way to overcome this problem ?

Thx Thorsten


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


Re: [CFORMS] Set required attribute to widget from flow

Posted by Mark Lowe <me...@gmail.com>.
On 3/18/06, Jason Johnston <co...@lojjic.net> wrote:
> Thorsten Mauch wrote:
> > Hi
> > I have a form that have some widget that's are hided by default (additional
> > delivery address). If the user choose the to enter the additional delivery
> > address, then the widgets are shown and become mandatory. For that reason it
> > try to change the required attribute from flow script, but I get the error:
> >
> > java.lang.IllegalStateException: Attempt to modify an immutable
> > WidgetDefinition
> >
> > I called:
> > form.lookupWidget("deliveryaddress_street").getFieldDefinition().setRequired
> > (true);
>
> What version of Cocoon are you using?  As of 2.1.8 you can set the
> required state of a field instance directly:
>
> form.lookupWidget("deliveryaddress_street").setRequired(true);

I came across this when with 2.1.7, where between versions the form
definition became frozen.. You can use a jx transformation to generate
the form definition. setRequired directly on the widget is nicer than
the work around I found, but in case you're using 2.1.7 it works.

Mark

>
> But if you're using widget states to show/hide the fields then you
> shouldn't have to toggle the required state; if a field is set to
> required="true" and state="invisible" then it should not fail validation.
>
> ---------------------------------------------------------------------
> 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: [CFORMS] Set required attribute to widget from flow

Posted by Jason Johnston <co...@lojjic.net>.
Thorsten Mauch wrote:
> Hi
> I have a form that have some widget that's are hided by default (additional
> delivery address). If the user choose the to enter the additional delivery
> address, then the widgets are shown and become mandatory. For that reason it
> try to change the required attribute from flow script, but I get the error:
> 
> java.lang.IllegalStateException: Attempt to modify an immutable
> WidgetDefinition
> 
> I called:
> form.lookupWidget("deliveryaddress_street").getFieldDefinition().setRequired
> (true);

What version of Cocoon are you using?  As of 2.1.8 you can set the
required state of a field instance directly:

form.lookupWidget("deliveryaddress_street").setRequired(true);

But if you're using widget states to show/hide the fields then you
shouldn't have to toggle the required state; if a field is set to
required="true" and state="invisible" then it should not fail validation.

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