/** * If this Component is a Page, returns self. Otherwise, searches for the nearest Page parent in * the component hierarchy. If no Page parent can be found, {@code null} is returned. * * @return The Page or {@code null} if none can be found */ protected final Page findPage() { // Search for page return (Page)(this instanceof Page ? this : findParent(Page.class)); }
/** * If this Component is a Page, returns self. Otherwise, searches for the nearest Page parent in * the component hierarchy. If no Page parent can be found, null is returned. * * @return The Page or null if none can be found */ protected final Page findPage() { // Search for page return (Page)(this instanceof Page ? this : findParent(Page.class)); }
private NodeTreeContainer findContainer(Component component) { if (component instanceof NodeTreeContainer) { return (NodeTreeContainer) component; } else { return component.findParent(NodeTreeContainer.class); } }
/** * If this Component is a Page, returns self. Otherwise, searches for the nearest Page parent in * the component hierarchy. If no Page parent can be found, {@code null} is returned. * * @return The Page or {@code null} if none can be found */ protected final Page findPage() { // Search for page return (Page)(this instanceof Page ? this : findParent(Page.class)); }
/** * @param component * @return The parent form for component */ public static Form<?> findForm(Component component) { return component.findParent(Form.class); }
/** * @param component * @return The parent form for component */ public static Form<?> findForm(Component component) { return component.findParent(Form.class); }
/** * If this Component is a Page, returns self. Otherwise, searches for the nearest Page parent in * the component hierarchy. If no Page parent can be found, null is returned. * * @return The Page or null if none can be found */ protected final Page findPage() { // Search for page return (Page)(this instanceof Page ? this : findParent(Page.class)); }
public static boolean isPartOfPage(final Component component) { return component.findParent(Page.class) != null; }
@Override public Project getProject() { ProjectAware projectAware = component.findParent(ProjectAware.class); if (projectAware != null) return projectAware.getProject(); else return null; }
/** * Finds the form this behavior is linked to * * @return form this behavior is linked to or {@code null} if none */ protected Form<?> findForm() { // try to find form in the hierarchy of owning component Component component = getComponent(); return component.findParent(Form.class); }
public static ModalHandler getInstanceFor(Component component) { HasModalHandler container; if (component instanceof HasModalHandler) { container = (HasModalHandler) component; } else { container = component.findParent(HasModalHandler.class); } return container.getModalHandler(); }
private AbstractWidget<?> getWidget(ICommandsSupportComponent<?> commandSupport) { Component component = commandSupport.getComponent(); if (component instanceof AbstractWidget) { return (AbstractWidget<?>) component; } return component.findParent(AbstractWidget.class); } }
@Override public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) { Set<Form<?>> formsToUpdate = new HashSet<>(); for (Map.Entry<String, Component> entry : map.entrySet()) { Component component = entry.getValue(); Form<?> form = component.findParent(Form.class); if(form!=null && form.isMultiPart()) formsToUpdate.add(form.getRootForm()); } for (Form<?> form : formsToUpdate) { response.addJavaScript("{var e = document.getElementById('"+form.getMarkupId()+"'); e.encoding= 'multipart/form-data'; e.encType=e.encoding;}"); } } }
public void onBeforeRespond(Map map, AjaxRequestTarget target) { if (target.getPage() != component.findParent(Page.class)) { return; } IWireframe wireframe = WireframeUtils.getParentWireframe(component); if (wireframe != null) { wireframe.render(target); } else { log.warn("Unable to find parent wireframe-behavior"); } }
@Override public void onAfterRespond(Map<String, Component> map, IJavaScriptResponse response) { Set<Form<?>> formsToUpdate = new HashSet<>(); for (Map.Entry<String, Component> entry : map.entrySet()) { Component component = entry.getValue(); Form<?> form = component.findParent(Form.class); if(form!=null && form.isMultiPart()) formsToUpdate.add(form.getRootForm()); } for (Form<?> form : formsToUpdate) { response.addJavaScript("{var e = document.getElementById('"+form.getMarkupId()+"'); e.encoding= 'multipart/form-data'; e.encType=e.encoding;}"); } } }
@Override protected final void onSelect(Component tabLink) { AjaxRequestTarget target = Preconditions.checkNotNull(RequestCycle.get().find(AjaxRequestTarget.class)); Tabbable tabbable = tabLink.findParent(Tabbable.class); if (tabbable == null) { Tabbable.TabsFragment tabs = Preconditions.checkNotNull(tabLink.findParent(Tabbable.TabsFragment.class)); tabs.getDropdown().close(); tabbable = tabs.getTabbable(); } target.add(tabbable); onSelect(target, tabLink); }
protected void update(Component component, ActionPerformedEvent<?> event, IEvent<?> wicketEvent) { component.configure(); if(component.isVisibleInHierarchy() && component.findParent(Page.class)!=null) event.getTarget().ifPresent(target ->target.add(component)); }
@SuppressWarnings("unchecked") public void selectTab(Component tabLink) { ListView<ActionTab> tabItems = tabLink.findParent(ListView.class); for (ActionTab each: tabItems.getModelObject()) each.setSelected(false); setSelected(true); onSelect(tabLink); }
/** * Decides whether the timer behavior should render its JavaScript to re-trigger it after the * update interval. * * @return {@code true} if the behavior is not stopped, it is enabled and still attached to any * component in the page or to the page itself */ protected boolean shouldTrigger() { return isStopped() == false && isEnabled(getComponent()) && (getComponent() instanceof Page || getComponent().findParent(Page.class) != null); }
/** * Decides whether the timer behavior should render its JavaScript to re-trigger it after the * update interval. * * @return {@code true} if the behavior is not stopped, it is enabled and still attached to any * component in the page or to the page itself */ protected boolean shouldTrigger() { return isStopped() == false && isEnabled(getComponent()) && (getComponent() instanceof Page || getComponent().findParent(Page.class) != null); }