Example usage for org.apache.wicket Component RENDER

List of usage examples for org.apache.wicket Component RENDER

Introduction

In this page you can find the example usage for org.apache.wicket Component RENDER.

Prototype

Action RENDER

To view the source code for org.apache.wicket Component RENDER.

Click Source Link

Document

Action used with IAuthorizationStrategy to determine whether a component and its children are allowed to be rendered.

Usage

From source file:rzd.vivc.ideax.wicket.autorization.XAutorisationStrategy.java

@Override
public boolean isActionAuthorized(Component cmpnt, Action action) {
    //?  ?.   /*from   ww w.  j  ava  2 s  .c  om*/
    if (action.equals(Component.RENDER)) {
        Class<? extends Component> c = cmpnt.getClass();
        DirectorOnly directorOnly = c.getAnnotation(DirectorOnly.class);
        if (directorOnly != null) {
            UserSession sess = UserSession.get();
            return sess.isAuthenticated() && sess.getUser().isDirector();
        }
    }
    return true;
}

From source file:sf.wicklet.gwt.server.ajax.impl.GwtAjaxWickletResponse.java

License:Apache License

@Override
protected void writeComponent(final Response response, final String markupId, final Component component,
        final String encoding) {
    if (component.getRenderBodyOnly() == true) {
        throw new IllegalStateException(
                "Ajax render cannot be called on component that has setRenderBodyOnly enabled. Component: "
                        + component.toString());
    }//from  www .j  a  v a  2 s. c o  m
    component.setOutputMarkupId(true);
    // substitute our encoding response for the real one so we can capture
    // component's markup in a manner safe for transport inside CDATA block
    encodingBodyResponse.reset();
    RequestCycle.get().setResponse(encodingBodyResponse);
    // Initialize temporary variables
    final Page page = component.findParent(Page.class);
    if (page == null) {
        // dont throw an exception but just ignore this component, somehow
        // it got removed from the page.
        AbstractGwtAjaxResponse.LOG.debug("component: " + component + " with markupid: " + markupId
                + " not rendered because it was already removed from page");
        return;
    }
    page.startComponentRender(component);
    try {
        component.prepareForRender();
        // render any associated headers of the component
        writeHeaderContribution(response, component);
    } catch (final RuntimeException e) {
        try {
            component.afterRender();
        } catch (final RuntimeException e2) {
            // ignore this one could be a result off.
        }
        // Restore original response
        RequestCycle.get().setResponse(response);
        encodingBodyResponse.reset();
        throw e;
    }
    try {
        component.render();
    } catch (final RuntimeException e) {
        RequestCycle.get().setResponse(response);
        encodingBodyResponse.reset();
        throw e;
    }
    page.endComponentRender(component);
    // Restore original response
    RequestCycle.get().setResponse(response);
    response.write("<component id=\"");
    response.write(markupId);
    response.write("\" ");
    //        if (encodingBodyResponse.isContentsEncoded()) {
    //            response.write(" encoding=\"");
    //            response.write(getEncodingName());
    //            response.write("\" ");
    //        }
    response.write(" encoding=\"escaped-xml\" >");
    response.write(XmlUtil.escXml(encodingBodyResponse.getContents()));
    response.write("</component>");
    encodingBodyResponse.reset();
}