Examples of FormState


Examples of it.eng.spagobi.engines.qbe.FormState

      getEngineInstance().setWorkSheetDefinition(workSheetDefinition);
     
      try {
        JSONObject jsonEncodedFormState = getAttributeAsJSONObject(FORM_STATE);
       
        FormState formState = getEngineInstance().getFormState();
        if(formState==null){
          formState = new FormState();
          getEngineInstance().setFormState(formState);
        }
        formState.setFormStateValues(jsonEncodedFormState);
       

      } catch (Exception e) {
        logger.debug("No Form State defined");
      }
View Full Code Here

Examples of it.eng.spagobi.engines.qbe.FormState

      super.service(request, response);
     
      QbeEngineInstance engineInstance = getEngineInstance();
      Assert.assertNotNull(engineInstance, "It's not possible to execute " + this.getActionName() + " service before having properly created an instance of EngineInstance class");
     
      FormState fs = engineInstance.getFormState();
      Assert.assertTrue(fs != null && fs.getConf() != null,
          "It's not possible to execute " + this.getActionName() + " service before having properly created a form template");
     
      setAttribute(FormEngineStartAction.ENGINE_INSTANCE, engineInstance);
     
    } catch(Throwable e) {
View Full Code Here

Examples of it.eng.spagobi.engines.qbe.FormState

   * @return
   * @throws JSONException
   */
  @Override
  protected JSONObject loadSmartFilterFormValues() throws JSONException{
    FormState formState = getEngineInstance().getFormState();
    if (formState == null) {
      return null;
    } else {
      return  formState.getFormStateValues();
    }
  }
View Full Code Here

Examples of it.eng.spagobi.engines.qbe.FormState

   
      qbeEngineInstance.setAnalysisMetadata( getAnalysisMetadata() );
 
     
      // initializes form state, if not already initialized (starting a new form definition)
      FormState formState = qbeEngineInstance.getFormState();
      if (formState == null) {
        logger.debug("Initializing a new form state object...");
        formState = new FormState();
        formState.setConf(new JSONObject());
        qbeEngineInstance.setFormState(formState);
      }
      //Integer subObjectId = getAttributeAsInteger("subobjectId");
     
     
      //get the form values saved (if the user has loaded a subobject)
      analysisFormState = new SmartFilterAnalysisState();
      analysisFormState.load( getAnalysisStateRowData() );
      formState.setFormStateValues(analysisFormState.getFormValues());
     
      //save the map id-->field name
      formState.setIdNameMap();
     
      qbeEngineInstance.getEnv().put("TEMPLATE", getTemplateAsSourceBean());
      String docId = this.getAttributeAsString("formDocumentId");
      if(docId != null) qbeEngineInstance.getEnv().put("DOCUMENT", docId);
      else {
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.edit.FormState

        request.setBlockContent(containedBlock);
        if (!withoutProcessing) {
            request.processUtilCloseTag();
        }

        final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);

        // TODO the list of included fields should be considered in the next
        // method (see EditObject)
        final InputField[] formFields = createFields(action, object);
        containedBlock.hideExcludedParameters(formFields);
        containedBlock.setUpValues(formFields);
        initializeFields(context, object, action, formFields);
        setDefaults(context, object, action, formFields, entryState, parameterObject.showIcon);
        String errors = null;
        if (entryState != null && entryState.isForForm(parameterObject.formId)) {
            copyEntryState(context, object, action, formFields, entryState);
            errors = entryState.getError();
        }
        overrideWithHtml(context, containedBlock, formFields);

        String formTitle;
        if (parameterObject.formTitle == null) {
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.edit.FormState

            }
        }

        String view;
        if (!isValid) {
            final FormState formState = new FormState();
            formState.setForm(actualFormId);
            formState.setError("Failed to login. Check the username and ensure that your password was entered correctly");
            FieldEditState fieldState = formState.createField("username", username);
            if (username.length() == 0) {
                fieldState.setError("User Name required");
            }
            fieldState = formState.createField("password", password);
            if (password.length() == 0) {
                fieldState.setError("Password required");
            }
            if (username.length() == 0 || password.length() == 0) {
                formState.setError("Both the user name and password must be entered");
            }
            context.addVariable(ENTRY_FIELDS, formState, Scope.REQUEST);

            view = context.getParameter(ERROR);
            context.setRequestPath("/" + view, Dispatcher.ACTION);
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.edit.FormState

        if (view != null) {
            hiddenFields.add(new HiddenInputField(VIEW, view));
        }
        hiddenFields.add(new HiddenInputField("_" + FORM_ID, formId));

        final FormState entryState = (FormState) request.getContext().getVariable(ENTRY_FIELDS);
        boolean isforThisForm = entryState != null && entryState.isForForm(formId);
        if (entryState != null && entryState.isForForm(formId)) {
        }
        final InputField nameField = createdField("username", "User Name", InputField.TEXT, isforThisForm ? entryState : null);
        final String width = request.getOptionalProperty("width");
        if (width != null) {
            final int w = Integer.valueOf(width).intValue();
            nameField.setWidth(w);
        }
        final InputField passwordField = createdField("password", "Password", InputField.PASSWORD, isforThisForm ? entryState : null);
        final InputField[] fields = new InputField[] { nameField, passwordField, };

        final String formTitle = request.getOptionalProperty(FORM_TITLE);
        final String loginButtonTitle = request.getOptionalProperty(BUTTON_TITLE, "Log in");
        final String className = request.getOptionalProperty(CLASS, "login");
        final String id = request.getOptionalProperty(ID, "logon");

        HtmlFormBuilder.createForm(request, "logon.app", hiddenFields.toArray(new HiddenInputField[hiddenFields.size()]), fields,
                className, id, formTitle, labelDelimiter, null, null, loginButtonTitle,
                isforThisForm && entryState != null ? entryState.getError() : null , null);       
    }
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.edit.FormState

        final String actualObjectId = context.mapObject(object, Scope.INTERACTION);
        final String version = context.mapVersion(object);

        final String id = request.getOptionalProperty(ID, object.getSpecification().getShortIdentifier());

        final FormState entryState = (FormState) context.getVariable(ENTRY_FIELDS);

        final ObjectSpecification specification = object.getSpecification();
        final FormFieldBlock containedBlock = new FormFieldBlock() {
            @Override
            public boolean isVisible(final String name) {
                final ObjectAssociation fld = specification.getAssociation(name);
                final boolean isVisible = fld.isVisible(IsisContext.getAuthenticationSession(), object, where).isAllowed();
                final boolean isUseable = fld.isUsable(IsisContext.getAuthenticationSession(), object, where).isAllowed();
                return isVisible && isUseable;
            }

            @Override
            public ObjectAdapter getCurrent(final String name) {
                ObjectAdapter value = null;
                if (entryState != null) {
                    final FieldEditState field2 = entryState.getField(name);
                    value = field2.getValue();
                }
                if (value == null) {
                    final ObjectAssociation fld = specification.getAssociation(name);
                    value = fld.get(object);
                }
                return value;
            }

            @Override
            public boolean isNullable(final String name) {
                final ObjectAssociation fld = specification.getAssociation(name);
                return !fld.isMandatory();
            }
        };

        request.setBlockContent(containedBlock);
        request.processUtilCloseTag();

        final AuthenticationSession session = IsisContext.getAuthenticationSession();
        List<ObjectAssociation> viewFields = specification.getAssociations(Contributed.EXCLUDED, ObjectAssociation.Filters.dynamicallyVisible(session, object, where));
        viewFields = containedBlock.includedFields(viewFields);
        final InputField[] formFields = createFields(viewFields);

        initializeFields(context, object, formFields, entryState, !hideNonEditableFields);
        setDefaults(context, object, formFields, entryState, showIcon);

        copyFieldContent(context, object, formFields, showIcon);
        overrideWithHtml(context, containedBlock, formFields);
        String errors = null;
        if (entryState != null && entryState.isForForm(formId)) {
            copyEntryState(context, object, formFields, entryState);
            errors = entryState.getError();
        }

        final String errorView = context.fullFilePath(forwardErrorTo == null ? context.getResourceFile() : forwardErrorTo);
        final List<HiddenInputField> hiddenFields = new ArrayList<HiddenInputField>();
        hiddenFields.add(new HiddenInputField("_" + OBJECT, actualObjectId));
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.edit.FormState

        final String override = context.getParameter("_" + RESULT_OVERRIDE);
        String resultName = context.getParameter("_" + RESULT_NAME);
        final String message = context.getParameter("_" + MESSAGE);
        resultName = resultName == null ? RequestContext.RESULT : resultName;

        FormState entryState = null;
        try {
            final ObjectAdapter object = MethodsUtils.findObject(context, objectId);
            // FIXME need to find method based on the set of parameters.
            // otherwise overloaded method may be incorrectly
            // selected.
            final ObjectAction action = MethodsUtils.findAction(object, methodName);
            entryState = validateParameters(context, action, object);

            AuthenticationSession session = context.getSession();
            if (session == null && action.isVisible(new AnonymousSession(), object, where).isVetoed()) {
                session = new AnonymousSession();
            }

            final Version originalVersion = context.getVersion(version);
            object.checkLock(originalVersion);
            if (entryState.isValid()) {
                final boolean hasResult = invokeMethod(context, resultName, object, action, entryState);
                String view = context.getParameter(hasResult ? "_" + VIEW : "_" + VOID);

                final int questionMark = view == null ? -1 : view.indexOf("?");
                if (questionMark > -1) {
                    final String params[] = view.substring(questionMark + 1).split("&");
                    for (final String param : params) {
                        final int equals = param.indexOf("=");
                        context.addVariable(param.substring(0, equals), param.substring(equals + 1), Scope.REQUEST);
                        view = view.substring(0, questionMark);
                    }
                }
                context.setRequestPath(view);
                if (message != null) {
                    final MessageBroker messageBroker = getMessageBroker();
                    messageBroker.addMessage(message);
                }
                if (override != null) {
                    context.addVariable(resultName, override, Scope.REQUEST);
                }
                if (!action.hasReturn() && context.getVariable(resultName) == null) {
                    context.addVariable(resultName, objectId, Scope.REQUEST);
                }
            } else {
                entryState.setForm(formId);
                context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
                context.addVariable(resultName, objectId, Scope.REQUEST);
                if (override != null) {
                    context.addVariable(resultName, override, Scope.REQUEST);
                }
                final String error = entryState.getError();
                final String view = context.getParameter("_" + ERROR);
                context.setRequestPath(view, Dispatcher.ACTION);

                final MessageBroker messageBroker = getMessageBroker();
                messageBroker.addWarning(error);
            }
        } catch (final ConcurrencyException e) {
            final ObjectAdapter adapter = getAdapterManager().getAdapterFor(e.getOid());
            String user = adapter.getOid().getVersion().getUser();
            String errorMessage = "The data for '" + adapter.titleString() + "' was changed by " + user
                    + ". Please repeat the action based on those changes.";
            getMessageBroker().addMessage(errorMessage);

            entryState.setForm(formId);
            context.addVariable(ENTRY_FIELDS, entryState, Scope.REQUEST);
            context.addVariable(resultName, objectId, Scope.REQUEST);
            if (override != null) {
                context.addVariable(resultName, override, Scope.REQUEST);
            }
            final String error = entryState.getError();
            if (error != null) {
                context.addVariable(RequestContext.ERROR, error, Scope.REQUEST);
            }

            final String view = context.getParameter("_" + ERROR);
View Full Code Here

Examples of org.apache.isis.viewer.scimpi.dispatcher.edit.FormState

        }
        return parameters;
    }

    private FormState validateParameters(final RequestContext context, final ObjectAction action, final ObjectAdapter object) {
        final FormState formState = new FormState();
        final List<ObjectActionParameter> parameters2 = action.getParameters();
        final int parameterCount = action.getParameterCount();
        for (int i = 0; i < parameterCount; i++) {
            final String fieldName = parameterName(i);
            String newEntry = context.getParameter(fieldName);

            if (newEntry != null && newEntry.equals("-OTHER-")) {
                newEntry = context.getParameter(fieldName + "-other");
            }

            if (newEntry == null) {
                // TODO figure out a better way to determine if boolean or a
                // password
                final ObjectSpecification spec = parameters2.get(i).getSpecification();
                if (spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(boolean.class)) || spec.isOfType(IsisContext.getSpecificationLoader().loadSpecification(Boolean.class))) {
                    newEntry = FALSE;
                } else {
                    newEntry = "";
                }
            }
            final FieldEditState fieldState = formState.createField(fieldName, newEntry);
            Consent consent = null;

            if (!parameters2.get(i).isOptional() && newEntry.equals("")) {
                consent = new Veto(parameters2.get(i).getName() + " required");
                formState.setError("Not all fields have been set");

            } else if (parameters2.get(i).getSpecification().getFacet(ParseableFacet.class) != null) {
                try {
                    final ParseableFacet facet = parameters2.get(i).getSpecification().getFacet(ParseableFacet.class);
                    Localization localization = IsisContext.getLocalization();
                    final String message = parameters2.get(i).isValid(object, newEntry, localization);
                    if (message != null) {
                        consent = new Veto(message);
                        formState.setError("Not all fields are valid");
                    }
                    final ObjectAdapter entry = facet.parseTextEntry(null, newEntry, localization);
                    fieldState.setValue(entry);
                } catch (final TextEntryParseException e) {
                    consent = new Veto(e.getMessage());
                    formState.setError("Not all fields are valid");
                }
            } else {
                fieldState.setValue(newEntry == null ? null : context.getMappedObject(newEntry));
            }
            if (consent != null && consent.isVetoed()) {
                fieldState.setError(consent.getReason());
            }
        }

        if (formState.isValid()) {
            final ObjectAdapter[] parameters = getParameters(action, formState);
            final Consent consent = action.isProposedArgumentSetValid(object, parameters);
            if (consent != null && consent.isVetoed()) {
                formState.setError(consent.getReason());
            }
        }

        return formState;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.