当前位置: 首页>>代码示例>>Java>>正文


Java Constants类代码示例

本文整理汇总了Java中org.apache.struts.taglib.html.Constants的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Constants类属于org.apache.struts.taglib.html包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setNestedProperties

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * Helper method that will set all the relevant nesting properties for the
 * provided tag reference depending on the implementation.
 * @param request object to pull references from
 * @param tag to set the nesting values into
 */
public static void setNestedProperties(HttpServletRequest request,
                                       NestedPropertySupport tag) {
  boolean adjustProperty = true;
  /* if the tag implements NestedNameSupport, set the name for the tag also */
  if (tag instanceof NestedNameSupport) {
    NestedNameSupport nameTag = (NestedNameSupport)tag;
    if (nameTag.getName() == null|| Constants.BEAN_KEY.equals(nameTag.getName())) {
      nameTag.setName(getCurrentName(request, (NestedNameSupport) tag));
    } else {
      adjustProperty = false;
    }
  }

  /* get and set the relative property, adjust if required */
  String property = tag.getProperty();
  if (adjustProperty) {
    property = getAdjustedProperty(request, property);
  }
  tag.setProperty(property);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:NestedPropertyHelper.java

示例2: processPopulate

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * <p>Populate the properties of the specified <code>ActionForm</code> instance from
 * the request parameters included with this request.  In addition,
 * request attribute <code>Globals.CANCEL_KEY</code> will be set if
 * the request was submitted with a button created by
 * <code>CancelTag</code>.</p>
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param form The ActionForm instance we are populating
 * @param mapping The ActionMapping we are using
 *
 * @exception ServletException if thrown by RequestUtils.populate()
 */
protected void processPopulate(HttpServletRequest request, HttpServletResponse response,
        ActionForm form, ActionMapping mapping) throws ServletException {
    if (form == null)
        return;

    // Populate the bean properties of this ActionForm instance
    if (log.isDebugEnabled())
        log.debug(" Populating bean properties from this request");

    form.setServlet(this.servlet);

    //*** Jaffa-customization: Moved in the custom populate method ***
    //form.reset(mapping, request);

    if (mapping.getMultipartClass() != null)
        request.setAttribute(Globals.MULTIPART_KEY, mapping.getMultipartClass());

    //*** Jaffa-customization: Invoke a custom version of the RequestUtils.populate() method, which will invoke the reset() method ***
    //RequestUtils.populate(form, mapping.getPrefix(), mapping.getSuffix(), request);
    customRequestUtilsPopulate(form, mapping.getPrefix(), mapping.getSuffix(), request, mapping);

    // Set the cancellation request attribute if appropriate
    if ((request.getParameter(Constants.CANCEL_PROPERTY) != null) || (request.getParameter(Constants.CANCEL_PROPERTY_X) != null))
        request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:40,代码来源:CustomRequestProcessor.java

示例3: renderToken

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/** This is the exact copy of the renderToken() method in Struts 1.1, except that it gets the token information from the component, as opposed to the session.
 * Generates a hidden input field with token information, if any.
 * @return A hidden input field containing the token.
 */
protected String renderToken() {
    StringBuffer results = new StringBuffer();
    FormKey fk = (FormKey) pageContext.getRequest().getAttribute(FormKey.class.getName());
    if (fk != null && fk.getComponentId() != null) {
        Component component = UserSession.getUserSession((HttpServletRequest) pageContext.getRequest()).getComponent(fk.getComponentId());
        if (component != null && component.getToken() != null) {
            results.append("<input type=\"hidden\" name=\"");
            results.append(Constants.TOKEN_KEY);
            results.append("\" value=\"");
            results.append(component.getToken());
            results.append("\" />");
        }
    }
    return results.toString();
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:20,代码来源:FormTag.java

示例4: setNestedProperties

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * Helper method that will set all the relevant nesting properties for the
 * provided tag reference depending on the implementation.
 *
 * @param request object to pull references from
 * @param tag     to set the nesting values into
 */
public static void setNestedProperties(HttpServletRequest request,
    NestedPropertySupport tag) {
    boolean adjustProperty = true;

    /* if the tag implements NestedNameSupport, set the name for the tag also */
    if (tag instanceof NestedNameSupport) {
        NestedNameSupport nameTag = (NestedNameSupport) tag;

        if ((nameTag.getName() == null)
            || Constants.BEAN_KEY.equals(nameTag.getName())) {
            nameTag.setName(getCurrentName(request, (NestedNameSupport) tag));
        } else {
            adjustProperty = false;
        }
    }

    /* get and set the relative property, adjust if required */
    String property = tag.getProperty();

    if (adjustProperty) {
        property = getAdjustedProperty(request, property);
    }

    tag.setProperty(property);
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:33,代码来源:NestedPropertyHelper.java

示例5: testComputeParameters0b

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
public void testComputeParameters0b() {
    request.getSession().setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token");

    Map map = null;

    try {
        map = tagutils.computeParameters(pageContext, null, null, null,
                null, null, null, null, true);
    } catch (JspException e) {
        fail("JspException: " + e);
    }

    assertNotNull("Map is not null", map);
    assertEquals("One parameter in the returned map", 1, map.size());
    assertTrue("Transaction token parameter present",
        map.containsKey(Constants.TOKEN_KEY));
    assertEquals("Transaction token parameter value", "token",
        (String) map.get(Constants.TOKEN_KEY));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:20,代码来源:TestTagUtils.java

示例6: initFormBean

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
protected void initFormBean() throws JspException {
    int scope = PageContext.SESSION_SCOPE;
    if ("request".equalsIgnoreCase(beanScope)) {
        scope = PageContext.REQUEST_SCOPE;
    }

    Object bean = pageContext.getAttribute(beanName, scope);
    if (bean == null) {
        bean = pageContext.getRequest().getAttribute(beanName);
        if (bean == null) {
            throw new JspException("ActionForm not found.");
        }
    }

    pageContext.setAttribute(Constants.BEAN_KEY, bean,
            PageContext.REQUEST_SCOPE);
}
 
开发者ID:kawasima,项目名称:sa-compojure,代码行数:18,代码来源:S2FormTag.java

示例7: calculateURL

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
@Override
protected String calculateURL() throws JspException {
    if (href != null) {
        int index = href.indexOf(':');
        if (index > -1) {
            return super.calculateURL();
        }
        String url = S2Functions.url(href);
        if (transaction) {
            HttpSession session = pageContext.getSession();
            if (session != null) {
                String token = (String) session
                        .getAttribute(Globals.TRANSACTION_TOKEN_KEY);
                if (token != null) {
                    String c = url != null && url.indexOf('?') >= 0 ? "&"
                            : "?";
                    url = url + c + Constants.TOKEN_KEY + "=" + token;
                }
            }
        }
        return url;
    }
    return super.calculateURL();
}
 
开发者ID:kawasima,项目名称:sa-compojure,代码行数:25,代码来源:S2LinkTag.java

示例8: initFormBean

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
@Override
protected void initFormBean() throws JspException {
    int scope = PageContext.SESSION_SCOPE;
    if ("request".equalsIgnoreCase(beanScope)) {
        scope = PageContext.REQUEST_SCOPE;
    }

    Object bean = pageContext.getAttribute(beanName, scope);
    if (bean == null) {
        bean = RequestUtils.createActionForm(
                (HttpServletRequest) pageContext.getRequest(), mapping,
                moduleConfig, servlet);
        if (bean == null) {
            throw new JspException(messages.getMessage("formTag.create",
                    beanType));
        }
        pageContext.setAttribute(beanName, bean, scope);
    }
    pageContext.setAttribute(Constants.BEAN_KEY, bean,
            PageContext.REQUEST_SCOPE);
}
 
开发者ID:seasarorg,项目名称:sa-struts,代码行数:22,代码来源:S2FormTag.java

示例9: doStartTag

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * Overriding method of the heart of the matter. Gets the relative property
 * and leaves the rest up to the original tag implementation. Sweet.
 * @return int JSP continuation directive.
 *             This is in the hands of the super class.
 */
public int doStartTag() throws JspException {
  // get the original properties
  originalName = getName();
  originalProperty = getProperty();
  originalLabelProperty = getLabelProperty();

  // request
  HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();

  // if we have a label property
  if (originalLabelProperty != null) {
    // do the label property first
    if (getName() == null|| Constants.BEAN_KEY.equals(getName())) {
      super.setLabelProperty(NestedPropertyHelper.getAdjustedProperty(request,
                                                       originalLabelProperty));
    } else {
        super.setLabelProperty(originalLabelProperty);
    }
  }

  // set the other properties
  NestedPropertyHelper.setNestedProperties(request, this);



  // let the super do it's thing
  return super.doStartTag();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:NestedOptionsTag.java

示例10: isTokenValid

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * Return <code>true</code> if there is a transaction token stored in
 * the user's current session, and the value submitted as a request
 * parameter with this action matches it.  Returns <code>false</code>
 * <ul>
 * <li>No session associated with this request</li>
 * <li>No transaction token saved in the session</li>
 * <li>No transaction token included as a request parameter</li>
 * <li>The included transaction token value does not match the
 *     transaction token in the user's session</li>
 * </ul>
 *
 * @param request The servlet request we are processing
 * @param reset Should we reset the token after checking it?
 */
public synchronized boolean isTokenValid(
    HttpServletRequest request,
    boolean reset) {

    // Retrieve the current session for this request
    HttpSession session = request.getSession(false);
    if (session == null) {
        return false;
    }

    // Retrieve the transaction token from this session, and
    // reset it if requested
    String saved = (String) session.getAttribute(Globals.TRANSACTION_TOKEN_KEY);
    if (saved == null) {
        return false;
    }

    if (reset) {
        this.resetToken(request);
    }

    // Retrieve the transaction token included in this request
    String token = request.getParameter(Constants.TOKEN_KEY);
    if (token == null) {
        return false;
    }

    return saved.equals(token);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:TokenProcessor.java

示例11: processPopulate

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * <p>Populate the properties of the specified <code>ActionForm</code> instance from
 * the request parameters included with this request.  In addition,
 * request attribute <code>Globals.CANCEL_KEY</code> will be set if
 * the request was submitted with a button created by
 * <code>CancelTag</code>.</p>
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 * @param form The ActionForm instance we are populating
 * @param mapping The ActionMapping we are using
 *
 * @exception ServletException if thrown by RequestUtils.populate()
 */
protected void processPopulate(HttpServletRequest request,
                               HttpServletResponse response,
                               ActionForm form,
                               ActionMapping mapping)
    throws ServletException {

    if (form == null) {
        return;
    }

    // Populate the bean properties of this ActionForm instance
    if (log.isDebugEnabled()) {
        log.debug(" Populating bean properties from this request");
    }
    
    form.setServlet(this.servlet);
    form.reset(mapping, request);
    
    if (mapping.getMultipartClass() != null) {
        request.setAttribute(Globals.MULTIPART_KEY,
                             mapping.getMultipartClass());
    }
    
    RequestUtils.populate(form, mapping.getPrefix(), mapping.getSuffix(),
                          request);

    // Set the cancellation request attribute if appropriate
    if ((request.getParameter(Constants.CANCEL_PROPERTY) != null) ||
        (request.getParameter(Constants.CANCEL_PROPERTY_X) != null)) {
            
        request.setAttribute(Globals.CANCEL_KEY, Boolean.TRUE);
    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:RequestProcessor.java

示例12: doStartTag

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
/**
 * Overriding method of the heart of the matter. Gets the relative
 * property and leaves the rest up to the original tag implementation.
 * Sweet.
 *
 * @return int JSP continuation directive. This is in the hands of the
 *         super class.
 */
public int doStartTag() throws JspException {
    // get the original properties
    originalName = getName();
    originalProperty = getProperty();
    originalLabelProperty = getLabelProperty();

    // request
    HttpServletRequest request =
        (HttpServletRequest) pageContext.getRequest();

    // if we have a label property
    if (originalLabelProperty != null) {
        // do the label property first
        if ((getName() == null) || Constants.BEAN_KEY.equals(getName())) {
            super.setLabelProperty(NestedPropertyHelper.getAdjustedProperty(
                    request, originalLabelProperty));
        } else {
            super.setLabelProperty(originalLabelProperty);
        }
    }

    // set the other properties
    NestedPropertyHelper.setNestedProperties(request, this);

    // let the super do it's thing
    return super.doStartTag();
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:36,代码来源:NestedOptionsTag.java

示例13: testComputeParameters3a

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
public void testComputeParameters3a() {
    request.setAttribute("attr", new MockFormBean("bar3"));
    request.getSession().setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token");

    Map map = null;

    try {
        map = tagutils.computeParameters(pageContext, "foo1", "attr",
                "stringProperty", "request", "attr", "mapProperty",
                "request", true);
    } catch (JspException e) {
        fail("JspException: " + e);
    }

    assertNotNull("Map is not null", map);
    assertEquals("Three parameter in the returned map", 3, map.size());

    assertTrue("Parameter foo1 present", map.containsKey("foo1"));
    assertTrue("Parameter foo1 value type",
        map.get("foo1") instanceof String[]);

    String[] values = (String[]) map.get("foo1");

    assertEquals("Values count", 2, values.length);

    assertTrue("Parameter foo2 present", map.containsKey("foo2"));
    assertEquals("Parameter foo2 value", "bar2", (String) map.get("foo2"));

    assertTrue("Transaction token parameter present",
        map.containsKey(Constants.TOKEN_KEY));
    assertEquals("Transaction token parameter value", "token",
        (String) map.get(Constants.TOKEN_KEY));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:34,代码来源:TestTagUtils.java

示例14: testComputeParameters3aa

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
public void testComputeParameters3aa() {
    request.setAttribute("attr", new MockFormBean("bar3"));
    request.getSession().setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token");

    Map map = null;

    try {
        map = tagutils.computeParameters(pageContext, "foo1", "attr",
                "stringProperty", "request", "attr",
                "mapPropertyArrayValues", "request", true);
    } catch (JspException e) {
        fail("JspException: " + e);
    }

    assertNotNull("Map is not null", map);
    assertEquals("Three parameter in the returned map", 3, map.size());

    assertTrue("Parameter foo1 present", map.containsKey("foo1"));
    assertTrue("Parameter foo1 value type",
        map.get("foo1") instanceof String[]);

    String[] values = (String[]) map.get("foo1");

    assertEquals("Values count", 3, values.length);

    assertTrue("Parameter foo2 present", map.containsKey("foo2"));

    String[] arrayValues = (String[]) map.get("foo2");
    String val = arrayValues[0];

    assertEquals("Parameter foo2 value", "bar2", val);

    assertTrue("Transaction token parameter present",
        map.containsKey(Constants.TOKEN_KEY));
    assertEquals("Transaction token parameter value", "token",
        (String) map.get(Constants.TOKEN_KEY));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:38,代码来源:TestTagUtils.java

示例15: testComputeParameters3b

import org.apache.struts.taglib.html.Constants; //导入依赖的package包/类
public void testComputeParameters3b() {
    request.setAttribute("attr", new MockFormBean("bar3"));
    request.getSession().setAttribute(Globals.TRANSACTION_TOKEN_KEY, "token");

    Map map = null;

    try {
        map = tagutils.computeParameters(pageContext, "foo1", "attr",
                "stringProperty", "request", "attr", "mapProperty",
                "request", true);
    } catch (JspException e) {
        fail("JspException: " + e);
    }

    assertNotNull("Map is not null", map);
    assertEquals("Three parameter in the returned map", 3, map.size());

    assertTrue("Parameter foo1 present", map.containsKey("foo1"));
    assertTrue("Parameter foo1 value type",
        map.get("foo1") instanceof String[]);

    String[] values = (String[]) map.get("foo1");

    assertEquals("Values count", 2, values.length);

    assertTrue("Parameter foo2 present", map.containsKey("foo2"));
    assertEquals("Parameter foo2 value", "bar2", (String) map.get("foo2"));

    assertTrue("Transaction token parameter present",
        map.containsKey(Constants.TOKEN_KEY));
    assertEquals("Transaction token parameter value", "token",
        (String) map.get(Constants.TOKEN_KEY));
}
 
开发者ID:SonarSource,项目名称:sonar-scanner-maven,代码行数:34,代码来源:TestTagUtils.java


注:本文中的org.apache.struts.taglib.html.Constants类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。