Ejemplo n.º 1
0
  private boolean condition() throws JspException {
    HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
    i_action formAction = null;
    i_bean formBean = null;
    if (bean != null) {
      HashMap pool = (HashMap) request.getAttribute(bsController.CONST_BEAN_$INSTANCEACTIONPOOL);
      if (pool != null) formAction = (i_action) pool.get(bean);
    }
    if (formAction != null) bean = null;
    else formAction = (i_action) request.getAttribute(bsController.CONST_BEAN_$INSTANCEACTION);
    if (formAction == null) formAction = new action();
    if (bean == null) {
      formBean = formAction.get_bean();
      if (formBean != null) formBean = formBean.asBean();
    }

    if (method_prefix == null) method_prefix = "get";
    Object writeValue = null;
    Object anotherBean = null;
    if (bean == null && name != null) {
      anotherBean = formBean;
      writeValue = util_reflect.prepareWriteValueForTag(formBean, method_prefix, name, null);
    } else {
      if (name != null) {
        if (bean.equals(bsConstants.CONST_TAG_REQUESTPARAMETER))
          anotherBean = request.getParameter(name);
        if (bean.equals(bsConstants.CONST_TAG_SYSTEMPROPERTY))
          anotherBean = System.getProperty(name);
      }
      if (anotherBean == null) anotherBean = request.getAttribute(bean);
      if (anotherBean == null) anotherBean = request.getSession().getAttribute(bean);
      if (anotherBean == null)
        anotherBean = request.getSession().getServletContext().getAttribute(bean);
      if (name != null) {
        if (anotherBean == null) anotherBean = request.getAttribute(name);
        if (anotherBean == null) anotherBean = request.getSession().getAttribute(name);
        if (anotherBean == null)
          anotherBean = request.getSession().getServletContext().getAttribute(name);
      }
      if (anotherBean == null) anotherBean = util_tag.getBeanAsBSTag(bean, this);
      try {
        if (anotherBean == null)
          anotherBean =
              (bsController.getFromInfoNavigation(null, request)).find(bean).get_content();
      } catch (Exception e) {
      }
      if (anotherBean == null) anotherBean = bsController.getFromOnlySession(bean, request);
      if (anotherBean == null) anotherBean = bsController.getProperty(bean, request);

      if (anotherBean != null) {
        if (name == null) writeValue = anotherBean.toString();
        else {
          try {
            writeValue =
                util_reflect.prepareWriteValueForTag(anotherBean, method_prefix, name, null);
          } catch (Exception e) {
          }
        }
      }
    }

    if (field != null) {
      try {
        value =
            util_reflect
                .prepareWriteValueForTag(anotherBean, method_prefix, field, null)
                .toString();
      } catch (Exception e) {
      }
    }

    if (valueFromBean != null) {
      try {
        value =
            util_reflect
                .prepareWriteValueFromBean(
                    valueFromBean,
                    request,
                    (formAction == null) ? formBean : formAction.get_bean().asBean())
                .toString();
        /*
        				Object rightBean = null;
        				String nameRightBean = "";
        				String methodRightBean = "";
        				StringTokenizer st = new StringTokenizer(valueFromBean,".");

        				while(st.hasMoreTokens()){
        					String current = st.nextToken();
        					if(nameRightBean.equals("")) nameRightBean=current;
        					else{
        						if(methodRightBean.equals("")) methodRightBean=current;
        						else methodRightBean+="."+current;
        					}
        				}

        				if(rightBean==null) rightBean = request.getAttribute(nameRightBean);
        				if(rightBean==null) rightBean = request.getSession().getAttribute(nameRightBean);
        				if(rightBean!=null){
        					if(methodRightBean==null || methodRightBean.equals("")) value = rightBean.toString();
        					else{
        						try{
        							value = util_reflect.prepareWriteValueForTag(rightBean,"get",methodRightBean,null).toString();
        						}catch(Exception e){
        						}
        					}
        				}
        */
      } catch (Exception e) {
      }
    }
    try {
      writeValue =
          util_format.makeFormatedString(formatOutput, formatLanguage, formatCountry, writeValue);
    } catch (Exception e) {
    }
    if (value == null && writeValue == null) {
      if (getParent() != null && getParent() instanceof tagSwitch)
        ((tagSwitch) getParent()).setConditionBreak(true);
      return true;
    }
    if (writeValue == null || value == null) return false;
    if (upperCase != null && upperCase.toLowerCase().equals("true")) {
      if (writeValue.toString().toUpperCase().indexOf(value) == -1) {
        if (getParent() != null && getParent() instanceof tagSwitch)
          ((tagSwitch) getParent()).setConditionBreak(true);
        return true;
      } else return false;
    } else {
      if (ignoreCase != null && ignoreCase.equalsIgnoreCase("true")) {
        if (writeValue.toString().toUpperCase().indexOf(value.toUpperCase()) == -1) {
          if (getParent() != null && getParent() instanceof tagSwitch)
            ((tagSwitch) getParent()).setConditionBreak(true);
          return true;
        } else return false;
      } else {
        if (writeValue.toString().indexOf(value) == -1) {
          if (getParent() != null && getParent() instanceof tagSwitch)
            ((tagSwitch) getParent()).setConditionBreak(true);
          return true;
        } else return false;
      }
    }
  }
Ejemplo n.º 2
0
  private String getXmlFromBean() {
    String xml = null;
    HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
    i_action formAction = null;
    i_bean formBean = null;
    if (bean != null) {
      HashMap pool = (HashMap) request.getAttribute(bsController.CONST_BEAN_$INSTANCEACTIONPOOL);
      if (pool != null) formAction = (i_action) pool.get(bean);
    }
    if (formAction != null) bean = null;
    else formAction = (i_action) request.getAttribute(bsController.CONST_BEAN_$INSTANCEACTION);
    if (formAction == null) formAction = new action();
    if (bean == null) formBean = formAction.get_bean();

    if (method_prefix == null) method_prefix = "get";
    Object writeValue = null;
    Object anotherBean = null;

    if (bean == null) {
      anotherBean = formBean;
      if (anotherBean != null) {
        if (name == null) writeValue = anotherBean;
        else writeValue = util_reflect.prepareWriteValueForTag(formBean, method_prefix, name, null);
      }

    } else {

      if (bean.equals(bsConstants.CONST_TAG_REQUESTPARAMETER))
        anotherBean = request.getParameter(name);
      if (bean.equals(bsConstants.CONST_TAG_SYSTEMPROPERTY)) anotherBean = System.getProperty(name);
      if (anotherBean == null) anotherBean = request.getAttribute(bean);
      if (anotherBean == null) anotherBean = request.getSession().getAttribute(bean);
      if (anotherBean == null) anotherBean = util_tag.getBeanAsBSTag(bean, this);
      try {
        if (anotherBean == null)
          anotherBean =
              ((info_navigation)
                      request.getSession().getAttribute(bsConstants.CONST_BEAN_$NAVIGATION))
                  .find(bean)
                  .get_content();
      } catch (Exception e) {
      }

      if (anotherBean != null) {
        if (name == null) writeValue = anotherBean;
        else {
          try {
            writeValue =
                util_reflect.prepareWriteValueForTag(anotherBean, method_prefix, name, null);
          } catch (Exception e) {
          }
        }
      }
    }

    if (writeValue != null) {
      try {
        xml = util_beanMessageFactory.bean2message(writeValue);
      } catch (Exception e) {

      }
    }

    return xml;
  }