Exemplo n.º 1
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;
  }