Refine search
/** * Replaces a child component of this container with another or just adds it in case no child * with the same id existed yet. * * @param children * The child(ren) to be added or replaced * @return this markup container */ public MarkupContainer addOrReplace(final Component... children) { for (Component child : children) { Args.notNull(child, "child"); checkHierarchyChange(child); if (get(child.getId()) == null) { add(child); } else { replace(child); } } return this; }
@Override public final void addChildren(MarkupContainer parent, Class<?> childCriteria) { Args.notNull(parent, "parent"); Args.notNull(childCriteria, "childCriteria"); parent.visitChildren(childCriteria, new IVisitor<Component, Void>() { @Override public void component(final Component component, final IVisit<Void> visit) { add(component); visit.dontGoDeeper(); } }); }
/** * Register a container as a container for draggable/droppable items. * (add the css class and markupId to be find on clientside). * * @param v the container to register. * @return this */ protected DnDSortableBehavior registerContainer(MarkupContainer v) { v.add(new AttributeAppender("class", new Model<String>(String.valueOf(getContainerCSSClass())), " ")); v.setOutputMarkupId(true); containers_.add(v); return this; }
public void replaceDefaultModal(ModalWindow newModal){ defaultModal.replaceWith(newModal); defaultModal = newModal; defaultModal.setOutputMarkupId(true); }
/** * Get the type of associated markup for this component. The markup type for a component is * independent of whether or not the component actually has an associated markup resource file * (which is determined at runtime). * * @return The type of associated markup for this component (for example, "html", "wml" or * "vxml"). If there is no markup type for a component, null may be returned, but this * means that no markup can be loaded for the class. Null is also returned if the * component, or any of its parents, has not been added to a Page. */ public MarkupType getMarkupType() { MarkupContainer parent = getParent(); if (parent != null) { return parent.getMarkupType(); } return null; }
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; }
Args.notNull(child, "child"); exceptionMessage("Trying to add this component to itself.")); MarkupContainer parent = getParent(); while (parent != null) this.toString(false) + "; parent == child: " + parent.toString(false); Classes.simpleName(this.getClass()) + "(\"" + this.getId() + "\", ...) instead of add(...)"; parent = parent.getParent(); checkHierarchyChange(child); log.debug("Add " + child.getId() + " to " + this); Component previousChild = children_put(child); if (previousChild != null && previousChild != child) exceptionMessage("A child '" + previousChild.getClass().getSimpleName() + "' with id '" + child.getId() + "' already exists")); addedComponent(child);
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; }
/** * {@inheritDoc} */ @Override public String append(MarkupContainer c, MarkupContainer parent, Component start, Component end) { String startId = ""; if (start != null) { startId = start.getMarkupId(); } String endIdId = ""; if (end != null) { endIdId = end.getMarkupId(); } return append(getComponentTag(c).getName(), c.getMarkupId(), parent.getMarkupId() , startId, endIdId); }
public BSDropDownMenu appendLink(Component label, MarkupContainer link) { return appendTag("li", true, null, itemId -> new TemplatePanel(itemId, () -> "<a wicket:id='" + link.getId() + "'><span wicket:id='" + label.getId() + "'></span></a>") .add(link .add(label)) .setRenderBodyOnly(false)); } public BSDropDownMenu appendLink(Component link) {
/** * Removes the given component * * @param id * The id of the component to remove * @return {@code this} for chaining */ public MarkupContainer remove(final String id) { Args.notNull(id, "id"); final Component component = get(id); if (component != null) { remove(component); } else { throw new WicketRuntimeException("Unable to find a component with id '" + id + "' to remove"); } return this; }
private void addIcon(MarkupContainer container, IModel<SInstanceAction> itemModel) { final IModel<String> titleModel = $m.map(itemModel, action -> defaultString(action.getText(), action.getDescription())); container .add(new WebMarkupContainer("icon") .add($b.classAppender($m.map(itemModel, it -> it.getIcon().getIconCssClassesString()))) .add($b.styleAppender($m.map(itemModel, it -> it.getIcon().getIconCssStyles())))) .add($b.classAppender($m.map(itemModel, it -> it.getIcon().getContainerCssClassesString()))) .add($b.styleAppender($m.map(itemModel, it -> it.getIcon().getContainerCssStyles()))) .add($b.visibleIf($m.map(itemModel, it -> it.getIcon() != null))) .add($b.attr("title", titleModel)); } @Override
@SuppressWarnings("unchecked") @Override public Component appendInput(WicketBuildContext ctx, BSControls formGroup, IModel<String> labelModel) { final IModel<? extends SInstance> model = ctx.getModel(); BSDatepickerInputGroup datepicker = formGroup .newComponent(id -> new BSDatepickerInputGroup(id) .setConverter(new ConverterImpl()) .setTextFieldConfigurer((IConsumer<FormComponent<?>>) c -> c .setLabel(labelModel) .setDefaultModel(new SInstanceValueModel<>(model)) .setOutputMarkupId(true) .add(new InputMaskBehavior(Masks.FULL_DATE)))); configureMaxDate(datepicker, model.getObject().getAttributeValue(ATR_MAX_DATE)); return datepicker.getTextField(); }
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); } }); }
@Before public void setUp() throws Exception { target = new EntityModel(EntityModel.Mode.VIEW, EntityModel.RenderingHint.REGULAR); mockParent = context.mock(MarkupContainer.class, "parent"); mockComponent1 = context.mock(Component.class, "component1"); mockComponent2 = context.mock(Component.class, "component2"); context.checking(new Expectations() {{ allowing(mockParent).getId(); will(returnValue("parent")); allowing(mockComponent1).getId(); will(returnValue("id1")); allowing(mockComponent2).getId(); will(returnValue("id2")); ignoring(mockComponent1); ignoring(mockComponent2); }}); mockComponent1.setParent(mockParent); mockComponent2.setParent(mockParent); }
@Override protected void onConfigure() { super.onConfigure(); if (Strings.isEmpty(headerLabel.getDefaultModelObjectAsString())) { // there must be at least on character inside the header to prevent // layout problems. headerLabel.setDefaultModelObject(" "); headerLabel.setEscapeModelStrings(false); } footer.setVisible(buttons.size() > 0); }