List of usage examples for org.apache.wicket.markup ComponentTag getId
public final String getId()
From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java
License:Open Source License
/** * Renders the next element of markup in the given markup stream. * // w ww.j a v a2s. c om * @param markupStream The markup stream */ private final void _renderNext(final MarkupStream markupStream) { // Get the current markup element final MarkupElement element = markupStream.get(); // If it a tag like <wicket..> or <span wicket:id="..." > if ((element instanceof ComponentTag) && !markupStream.atCloseTag()) { // Get element as tag final ComponentTag tag = (ComponentTag) element; // Get component id final String id = tag.getId(); // Get the component for the id from the given container final Component component = get(id); // Failed to find it? if (component != null && orderedHeaders.get(renderColumnIdx) != null) { if (component instanceof SortableCellViewHeader) { int currentIdx = markupStream.getCurrentIndex(); renderHeader(renderColumnIdx, markupStream); renderColumnIdx++; markupStream.setCurrentIndex(currentIdx); markupStream.skipComponent(); } } else { // 2rd try: Components like Border and Panel might implement // the ComponentResolver interface as well. MarkupContainer container = this; while (container != null) { if (container instanceof SortableCellViewHeaders) { // we should created the corect header, use the id from the orderedHeaders String headerId = orderedHeaderIds.get(renderColumnIdx); renderColumnIdx++; if (resolve(markupStream, tag, headerId)) { return; } } if (container instanceof IComponentResolver) { if (((IComponentResolver) container).resolve(this, markupStream, tag)) { return; } } container = container.findParent(MarkupContainer.class); } // 3rd try: Try application's component resolvers final List<IComponentResolver> componentResolvers = getApplication().getPageSettings() .getComponentResolvers(); final Iterator<IComponentResolver> iterator = componentResolvers.iterator(); while (iterator.hasNext()) { final IComponentResolver resolver = iterator.next(); if (resolver.resolve(this, markupStream, tag)) { return; } } if (tag instanceof WicketTag) { if (((WicketTag) tag).isChildTag()) { markupStream.throwMarkupException("Found " + tag.toString() + " but no <wicket:extend>"); //$NON-NLS-1$ //$NON-NLS-2$ } else { markupStream.throwMarkupException("Failed to handle: " + tag.toString()); //$NON-NLS-1$ } } // No one was able to handle the component id markupStream.throwMarkupException("Unable to find component with id '" + id + "' in " + this //$NON-NLS-1$//$NON-NLS-2$ + ". This means that you declared wicket:id=" + //$NON-NLS-1$ id + " in your markup, but that you either did not add the " //$NON-NLS-1$ + "component to your page at all, or that the hierarchy does not match."); //$NON-NLS-1$ } } else { getResponse().write(element.toCharSequence()); markupStream.next(); } }
From source file:com.servoy.j2db.server.headlessclient.dataui.SortableCellViewHeaders.java
License:Open Source License
private void renderHeader(int headerIdx, final MarkupStream markupStream) { Component header = orderedHeaders.get(headerIdx); markupStream.setCurrentIndex(headerMarkupStartIdx); boolean found = false; MarkupElement element;//w w w. jav a 2s.c o m while (!found) { element = markupStream.next(); if ((element instanceof ComponentTag) && !markupStream.atCloseTag()) { // Get element as tag final ComponentTag tag = (ComponentTag) element; // Get component id final String id = tag.getId(); // Get the component for the id from the given container final Component component = get(id); // Failed to find it? if (component != null) { if (component.equals(header)) { component.render(markupStream); found = true; } } } } }
From source file:com.userweave.application.UserWeaveApplication.java
License:Open Source License
@Override public void init() { super.init(); getComponentInstantiationListeners().add(new SpringComponentInjector(this)); setupAuthorization();//w ww. j av a 2s .c om mountPages(); mountResources(); getMarkupSettings().setStripWicketTags(true); setupErrorHandling(); setupProductionSettings(); setDefaultResourceLocale(LocalizationUtils.getDefaultLocale()); getMarkupSettings().setMarkupFactory(new MarkupFactory() { @Override public MarkupParser newMarkupParser(MarkupResourceStream resource) { MarkupParser markupParser = new MarkupParser(resource); markupParser.add(new AbstractMarkupFilter() { // @Override // public MarkupElement nextTag() throws ParseException { // // // Get the next tag. If null, no more tags are available // final ComponentTag tag = (ComponentTag)getParent().nextTag(); // if ( null == tag || null != tag.getId() ) // return tag; // // // Process open <html> tags // if( null != tag.getName() && tag.getName().equals( "html" ) && tag.isOpen()) // { // String language = UserWeaveSession.get().getLocale().getLanguage(); // tag.getAttributes().put("lang", language); // tag.getAttributes().put("xml:lang", language); // tag.setModified( true ); // } // // return tag; // } @Override protected MarkupElement onComponentTag(ComponentTag tag) throws ParseException { if (null == tag || null != tag.getId()) { return tag; } // Process open <html> tags if (null != tag.getName() && tag.getName().equals("html") && tag.isOpen()) { String language = UserWeaveSession.get().getLocale().getLanguage(); tag.getAttributes().put("lang", language); tag.getAttributes().put("xml:lang", language); tag.setModified(true); } return tag; } }); return markupParser; } }); /* * @see: migration guide to wicket 1.5 Request cycle * * Instead of overrride newRequestCycle, we have to create a factory, * that builds our custom RequestCycle. */ setRequestCycleProvider(new IRequestCycleProvider() { @Override public RequestCycle get(RequestCycleContext context) { return new UserWeaveWebRequestCycle(context); } }); /* * @see: https://cwiki.apache.org/WICKET/request-mapping.html * * newRequestCycleProcessor is obsolete, so we replace the * CryptedUrlWebRequestCodingStrategy with a CryptoMapper, */ // if(ENCRYPTION) // { // setRootRequestMapper(new CryptoMapper(getRootRequestMapper(), this)); // } // add custom listener for runtime exceptions. getRequestCycleListeners().add(new AbstractRequestCycleListener() { @Override public IRequestHandler onException(RequestCycle cycle, Exception ex) { if (ex instanceof RuntimeException) { ((UserWeaveWebRequestCycle) cycle).handleRuntimeException((RuntimeException) ex); } return null; } }); // disable caching strategy getResourceSettings().setCachingStrategy(NoOpResourceCachingStrategy.INSTANCE); }
From source file:com.userweave.pages.test.singleSurveyTestUI.SingleFormSurveyUI.java
License:Open Source License
/** * Since isTransparentResolver() has disaperade in wicket 1.5, * we need to resolve manualy. //from w w w. j ava2 s.c om */ @Override public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if (tag.getId().equals(FORM_MARKUP_ID)) { return getForm(); } Component resolvedComponent = getParent().get(tag.getId()); if (resolvedComponent != null && getPage().wasRendered(resolvedComponent)) { return null; } return resolvedComponent; }
From source file:com.userweave.pages.user.configuration.UserEditBasePanel.java
License:Open Source License
@Override public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if (tag.getId().equals("form")) { return getForm(); }// w ww. j a v a2s.c o m Component resolvedComponent = getParent().get(tag.getId()); if (resolvedComponent != null && getPage().wasRendered(resolvedComponent)) { return null; } return resolvedComponent; }
From source file:net.jawr.web.wicket.JawrWicketLinkResolver.java
License:Apache License
@Override public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { Component component = null;/*www. j av a 2s . c o m*/ // Only component tags have the id == "_jawrAutolink_" String tagName = tag.getName(); if (tag.getId().equals(JawrWicketLinkTagHandler.AUTOLINK_ID)) { // create the right component depending on the tag name WebMarkupContainer jawrTag = null; final String id = tag.getId() + container.getPage().getAutoIndex(); if (tagName.equalsIgnoreCase(IMG_TAG_NAME)) { jawrTag = new JawrImageReference(id); } else if (tagName.equalsIgnoreCase("input") && tag.getAttribute("type").equals(IMAGE_TAG_NAME)) { jawrTag = new JawrHtmlImageReference(id); } else if (tagName.equalsIgnoreCase("script")) { jawrTag = new JawrJavascriptReference(id); } else if (tagName.equalsIgnoreCase("link")) { jawrTag = new JawrStylesheetReference(id); } if (jawrTag != null) { container.autoAdd(jawrTag, markupStream); } // Yes, we handled the tag return jawrTag; } else if (tag instanceof WicketTag) { // For tag wicket:jawr if (tagName.equals("jawr")) { final String id = tag.getId() + container.getPage().getAutoIndex(); component = new TransparentWebMarkupContainer(id); component.setRenderBodyOnly(true); container.autoAdd(component, markupStream); // Yes, we handled the tag return component; } } // We were not able to handle the tag return null; }
From source file:net.jawr.web.wicket.JawrWicketLinkTagHandler.java
License:Apache License
/** * Analyze the tag. If return value == true, a jawr component will be * created./* ww w . ja v a 2 s. c o m*/ * * @param tag * The current tag being parsed * @return If true, tag will become auto-component */ protected boolean analyzeAutolinkCondition(final ComponentTag tag) { if (tag.getId() == null) { if (checkRef(tag)) { return true; } } return false; }
From source file:org.apache.openmeetings.web.app.MessageTagHandler.java
License:Apache License
@Override protected final MarkupElement onComponentTag(ComponentTag tag) throws ParseException { if (tag.isClose()) { return tag; }/*from w w w . ja v a2 s . c om*/ final String wicketMessageAttribute = tag.getAttributes().getString(getWicketMessageAttrName()); if (Strings.isEmpty(wicketMessageAttribute) == false) { // check if this tag is raw markup if (tag.getId() == null) { // if this is a raw tag we need to set the id to something so // that wicket will not merge this as raw markup and instead // pass it on to a resolver tag.setId(getWicketMessageIdPrefix()); tag.setAutoComponentTag(true); tag.setModified(true); } tag.addBehavior(new AttributeLocalizer(getWicketMessageAttrName())); } return tag; }
From source file:org.apache.openmeetings.web.app.MessageTagHandler.java
License:Apache License
public Component resolve(final MarkupContainer container, final MarkupStream markupStream, final ComponentTag tag) { // localize any raw markup that has wicket:message attrs if ((tag != null) && (tag.getId().startsWith(getWicketMessageIdPrefix()))) { Component wc;//from w w w. j a va 2 s. c om int autoIndex = container.getPage().getAutoIndex(); String id = getWicketMessageIdPrefix() + autoIndex; if (tag.isOpenClose()) { wc = new WebComponent(id); } else { wc = new TransparentWebMarkupContainer(id); } return wc; } return null; }
From source file:org.hippoecm.frontend.editor.plugins.field.TransparentFragment.java
License:Apache License
@Override public Component resolve(final MarkupContainer container, final MarkupStream markupStream, final ComponentTag tag) { final String id = tag.getId(); final Component child = get(id); if (child != null) { return child; }/*w w w . j a va 2 s . c om*/ return getParent().get(id); }