Example usage for org.apache.wicket.markup WicketTag getId

List of usage examples for org.apache.wicket.markup WicketTag getId

Introduction

In this page you can find the example usage for org.apache.wicket.markup WicketTag getId.

Prototype

public final String getId() 

Source Link

Document

Get the tag's component id

Usage

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 ava 2s  . c om

            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;
}