wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grigorov <mgrigo...@apache.org>
Subject Re: AjaxFormComponentUpdatingBehavior to enable/disable a component
Date Thu, 12 Apr 2012 08:54:58 GMT
On Thu, Apr 12, 2012 at 11:52 AM, dpmihai <dpmihai@yahoo.com> wrote:
> Hi.
>
> I have a set of components  C (anything you want Label, DateField,
> TextField, DropDownChoice ...)
> and another ChechBox inside a ListItem.  I want to use the checkbox for
> enabling / disabling of all components C (when checkbox is selected I want
> to disable all C components):
>
>    final CheckBox dynamicChkBox = new CheckBox("dynamicChkBox",
> dynamicModel);
>        dynamicChkBox.add(new AjaxFormComponentUpdatingBehavior("onchange")
> {
>            protected void onUpdate(AjaxRequestTarget target) {
>                  Iterator it = item.iterator();  // item is my ListItem
>                  while (it.hasNext()) {
>                        Component component = (Component) it.next();

here do not disable the checkbox itself

>                        component.setEnabled(!(Boolean)
> dynamicModel.getObject());
>                        if ((target != null) &&
> !component.getId().startsWith("dynamic")) {
>                                target.add(component);
>                        }
>                  }
>            }
>    });
>
> Initially dynamic check box is not selected. I select the checkbox and my
> set of components C becomes disabled as desired, but then if I deselect the
> chechbox  I get an error:
>
> org.apache.wicket.request.handler.ListenerInvocationNotAllowedException:
> Behavior rejected interface invocation. Component: [CheckBox [Component id =
> dynamicChkBox]] Behavior: com.asf.nextserver.web.report.NextRuntimePanel$1
> {event='onchange'} Listener: [RequestListenerInterface
> name=IBehaviorListener, method=public abstract void
> org.apache.wicket.behavior.IBehaviorListener.onRequest()]
>        at
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:237)
>        .....
>
> I noticed that when I first select the checkbox even if the components are
> disabled Wicket Ajax Debug shows an error like :
> ERROR: Wicket.Ajax.Call.processComponent: Component with id [[txtTime145]]
> was not found while trying to perform markup update. Make sure you called
> component.setOutputMarkupId(true) on the component whose markup you are
> trying to update.
>
> I do not know why, because I put setOutputMarkupId(true) on all my
> components C.
>
> Is there somtehing I can do?
>
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/AjaxFormComponentUpdatingBehavior-to-enable-disable-a-component-tp4551288p4551288.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Mime
View raw message