Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-2489

need to know if a component has been added to the AjaxRequestTarget

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.1
    • 1.4.2, 1.5-M1
    • wicket
    • None

    Description

      We need to evaluate the AjaxRequestTarget to determine if a component has been directly added (as opposed to the component rendering because of a parent component being added). This is useful for applying markup wrapping through the use of behaviors. This is required because, on a ajax request - and if the component that has the markup wrapping behavior was added directly to the AjaxRequestTarget, the markup provided with the behavior will be duplicated. We currently have a workaround but it required the use of a custom AjaxRequestTarget:

      public class AjaxRequestTarget extends org.apache.wicket.ajax.AjaxRequestTarget {

      private Map<String, Boolean> addedComponents = new HashMap<String, Boolean>();

      public AjaxRequestTarget(Page page)

      { super(page); }

      @Override
      public void addComponent(Component component)

      { addedComponents.put(component.getMarkupId(), Boolean.TRUE); super.addComponent(component); }

      public boolean wasComponentAdded(Component component)

      { return (null != addedComponents.get(component.getMarkupId())); }

      }

      It would be nice if the Wicket AjaxRequestTarget had a method (the name of the method name doesn't really matter and is just for example purposes) like the following:

      public boolean wasComponentAdded(Component component) {
      return (null != markupIdToComponent.get(component.getMarkupId());
      }

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            jhudson Joe Hudson
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: