Class AjaxEnclosureListener

java.lang.Object
org.apache.wicket.protocol.http.AjaxEnclosureListener
All Implemented Interfaces:
AjaxRequestTarget.IListener

This listener adds Enclosures to AjaxTarget, where the child controller of the said Enclosure is already added. This is a part of the fix to the problem: "Changing the visibility of a child component in Ajax callback method will not affect the entire enclosure but just the child component itself. This is because only the child component is added to the AjaxRequestTarget" When used with an "Inline" Enclosure, this problem is fixed. Syntax for inline enclosure: <tr wicket:enclosure="controllingChildId"> In this example the tag used is tr, but any other tag could be used as well. The attribute "wicket:enclosure" is mandatory, and is used to recognise an inline enclosure. The value of the attribute, here "controllingChildId" can contain an id for the child (controller) element. If the said value is not given, the first element inside the enclosure will be used as a controller child. If there are no elements inside the enclosure, the parsing will fail.
Author:
Joonas Hamalainen
See Also:
  • Constructor Details

  • Method Details

    • onBeforeRespond

      public void onBeforeRespond(Map<String,Component> map, AjaxRequestTarget target)
      Try to find Enclosures that have their controllers added already, and add them to the target.
      Specified by:
      onBeforeRespond in interface AjaxRequestTarget.IListener
      Parameters:
      map - modifiable map (markupId -> component) of components already added to the target
      target - the target itself. Could be used to add components or to append/prepend JavaScript
    • isControllerOfEnclosure

      public static boolean isControllerOfEnclosure(Component component, Enclosure enclosure)
      Check if a given component is the controlling child of a given enclosure
      Parameters:
      component -
      enclosure -
      Returns:
      true if the given component is the controlling child of the given InlineEnclosure