List of usage examples for org.apache.wicket.markup WicketTag getAttribute
public final String getAttribute(String name)
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.// www.j a v a 2s. c om * */ 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 w w . ja va2 s . com*/ 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; }