コード例 #1
0
  private Response invokeActionUsingAdapters(
      final ObjectAction action,
      final JsonRepresentation arguments,
      final ActionResultReprRenderer.SelfLink selfLink) {

    final RepresentationService.Context rendererContext = representationServiceContext;
    final ObjectAdapter objectAdapter = this.objectAdapter;

    final ObjectActionArgHelper argHelper =
        new ObjectActionArgHelper(rendererContext, objectAdapter, action);

    final List<ObjectAdapter> argAdapters = argHelper.parseAndValidateArguments(arguments);

    // invoke
    final ObjectAdapter mixedInAdapter = null; // action will automatically fill in if a mixin
    final ObjectAdapter[] argAdapterArr =
        argAdapters.toArray(new ObjectAdapter[argAdapters.size()]);
    final ObjectAdapter returnedAdapter =
        action.execute(objectAdapter, mixedInAdapter, argAdapterArr, InteractionInitiatedBy.USER);

    final ObjectAndActionInvocation objectAndActionInvocation =
        new ObjectAndActionInvocation(objectAdapter, action, arguments, returnedAdapter, selfLink);

    // response
    transactionService.flushTransaction();
    return representationService.actionResult(
        representationServiceContext, objectAndActionInvocation, selfLink);
  }
コード例 #2
0
ファイル: Selector.java プロジェクト: coffeefoam/isis
  private void processElement(
      final Request request, final FormFieldBlock block, final String field) {
    final String type = request.getOptionalProperty(TYPE, "dropdown");
    if (!request.isPropertySpecified(METHOD) && request.isPropertySpecified(COLLECTION)) {
      final String id = request.getRequiredProperty(COLLECTION, Request.NO_VARIABLE_CHECKING);
      final String selector =
          showSelectionList(request, id, block.getCurrent(field), block.isNullable(field), type);
      block.replaceContent(field, selector);
    } else {
      final String objectId = request.getOptionalProperty(OBJECT);
      final String methodName = request.getRequiredProperty(METHOD);
      final ObjectAdapter object = MethodsUtils.findObject(request.getContext(), objectId);
      final ObjectAction action = MethodsUtils.findAction(object, methodName);
      if (action.getParameterCount() == 0) {
        final ObjectAdapter collection = action.execute(object, new ObjectAdapter[0]);
        final String selector =
            showSelectionList(
                request, collection, block.getCurrent(field), block.isNullable(field), type);
        block.replaceContent(field, selector);
      } else {
        final String id = "selector_options";
        final String id2 = (String) request.getContext().getVariable(id);
        final String selector =
            showSelectionList(request, id2, block.getCurrent(field), block.isNullable(field), type);

        final CreateFormParameter parameters = new CreateFormParameter();
        parameters.objectId = objectId;
        parameters.methodName = methodName;
        parameters.buttonTitle = request.getOptionalProperty(BUTTON_TITLE, "Search");
        parameters.formTitle = request.getOptionalProperty(FORM_TITLE);
        parameters.className = request.getOptionalProperty(CLASS, "selector");
        parameters.id = request.getOptionalProperty(ID);

        parameters.resultName = id;
        parameters.forwardResultTo = request.getContext().getResourceFile();
        parameters.forwardVoidTo = "error";
        parameters.forwardErrorTo = parameters.forwardResultTo;
        parameters.scope = Scope.REQUEST.name();
        request.pushNewBuffer();
        ActionForm.createForm(request, parameters);
        block.replaceContent(field, selector);

        request.appendHtml(request.popBuffer());
      }
    }
  }