Package org.apache.isis.viewer.scimpi.dispatcher.context

Examples of org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext


    protected abstract TableContentWriter createRowBuilder(final Request request, RequestContext context,
        final String parent, final List<ObjectAssociation> allFields, ObjectAdapter collection);

    public static void write(final Request request, final ObjectAdapter collection, final String summary,
        final TableContentWriter rowBuilder, final String tableClass, final String[] rowClasses) {
        final RequestContext context = request.getContext();

        final String summarySegment = " summary=\"" + summary + "\"";
        final String classSegment = tableClass == null ? "" : (" class=\"" + tableClass + "\"");
        request.appendHtml("<table" + classSegment + summarySegment + ">");
        rowBuilder.writeHeaders(request);
        rowBuilder.writeFooters(request);

        request.appendHtml("<tbody>");
        final CollectionFacet facet = collection.getSpecification().getFacet(CollectionFacet.class);
        final Iterator<ObjectAdapter> iterator = facet.iterator(collection);
        int row = 1;
        while (iterator.hasNext()) {
            final ObjectAdapter element = iterator.next();

            context.addVariable("row", "" + (row), Scope.REQUEST);
            String cls = "";
            if (rowClasses != null) {
                cls = " class=\"" + rowClasses[row % rowClasses.length] + "\"";
            }
            request.appendHtml("<tr" + cls + ">");
View Full Code Here


    public void process(final Request request) {
        final String title = request.getOptionalProperty(FORM_TITLE);
        final String name = request.getOptionalProperty(NAME);
        final String cls = request.getOptionalProperty(CLASS, "action");
        final String object = request.getOptionalProperty(OBJECT);
        final RequestContext context = request.getContext();
        String objectId = object != null ? object : (String) context.getVariable(RequestContext.RESULT);
        ObjectAdapter adapter = MethodsUtils.findObject(context, objectId);

        // REVIEW this is common used code
        final String fieldName = request.getOptionalProperty(FIELD);
        if (fieldName != null) {
            final ObjectAssociation field = adapter.getSpecification().getAssociation(fieldName);
            if (field == null) {
                throw new ScimpiException("No field " + fieldName + " in "
                    + adapter.getSpecification().getFullIdentifier());
            }
            if (field.isVisible(IsisContext.getAuthenticationSession(), adapter).isVetoed()) {
                throw new ForbiddenException(field, ForbiddenException.VISIBLE);
            }
            IsisContext.getPersistenceSession().resolveField(adapter, field);
            adapter = field.get(adapter);
            if (adapter != null) {
                objectId = context.mapObject(adapter, Scope.INTERACTION);
            }
        }

        if (adapter != null && valid(request, adapter)) {
            final String variable = request.getOptionalProperty("param-name", RequestContext.RESULT);
            final String variableSegment = variable + "=" + objectId;

            String view = request.getOptionalProperty(VIEW);
            if (view == null) {
                view = defaultView();
            }
            view = context.fullUriPath(view);
            final String classSegment = " class=\"" + cls + "\"";
            final String titleSegment = title == null ? "" : (" title=\"" + title + "\"");
            String additionalSegment = additionalParameters(request);
            additionalSegment = additionalSegment == null ? "" : "&amp;" + additionalSegment;
            request.appendHtml("<a" + classSegment + titleSegment + " href=\"" + view + "?" + variableSegment
                + context.encodedInteractionParameters() + additionalSegment + "\">");
            request.pushNewBuffer();
            request.processUtilCloseTag();
            final String buffer = request.popBuffer();
            if (buffer.trim().length() > 0) {
                request.appendHtml(buffer);
View Full Code Here

        final String variableName = request.getRequiredProperty(NAME);
        final String defaultObjectId = request.getOptionalProperty(DEFAULT);
        final String scopeName = request.getOptionalProperty(SCOPE);
        final Scope scope = RequestContext.scope(scopeName, Scope.REQUEST);

        final RequestContext context = request.getContext();
        final ObjectAdapter sourceObject = context.getMappedObject(sourceObjectId);
        final boolean isSourceSet = sourceObject != null;
        final boolean isSourceAssignable =
            isSourceSet && (cls == null || cls.isAssignableFrom(sourceObject.getObject().getClass()));
        if (isSourceAssignable) {
            request.appendDebug("     " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
            context.addVariable(variableName, sourceObjectId, scope);
        } else {
            request.appendDebug("     " + variableName + " set to " + sourceObjectId + " (" + scope + ")");
            if (defaultObjectId != null) {
                context.addVariable(variableName, defaultObjectId, scope);
            }
            context.changeScope(variableName, scope);
        }
    }
View Full Code Here

            } else if (type.equals("object-graph")) {
                objectGraph(request);

            } else if (type.equals("object")) {
                final String value = request.getOptionalProperty(VALUE);
                final RequestContext context = request.getContext();
                final ObjectAdapter object = context.getMappedObject(value);
                final DebugString str = new DebugString();
                Dump.adapter(object, str);
                Dump.graph(object, IsisContext.getAuthenticationSession(), str);
                request.appendHtml("<h2>" + object.getSpecification().getFullIdentifier() + "</h2>");
                request.appendHtml("<pre class=\"debug\">" + str + "</pre>");
            }

        }

        if (alwaysShow || request.getContext().getDebug() == RequestContext.Debug.ON) {

            final RequestContext context = request.getContext();

            final String id = request.getOptionalProperty("object");
            if (id != null) {
                final ObjectAdapter object = context.getMappedObject(id);
                if (object instanceof DebuggableWithTitle) {
                    final DebugString debug = new DebugString();
                    ((DebuggableWithTitle) object).debugData(debug);
                    request.appendHtml("<pre class=\"debug\">" + debug + "</pre>");
                } else {
                    request.appendHtml(object.toString());
                }
            }

            final String variable = request.getOptionalProperty("variable");
            if (variable != null) {
                final Object object = context.getVariable(variable);
                request.appendHtml(variable + " => " + (object == null ? "null" : object.toString()));
            }

            final String list = request.getOptionalProperty("list");
            if (list != null) {
                final DebugString debug = new DebugString();
                context.append(debug, list);
                request.appendHtml(debug.toString());
            }

            final String uri = request.getOptionalProperty("uri");
            if (uri != null) {
                request.appendHtml("<pre class=\"debug\">");
                request.appendHtml(context.getUri());
                request.appendHtml("</pre>");
            }

        }
    }
View Full Code Here

public class RunAction extends AbstractElementProcessor {

    @Override
    public void process(final Request request) {
        final RequestContext context = request.getContext();

        final String objectId = request.getOptionalProperty(OBJECT);
        final ObjectAdapter object = MethodsUtils.findObject(context, objectId);

        final String methodName = request.getRequiredProperty(METHOD);
View Full Code Here

    }

    protected void displayVariables(final Request request) {
        request.appendHtml("<h1>Variables</h1>");
        final DebugHtmlString debug = new DebugHtmlString();
        final RequestContext context = request.getContext();
        context.append(debug, "variables");
        request.appendHtml(debug.toString());
    }
View Full Code Here

        // TODO need a mechanism for globally dealing with encoding; then use the new encode method
        final String confirmSegment = confirm == null ? "" : "&amp;" + "_" + CONFIRM + "=" + URLEncoder.encode(confirm);
        final String messageSegment =
            completionMessage == null ? "" : "&amp;" + "_" + MESSAGE + "=" + URLEncoder.encode(completionMessage);

        final RequestContext context = request.getContext();
        final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
        final String version = context.mapVersion(object);
        final ObjectAction action = MethodsUtils.findAction(object, method);

        final ActionContent parameterBlock = new ActionContent(action);
        request.setBlockContent(parameterBlock);
        request.pushNewBuffer();
View Full Code Here

public class Specification extends AbstractElementProcessor {

    @Override
    public void process(final Request request) {
        final RequestContext context = request.getContext();
        if (context.isDebugDisabled()) {
            return;
        }

        if (request.isRequested("always") || context.getDebug() == RequestContext.Debug.ON) {
            request.appendHtml("<div class=\"debug\">");
            request.appendHtml("<pre>");

            final String id = request.getOptionalProperty("object");
            final ObjectAdapter object = context.getMappedObjectOrResult(id);
            final ObjectSpecification specification = object.getSpecification();
            request.appendHtml(specification.getSingularName() + " (" + specification.getFullIdentifier() + ") \n");
            final List<ObjectAssociation> fields = specification.getAssociations();
            for (int i = 0; i < fields.size(); i++) {
                request.appendHtml("    " + fields.get(i).getName() + " ("
View Full Code Here

        if (linkAllFields) {
            for (int i = 0; i < linkFields.length; i++) {
                linkFields[i] = fields.get(i).isOneToOneAssociation();
            }
        }
        final RequestContext context = request.getContext();
        final TableContentWriter rowBuilder =
            rowBuilder(request, context, null, context.mapObject(object, Scope.REQUEST), field.getId(), fields);
        write(request, collection, summary, rowBuilder, null, null);
    }
View Full Code Here

        if (request.getContext().isDebugDisabled()) {
            request.skipUntilClose();
            return;
        }

        final RequestContext context = request.getContext();
        final Object result = context.getVariable(RequestContext.RESULT);
        request.appendHtml("<div class=\"debug\">");
        request
            .appendHtml("<a class=\"debug-link\" href=\"/debug/debug.shtml\" target=\"debug\" title=\"debug\" >...</a>");
        if (result != null) {
            request.appendHtml(" <a href=\"/debug/object.shtml?_result=" + result
View Full Code Here

TOP

Related Classes of org.apache.isis.viewer.scimpi.dispatcher.context.RequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.