Java Code Examples for org.apache.wicket.markup.ComponentTag#getAttribute()
The following examples show how to use
org.apache.wicket.markup.ComponentTag#getAttribute() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabbedPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected WebMarkupContainer newLink(String linkId, final int index) { return new AjaxLink<Void>(linkId) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { setSelectedTab(index); target.add(TabbedPanel.this); onLinkClick(target); } @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()); } }; }
Example 2
Source File: SubscriptionStatusLink.java From onedev with MIT License | 5 votes |
@Override protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); String classes = tag.getAttribute("class"); if (classes == null) classes = ""; if (isSubscribed()) { tag.put("class", classes + " subscription-status subscribed"); tag.put("title", "Subscribed. Click to unsubscribe"); } else { tag.put("class", classes + " subscription-status unsubscribed"); tag.put("title", "Unsubscribed. Click to subscribe"); } }
Example 3
Source File: OmTextLabel.java From openmeetings with Apache License 2.0 | 5 votes |
@Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { final String vis = openTag.getAttribute(markupStream.getWicketNamespace() + WICKET_VISIBLE); if (vis != null && Boolean.FALSE.equals(Boolean.valueOf(vis))) { //skip the body return; } super.onComponentTagBody(markupStream, openTag); }
Example 4
Source File: ErrorHighlightBehavior.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@Override public void onComponentTag(final Component component, final ComponentTag tag) { if (component instanceof FormComponent< ? >) { final FormComponent< ? > fc = (FormComponent< ? >) component; if (fc instanceof AbstractSelectPanel< ? > == true) { // Do ignore the AbstractSelectPanels, otherwise the icons looks not very pretty on colored background. return; } if (fc.isValid() == true) { return; } } else if (component.getParent() != null && component.getParent() instanceof FieldsetPanel) { final FieldsetPanel fs = (FieldsetPanel) component.getParent(); if (fs.isValid() == true) { return; } } else { return; } final String value = tag.getAttribute("class"); if (StringUtils.isEmpty(value) == true) { tag.put("class", "has-error"); } else { tag.put("class", value + " has-error"); } }
Example 5
Source File: WicketPropertyResolver.java From Orienteer with Apache License 2.0 | 4 votes |
@Override public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if (tag instanceof WicketTag) { final WicketTag wTag = (WicketTag)tag; // If <wicket:property ...> if (PROPERTY.equalsIgnoreCase(wTag.getName())) { wTag.setAutoComponentTag(false); String oClassName = tag.getAttribute("class"); String refComponent = tag.getAttribute("ref"); IModel<?> model = container.getPage().getDefaultModel(); if(!Strings.isEmpty(refComponent)) { Component component = container; if(refComponent.startsWith("/")) { //If starts from / - it means that path is absolute for a page component = container.getPage().get(refComponent.substring(1)); } else if(refComponent.startsWith("#")) { //Supports format like #element:suba:subb int subs = refComponent.indexOf(":"); final String nameToFind = subs>0?refComponent.substring(1, subs):refComponent.substring(1); component = container.getPage().visitChildren((comp, visit) -> {if(comp.getId().equals(nameToFind)) visit.stop(comp);}); if(subs>0) component = component.get(refComponent.substring(subs+1)); } else { component = container.get(refComponent); } model = component.getDefaultModel(); } String objectExpression = tag.getAttribute("object"); if(!Strings.isEmpty(objectExpression)) model = new PropertyModel<ODocument>(model, objectExpression); DisplayMode mode = DisplayMode.parse(tag.getAttribute("mode"), DisplayMode.VIEW); String visualization = tag.getAttribute("visualization"); String property = tag.getAttribute("property"); if(Strings.isEmpty(property)) property = wTag.getId(); if(Strings.isEmpty(oClassName)) { Object object = model.getObject(); if(object instanceof OIdentifiable) { ODocument doc = ((OIdentifiable)object).getRecord(); oClassName = doc.getSchemaClass().getName(); } } IModel<OProperty> propertyModel = new OPropertyModel(oClassName, property); if(propertyModel.getObject()==null) throw new WicketRuntimeException("No such property '"+property+"' defined on class '"+oClassName+"'"); else return new ODocumentMetaPanel<Object>(wTag.getId(), mode.asModel(), (IModel<ODocument>)model, propertyModel).setVisualization(visualization); } } // We were not able to handle the tag return null; }