List of usage examples for org.apache.wicket MarkupContainer getPage
@Override public final Page getPage()
From source file:com.olegchir.flussonic_userlinks.wicket.IncludeResolver.IncludeResolver.java
License:Apache License
/** * Handles resolving the wicket:include tag. If a filename is specified this * file will be looked up. If a key is specified it's value is looked up * using the resource mechanism. The looked up value will then be used as * filename./*from w ww. j a v a 2s . com*/ * */ public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if ((tag instanceof WicketTag) && tagname.equalsIgnoreCase(tag.getName())) { WicketTag wtag = (WicketTag) tag; String fileName = StringUtils.trimToNull(wtag.getAttribute("file")); String fileKey = StringUtils.trimToNull(wtag.getAttribute("key")); if (null != fileKey) { if (null != fileName) { throw new MarkupException("Wrong format of: you must not use file and key attribtue at once"); } fileName = StringUtils.trimToNull(container.getString(fileKey)); if (null == fileName) { throw new MarkupException("The key inside could not be resolved"); } } else if (null == fileName) { throw new MarkupException("Wrong format of: specify the file or key attribute"); } final String id = "_" + tagname + "_" + container.getPage().getAutoIndex(); IncludeContainer ic = new IncludeContainer(id, fileName, fileKey, markupStream); ic.setRenderBodyOnly(container.getApplication().getMarkupSettings().getStripWicketTags()); // container.autoAdd(ic, markupStream); return ic; } return null; }
From source file:com.olegchir.flussonic_userlinks.wicket.SecurityResolver.SecurityResolver.java
License:Apache License
@Override public Component resolve(final MarkupContainer container, final MarkupStream markupStream, final ComponentTag tag) { // It must be <wicket:...> if (tag instanceof WicketTag) { final WicketTag wicketTag = (WicketTag) tag; // It must be <wicket:security...> if (TAGNAME_SECURITY.equalsIgnoreCase(tag.getName())) { boolean authorized = true; String rolesInOneString = StringUtils.trimToNull(wicketTag.getAttribute("onlyroles")); if (null != rolesInOneString) { Roles roles = AuthChecker.extractRoles(); authorized = roles.hasAnyRole(new Roles(rolesInOneString)); }/* w ww .j a va2 s . c o m*/ String id = wicketTag.getId() + container.getPage().getAutoIndex(); Component result = new TransparentWebMarkupContainer(id); if (!authorized) { result.setVisible(false); } return result; } } // We were not able to handle the componentId return null; }
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;/*from ww w .ja va 2 s .c om*/ // 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:org.apache.openmeetings.web.app.MessageResolver.java
License:Apache License
@Override public Component resolve(MarkupContainer container, MarkupStream markupStream, ComponentTag tag) { if (tag instanceof WicketTag) { WicketTag wtag = (WicketTag) tag; if (TAG_NAME.equals(wtag.getName())) { Long messageKey = wtag.getAttributes().getAsLong("key"); if (messageKey != null) { final String id = "_message_" + container.getPage().getAutoIndex(); Label label = new Label(id, WebSession.getString(messageKey)); label.setRenderBodyOnly(container.getApplication().getMarkupSettings().getStripWicketTags()); return label; }/* w w w . j ava 2 s. c o m*/ } } return super.resolve(container, markupStream, 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;/* w w w.jav a 2 s .c o m*/ 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; }