/*
   * (non-Javadoc)
   *
   * @see org.hdiv.filter.IValidationHelper#endPage(javax.servlet.http. HttpServletRequest)
   */
  public void endPage(HttpServletRequest request) {

    // End page in datacomposer
    boolean exist = HDIVUtil.isDataComposer(request);
    if (exist) {
      IDataComposer dataComposer = HDIVUtil.getDataComposer(request);
      dataComposer.endPage();
    }
  }
Пример #2
0
  /**
   * Generate the required input tag, followed by the optional rendered text. Support for <code>
   * write</code> property since Struts 1.1.
   *
   * @exception JspException if a JSP exception has occurred
   * @see org.hdiv.dataComposer.IDataComposer#composeFormField(String, String, boolean, String)
   */
  public int doStartTag() throws JspException {

    try {
      String hiddenValue = value;
      Object lookupValue = null;

      if (value == null) {
        // locate and return the specified property of the specified bean
        lookupValue = TagUtils.getInstance().lookup(pageContext, name, property, null);

        if (lookupValue != null) {
          hiddenValue = lookupValue.toString();
        }
      }

      HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
      IDataComposer dataComposer = HDIVUtil.getDataComposer(request);
      this.encodedValue = dataComposer.composeFormField(prepareName(), hiddenValue, false, null);

      // Render the result to the output writer
      TagUtils.getInstance().write(this.pageContext, this.renderInputElement());

      // Is rendering the value separately requested?
      if (!write) {
        return (EVAL_BODY_TAG);
      }

      // Calculate the value to be rendered separately
      // * @since Struts 1.1
      String results = null;
      if (value != null) {
        results = TagUtils.getInstance().filter(value);
      } else {
        if (lookupValue == null) {
          results = "";
        } else {
          results = TagUtils.getInstance().filter(lookupValue.toString());
        }
      }

      // Render the result to the output writer
      TagUtils.getInstance().write(pageContext, results);
      return (EVAL_BODY_TAG);

    } catch (JspException e) {
      log.debug(e.getMessage());
      throw e;
    }
  }
Пример #3
0
  @Override
  protected void setUp() throws Exception {

    super.setUp();
    dataComposer = HDIVUtil.getDataComposer(request);
    dataComposer.beginRequest(Method.POST, "/testFormTag.do");
  }
  /**
   * Extra hidden fields with the HDIV state value.
   *
   * @param request request object
   * @return hidden field name/value
   */
  public Map<String, String> getExtraHiddenFields(HttpServletRequest request) {

    IDataComposer dataComposer =
        (IDataComposer) request.getAttribute(HDIVUtil.DATACOMPOSER_REQUEST_KEY);
    Map<String, String> extraFields = new HashMap<String, String>();

    if (dataComposer == null || dataComposer.isRequestStarted() == false) {
      return extraFields;
    }

    String requestId = dataComposer.endRequest();

    if (requestId != null && requestId.length() > 0) {
      String hdivStateParam = (String) request.getSession().getAttribute(Constants.HDIV_PARAMETER);
      extraFields.put(hdivStateParam, requestId);
    }
    return extraFields;
  }
  /**
   * Process form field value.
   *
   * @param request request object
   * @param name the name of the field
   * @param value the value of the field
   * @param type the type of the field
   * @return processed field value
   */
  public String processFormFieldValue(
      HttpServletRequest request, String name, String value, String type) {

    if (name == null) {
      return value;
    }

    IDataComposer dataComposer =
        (IDataComposer) request.getAttribute(HDIVUtil.DATACOMPOSER_REQUEST_KEY);

    if (dataComposer == null || dataComposer.isRequestStarted() == false) {
      return value;
    }

    if (isEditable(type)) {
      dataComposer.compose(name, value, true, type);
      return value;
    } else {
      String result = dataComposer.compose(name, value, false, type);
      return result;
    }
  }