public static void loadChildren(MarkupContainer container) { container.visitChildren(FormComponent.class, new IVisitor<FormComponent, Void>() { @Override public void component(FormComponent formComponent, IVisit iVisit) { if (isPersistent(formComponent)) { load(formComponent); } } }); }
public static void saveChildren(MarkupContainer container) { container.visitChildren(FormComponent.class, new IVisitor<FormComponent, Void>() { @Override public void component(FormComponent formComponent, IVisit iVisit) { if (isPersistent(formComponent)) { save(formComponent); } } }); }
@SuppressWarnings("unchecked") public static <C> Optional<C> findFirstChild(MarkupContainer container, Class<C> type, Predicate<C> filter) { return Optional.ofNullable(container.visitChildren(type, (Component object, IVisit<C> visit) -> { if (type.isAssignableFrom(object.getClass()) && (filter == null || filter.test((C) object))) { visit.stop((C) object); } })); }
@SuppressWarnings("unchecked") public static <C> Optional<C> findFirstChild(MarkupContainer container, Class<C> type, Predicate<C> filter) { return Optional.ofNullable(container.visitChildren(type, (Component object, IVisit<C> visit) -> { if (type.isAssignableFrom(object.getClass()) && (filter == null || filter.test((C) object))) { visit.stop((C) object); } })); }
@Override void onVisibleStateChanged() { super.onVisibleStateChanged(); visitChildren(new IVisitor<Component, Void>() { @Override public void component(Component component, IVisit<Void> visit) { component.clearVisibleInHierarchyCache(); } }); }
@Override public Object component(Component component) { if (component.getMarkupId().equals(id)) { this.found = component; return IVisitor.STOP_TRAVERSAL; } else if (component instanceof MarkupContainer) return ((MarkupContainer)component).visitChildren(this); else return IVisitor.CONTINUE_TRAVERSAL; }
/** * @param parent parent on which ChildVisitor is added * @param searchFor ,searchFor is the component which visitor search for * @return true if searchFor is found */ protected Boolean addNewChildVisitor(MarkupContainer parent, Component searchFor) { return parent.visitChildren(new ChildVisitor(searchFor)); }
/** * @param parent parent on which ChildVisitor is added * @param searchFor ,searchFor is the component which visitor search for * @return true if searchFor is found */ protected Boolean addNewChildVisitor(MarkupContainer parent, Component searchFor) { return parent.visitChildren(new ChildVisitor(searchFor)); }
@Override void onEnabledStateChanged() { super.onEnabledStateChanged(); visitChildren(new IVisitor<Component, Void>() { @Override public void component(Component component, IVisit<Void> visit) { component.clearEnabledInHierarchyCache(); } }); }
public Object component(Component component) { if (component.getMarkupId().equals(id)) { this.found = component; return IVisitor.STOP_TRAVERSAL; } if (component instanceof MarkupContainer) { return ((MarkupContainer)component).visitChildren(this); } return IVisitor.CONTINUE_TRAVERSAL; }
public Object component(Component component) { if (component.getMarkupId().equals(id)) { this.found = component; return IVisitor.STOP_TRAVERSAL; } else if (component instanceof MarkupContainer) return ((MarkupContainer)component).visitChildren(this); else return IVisitor.CONTINUE_TRAVERSAL; }
public Object component(Component component) { if (component.getParent().getMarkupId().equals(id)) { this.found.add(component); return IVisitor.STOP_TRAVERSAL; } if (component instanceof MarkupContainer) { return ((MarkupContainer)component).visitChildren(this); } return IVisitor.CONTINUE_TRAVERSAL; }
public static Component findFirstComponentWithId(MarkupContainer container, String id) { return container.visitChildren(Component.class, (IVisitor<Component, Component>) (object, visit) -> { if (object.getId().equals(id)) { visit.stop(object); } }); }
public static Component findFirstComponentWithId(MarkupContainer container, String id) { return container.visitChildren(Component.class, (IVisitor<Component, Component>) (object, visit) -> { if (object.getId().equals(id)) { visit.stop(object); } }); }
@SuppressWarnings("unchecked") public static <C> Stream<C> findChildren(MarkupContainer container, Class<C> type) { Stream.Builder<C> builder = Stream.builder(); container.visitChildren(type, (Component object, IVisit<Void> visit) -> { if (type.isAssignableFrom(object.getClass())) { builder.add((C) object); } }); return builder.build(); }
@SuppressWarnings("unchecked") public static <C> Stream<C> findChildren(MarkupContainer container, Class<C> type) { Stream.Builder<C> builder = Stream.builder(); container.visitChildren(type, (Component object, IVisit<Void> visit) -> { if (type.isAssignableFrom(object.getClass())) { builder.add((C) object); } }); return builder.build(); }
public void component(Component component, IVisit<Void> visit) { if (component.getParent().getMarkupId().equals(id)) { this.found.add(component); visit.stop(); } if (component instanceof MarkupContainer) { // mocleiri: changed for 1.5 compatibility, not 100% sure it is equivalent to before. ((MarkupContainer)component).visitChildren(this); visit.stop(); } }
public static void onFormError(MarkupContainer container, AjaxRequestTarget target) { container.visitChildren((c, v) -> { if (c instanceof FeedbackPanel && ((FeedbackPanel) c).anyMessage()) { Optional.ofNullable(target).ifPresent(t -> t.add(c)); } else if (c.hasFeedbackMessage()) { refreshComponentOrCellContainer(target, c); } }); }
public static void onFormError(MarkupContainer container, AjaxRequestTarget target) { container.visitChildren((c, v) -> { if (c instanceof FeedbackPanel && ((FeedbackPanel) c).anyMessage()) { Optional.ofNullable(target).ifPresent(t -> t.add(c)); } else if (c.hasFeedbackMessage()) { refreshComponentOrCellContainer(target, c); } }); }
@Override protected void respond(AjaxRequestTarget target) { final String draggableId = getComponent().getRequest().getParameter("id"); // find component with the markup id given in the 'id' request parameter MarkupIdVisitor visitor = new MarkupIdVisitor(draggableId); // System.out.println("R: " + getComponent() + " " + getComponent().getParent()+ " " + getComponent().getParent().getParent()); // getComponent().getPage().visitChildren(visitor); getDropContainer().visitChildren(visitor); onDrop(visitor.getFoundComponent(), target); }