add(new Label("message", "If you see this message wicket is properly configured and running") { @Override protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { String myAttrib = openTag.getAttribute("myAttrib"); replaceComponentTagBody(markupStream, openTag, getDefaultModelObjectAsString().substring(0, Integer.valueOf(myAttrib))); } });
/** * Overridden to workaround wicket 7 behavior, which proccessed an error, when ajax navigation is used. */ @Override protected void onComponentTag ( final ComponentTag tag ) { super.onComponentTag ( tag ); if ( !Strings.isEmpty ( tag.getAttribute ( "href" ) ) ) // checking if href is not null or empty with org.apache.wicket.util.string.Strings class. { tag.put ( "href", "" ); //removing any contents of the href option. } }
public static ClassValue of(ComponentTag tag) { return of(tag.getAttribute("class")); }
private boolean shouldProcess(ComponentTag openTag) { // do not wrap in CDATA any <script> which has special MIME type. WICKET-4425 String typeAttribute = openTag.getAttribute("type"); boolean shouldProcess = // style elements should be processed "style".equals(openTag.getName()) || // script elements should be processed only if they have no type (HTML5 recommendation) // or the type is "text/javascript" (typeAttribute == null || "text/javascript".equalsIgnoreCase(typeAttribute)); return shouldProcess && openTag.getUserData("STYLE_OR_SCRIPT") != null; } }
private boolean shouldProcess(ComponentTag openTag) { // do not wrap in CDATA any <script> which has special MIME type. WICKET-4425 String typeAttribute = openTag.getAttribute("type"); boolean shouldProcess = // style elements should be processed "style".equals(openTag.getName()) || // script elements should be processed only if they have no type (HTML5 recommendation) // or the type is "text/javascript" (typeAttribute == null || "text/javascript".equalsIgnoreCase(typeAttribute)); return shouldProcess && openTag.getUserData("STYLE_OR_SCRIPT") != null; } }
@Override public Component newComponent(MarkupContainer container, ComponentTag tag) { return new Enclosure(tag.getId(), tag .getAttribute(EnclosureHandler.CHILD_ATTRIBUTE)); } };
@Override public Component newComponent(MarkupContainer container, ComponentTag tag) { return new Enclosure(tag.getId(), tag .getAttribute(EnclosureHandler.CHILD_ATTRIBUTE)); } };
@Override public void onComponentTag(Component component, ComponentTag tag) { StringBuilder sbClass = new StringBuilder(StringUtils.defaultString(tag.getAttribute("class"))); sbClass.append(" table dataTable"); if (isStripedRows()) sbClass.append(" table-striped"); if (isHoverRows()) sbClass.append(" table-hover"); if (isBorderedTable()) sbClass.append(" table-bordered"); if (isCondensedTable()) sbClass.append(" table-condensed"); tag.put("class", sbClass.toString().trim()); }
@Override public Component newComponent(MarkupContainer container, ComponentTag tag) { String attributeName = getInlineEnclosureAttributeName(null); String childId = tag.getAttribute(attributeName); return new InlineEnclosure(tag.getId(), childId); } });
/** * Gets attribute value * @param tag * @param attribute * @return */ public static String getAttribute(ComponentTag tag, String attribute) { Args.notNull(tag, "tag"); Args.notNull(attribute, "attribute"); return tag.getAttribute(attribute); }
@Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); String cssClass = tag.getAttribute("class"); if (getSelectedTab() == index) { cssClass += " active"; } else cssClass = "nav-link"; tag.put("class", cssClass.trim()); } };
@Override public Component newComponent(MarkupContainer container, ComponentTag tag) { String attributeName = getInlineEnclosureAttributeName(null); String childId = tag.getAttribute(attributeName); return new InlineEnclosure(tag.getId(), childId); } });
@Override public void onComponentTag(Component component, ComponentTag tag) { if (tag.getType() != TagType.CLOSE) { String oldValue = tag.getAttribute(name); tag.put(name, onAttribute.apply(oldValue)); } } };
@Override public void onComponentTag(Component component, ComponentTag tag) { if (tag.getType() != TagType.CLOSE) { String oldValue = tag.getAttribute(name); tag.put(name, onAttribute.apply(oldValue)); } } };
@Override public Component resolve(final MarkupContainer container, final MarkupStream markupStream, final ComponentTag tag) { if ((tag instanceof WicketTag) && ((WicketTag)tag).isEnclosureTag()) { // Yes, we handled the tag return new Enclosure(tag.getId(), tag.getAttribute(EnclosureHandler.CHILD_ATTRIBUTE)); } // We were not able to handle the tag return null; } }
@Override public void onComponentTag( Component component, ComponentTag tag ) { super.onComponentTag( component, tag ); if ( component.hasErrorMessage() ) { String oldClass = tag.getAttribute( "class" ); if ( oldClass == null ) { oldClass = ""; } tag.put( "class", oldClass + " hasError" ); } } }
...new Link ( "link" ) { @Override protected void onComponentTag ( final ComponentTag tag ) { super.onComponentTag ( tag ); // you should always call super. tag.getName (); // get name of the tag: a/div/span.. tag.setName ( "span" ); // set tag's name. tag.getAttribute ( "name" ); // get 'name' attribute's value. tag.put ( "name", "#" ); // set 'name' attribute's value } }
@Override public Component resolve(final MarkupContainer container, final MarkupStream markupStream, final ComponentTag tag) { if ((tag instanceof WicketTag) && ((WicketTag)tag).isEnclosureTag()) { // Yes, we handled the tag return new Enclosure(tag.getId(), tag.getAttribute(EnclosureHandler.CHILD_ATTRIBUTE)); } // We were not able to handle the tag return null; } }
/** * Remove data-options value * @param tag * @param value * @return */ public static ComponentTag removeDataOptions(ComponentTag tag, String value) { Args.notNull(tag, "tag"); Args.notNull(value, "value"); if (hasDataOptions(tag, value)) { tag.put("data-options", removeToken(tag.getAttribute("data-options"), value, DATA_OPTIONS_SEPARATOR)); } return tag; }
@Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); ClassValue css = ClassValue.of(tag.getAttribute("class")); css.with("navbar").with("navbar-fixed-top"); tag.put("class", css.toString()); } }