Examples of RhinoExpressionEngine


Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngine

        if (_generateDataURL == null) {
              _generateDataURL = Boolean.FALSE;
          }
       
        // Step one: Resolve scriptlets
        RhinoExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine()
            text = engine.resolveScriptlets(text, _context, _scriptletEngineParameters);
           
            // Step two: Filter out all old relative links and replace them with dynamic URLs
            // We can ONLY do this in pure display mode. If field gets rendered for RTF editor we must prevent this because
            // it would lead to the storage of those dynamic URLs
            if (!_editMode) {
View Full Code Here

Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngine

    }
   
    String expr = getExpression();
    Object result;
        if (expr != null) {
            RhinoExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
            ExpressionResult exprResult = engine.evaluateExpression(expr, getTMLContext(), RhinoExpressionEngine.TYPE_EXPRESSION, null);
            if (!exprResult.isError()) {
                result = exprResult.getResult();
            }
            else {
                addWarning("Error evaluation param expression: " + exprResult.getException().getClass() + exprResult.getException().getMessage(), true);
View Full Code Here

Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngine

  }

    private Object calculateOptionByExpression(String expr) throws TMLException {
        Object result = null;
        RhinoExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
        ExpressionResult exprResult = engine.evaluateExpression(expr, getTMLContext(), RhinoExpressionEngine.TYPE_EXPRESSION, null);
        if (!exprResult.isError()) {
            result = exprResult.getResult();
            return result;
        }
        else {
View Full Code Here

Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngine

        // show message in body only if condition failed
        if (!_tmlForm.conditionFailed(condition)) {
            this.setResultOutput(false);
        } else {
            // resolve scriptlets
            RhinoExpressionEngine engine = (RhinoExpressionEngine) ExpressionEngineFactory.getEngine(ExpressionEngineFactory.ENGINE_TMLSCRIPT);
            if (engine == null) {
                this.getTMLContext().addwarning("Scriptlets in tml:validate cannot be resolved. Error initializing tmlscript-engine.", false);
            } else {
                try {
                  Map params = new HashMap();
                  params.put(RhinoExpressionEngine.PARAM_LEVEL, RhinoExpressionEngine.LEVEL_SCRIPTLETS);
                    message = engine.resolveScriptlets(message, this.getTMLContext(), params);
                }
                catch (ParseException e) {
                    this.getTMLContext().addwarning("Scriptlets in tml:validate cannot be resolved.", false);
                }
                catch (WGAPIException e) {
View Full Code Here

Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngine

      }
    }
   
    // Eventually resolve scriptlets
    if (result.size() > 0 && this.stringToBoolean(this.getScriptlets()) == true) {
      RhinoExpressionEngine engine = ExpressionEngineFactory.getTMLScriptEngine();
            String resolvedResultStr = null;
            try {
              Map params = new HashMap();
              params.put(RhinoExpressionEngine.PARAM_LEVEL, RhinoExpressionEngine.LEVEL_SCRIPTLETS);
                resolvedResultStr = engine.resolveScriptlets(result.get(0), getTMLContext(), params);
                result = new ArrayList();
                result.add(resolvedResultStr);
            }
            catch (ParseException e) {
                addWarning("Error parsing scriptlets: " + e.getMessage(), false);
View Full Code Here

Examples of de.innovationgate.wgpublisher.expressions.tmlscript.RhinoExpressionEngine

   
            // clear messages
            this._messages.clear();
           
            // init expression engine
            RhinoExpressionEngine engine = (RhinoExpressionEngine) ExpressionEngineFactory.getEngine(ExpressionEngineFactory.ENGINE_TMLSCRIPT);
            if (engine == null) {
                TMLContext.getThreadMainContext().addwarning("Formvalidation cannot be processed. Error initializing tmlscript-engine.", false);
                return false;
            }       
           
            // validate each field
            Iterator fieldIt = fields.values().iterator();           
            boolean formIsValid = true;
            while (fieldIt.hasNext()) {
                TMLFormField field = (TMLFormField) fieldIt.next();
               
                // check if we have a registration for this field
                // we can only validate tml:input fields
                if (_formInfo.containsFieldRegistration(field.getName())) {
                    if (validateField(field, formContext, validationContext, engine) == false) {
                        formIsValid = false;
                    }
                }
            }
           
            // validate global validations (tml:validate tag)
            Iterator globalValidations = _formInfo.getFormValidations().keySet().iterator();
            while (globalValidations.hasNext()) {
                String expression = (String) globalValidations.next();
                FormInfo.FormValidation formValidation = (FormInfo.FormValidation) _formInfo.getFormValidations().get(expression);
                // check if formvalidation should be processed this time
                // all dependent fields (from attrib ifnoerror of tml:validate) are validated successfully
                boolean executeYet = true;
                Iterator ifnoerrorFields = formValidation.getIfnoerror().iterator();
                while (ifnoerrorFields.hasNext()) {
                    String fieldname = (String) ifnoerrorFields.next();
                    if (_messages.containsKey(fieldname)) {
                        executeYet = false;
                        break;
                    }
                }
                if (executeYet) {
                    ExpressionResult result = engine.evaluateExpression(expression, validationContext, ExpressionEngine.TYPE_EXPRESSION, buildValidationExpressionParams(null));               
                    if (result.isError()) {
                        formIsValid = false;
                        String errorMsg = "Validation-Expression could not be processed. Warning: " + result.getException().getMessage() + " - expression was: " + expression;
                        if (result.getException() != null) {
                            // See if there is a TMLFormValidationException "somewhere down there". If so we take it as negative validation result
                            Throwable cause = result.getException();
                            while (!(cause instanceof TMLFormValidationException) && cause.getCause() != null && cause.getCause() != cause) {
                                cause = cause.getCause();
                            }
                           
                            if (cause instanceof TMLFormValidationException) {
                                errorMsg = cause.getMessage();
                            }
                            else {
                                TMLContext.getThreadMainContext().addwarning(errorMsg, false);
                                TMLContext.getThreadMainContext().getlog().error("Error running validation expression", result.getException());
                            }
                        }

                        log.debug(errorMsg);                                      
                        _globalMessages.put(expression, errorMsg);
                        // clear given dependent fields
                        clearFields(formValidation.getCleariferror());
                    }
                    else if (result.isFalse()) {
                        formIsValid = false;
                        // resolve scriptlets in message
                        Map params = new HashMap();
                        params.put(RhinoExpressionEngine.PARAM_LEVEL, RhinoExpressionEngine.LEVEL_SCRIPTLETS);
                        String message = engine.resolveScriptlets(formValidation.getMessage(), validationContext, params);
                        _globalMessages.put(expression, message);                       
                        log.debug("Validation result for expression '" + expression + "' is '" + result.isTrue() + "'.");
                        // clear given dependent fields
                        clearFields(formValidation.getCleariferror());                       
                    } else if (result.isTrue()) {
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.