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


Java StripesConstants类代码示例

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


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

示例1: getValue

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Attempts to resolve the value as described in the class level javadoc.
 * @param ctx the ELContext for the expression
 * @param base the object on which the property resides (null == root property)
 * @param prop the name of the property being looked for
 * @return the value of the property or null if one can't be found
 */
@Override
public Object getValue(ELContext ctx, Object base, Object prop) {
    if (ExpressionExecutorSupport.isSelfKeyword(this.bean, prop)) {
        ctx.setPropertyResolved(true);
        return this.currentValue;
    }
    else if (StripesConstants.REQ_ATTR_ACTION_BEAN.equals(prop)) {
        ctx.setPropertyResolved(true);
        return this.bean;
    }
    else {
        try {
            base = base == null ? this.bean : base;
            Object retval = BeanUtil.getPropertyValue(String.valueOf(prop), base);
            ctx.setPropertyResolved(true);
            return retval;
        }
        catch (Exception e) { return null; }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:28,代码来源:Jsp21ExpressionExecutor.java

示例2: setSourcePage

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * All requests to Stripes that can generate validation errors are required to supply a
 * request parameter telling Stripes where the request came from. If you do not supply a
 * value for this parameter then the value of MockRoundTrip.DEFAULT_SOURCE_PAGE will be used.
 */
public void setSourcePage(String url) {
    if (url != null) {
        url = CryptoUtil.encrypt(url);
    }
    setParameter(StripesConstants.URL_KEY_SOURCE_PAGE, url);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:12,代码来源:MockRoundtrip.java

示例3: getValueFromActionBean

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Helper method that will check to see if there is an ActionBean present in the request,
 * and if so, retrieve the value for this tag from the ActionBean.
 *
 * @param tag the tag whose values to look for
 * @return an Object, possibly null, representing the tag's value
 */
protected Object getValueFromActionBean(InputTagSupport tag) throws StripesJspException {
    ActionBean actionBean = tag.getParentFormTag().getActionBean();
    Object value = null;

    if (actionBean != null) {
        try {
            value = BeanUtil.getPropertyValue(tag.getName(), actionBean);
        }
        catch (ExpressionException ee) {
            if (!StripesConstants.SPECIAL_URL_KEYS.contains(tag.getName())) {
                log.info("Could not find property [", tag.getName(), "] on ActionBean.", ee);
            }
        }
    }

    return value;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:DefaultPopulationStrategy.java

示例4: getLocalizedFieldName

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Attempts to fetch a "field name" resource from the localization bundle. Delegates
 * to {@link LocalizationUtility#getLocalizedFieldName(String, String, Class, java.util.Locale)}
 *
 * @param name the field name or resource to look up
 * @return the localized String corresponding to the name provided
 * @throws StripesJspException
 */
protected String getLocalizedFieldName(final String name) throws StripesJspException {
    Locale locale = getPageContext().getRequest().getLocale();
    FormTag form = null;

    try { form = getParentFormTag(); }
    catch (StripesJspException sje) { /* Do nothing. */}

    String actionPath = null;
    Class<? extends ActionBean> beanClass = null;

    if (form != null) {
        actionPath = form.getAction();
        beanClass = form.getActionBeanClass();
    }
    else {
        ActionBean mainBean = (ActionBean) getPageContext().getRequest().getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);
        if (mainBean != null) {
            beanClass = mainBean.getClass();
        }
    }
    return LocalizationUtility.getLocalizedFieldName(name, actionPath, beanClass, locale);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:InputTagSupport.java

示例5: getExcludes

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/** Returns the list of parameters that should be excluded from the hidden tag. */
protected Set<String> getExcludes(FormTag form) {
    Set<String> excludes = new HashSet<String>();
    excludes.addAll(form.getRegisteredFields());
    excludes.add(StripesConstants.URL_KEY_SOURCE_PAGE);
    excludes.add(StripesConstants.URL_KEY_FIELDS_PRESENT);
    excludes.add(StripesConstants.URL_KEY_EVENT_NAME);
    excludes.add(StripesConstants.URL_KEY_FLASH_SCOPE_ID);

    // Use the submitted action bean to eliminate any event related parameters
    ServletRequest request = getPageContext().getRequest();
    ActionBean submittedActionBean = (ActionBean) request
            .getAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);

    if (submittedActionBean != null) {
        String eventName = submittedActionBean.getContext().getEventName();
        if (eventName != null) {
            excludes.add(eventName);
            excludes.add(eventName + ".x");
            excludes.add(eventName + ".y");
        }
    }
    return excludes;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:WizardFieldsTag.java

示例6: getRequestedPath

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * <p>
 * Get the path from the given request. This method is different from
 * {@link HttpServletRequest#getRequestURI()} in that it concatenates and returns the servlet
 * path plus the path info from the request. These are usually the same, but in some cases they
 * are not.
 * </p>
 * <p>
 * One case where they are known to differ is when a request for a directory is forwarded by the
 * servlet container to a welcome file. In that case, {@link HttpServletRequest#getRequestURI()}
 * returns the path that was actually requested (e.g., {@code "/"}), whereas the servlet path
 * plus path info is the path to the welcome file (e.g. {@code "/index.jsp"}).
 * </p>
 */
public static String getRequestedPath(HttpServletRequest request) {
    String servletPath, pathInfo;

    // Check to see if the request is processing an include, and pull the path
    // information from the appropriate source.
    // only request attributes need decoding, not servletPath and pathInfo
    // see http://www.stripesframework.org/jira/browse/STS-899

    servletPath = urlDecodeNullSafe((String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH));
    if (servletPath != null) {
        pathInfo = urlDecodeNullSafe((String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH_INFO));
    }
    else {
        servletPath = request.getServletPath();
        pathInfo = request.getPathInfo();
    }

    if (servletPath == null)
        return pathInfo == null ? "" : pathInfo;
    else if (pathInfo == null)
        return servletPath;
    else
        return servletPath + pathInfo;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:HttpUtil.java

示例7: execute

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Attempts to forward the user to the specified path.
 * @throws ServletException thrown when the Servlet container encounters an error
 * @throws IOException thrown when the Servlet container encounters an error
 */
public void execute(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {

    if (status != null) {
        response.setStatus(status);
    }
    String path = getUrl(request.getLocale());

    // Set event name as a request attribute
    String oldEvent = (String) request.getAttribute(StripesConstants.REQ_ATTR_EVENT_NAME);
    request.setAttribute(StripesConstants.REQ_ATTR_EVENT_NAME, event);

    // Figure out if we're inside an include, and use an include instead of a forward
    if (autoInclude && request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH) != null) {
        log.trace("Including URL: ", path);
        request.getRequestDispatcher(path).include(request, response);
    }
    else {
        log.trace("Forwarding to URL: ", path);
        request.getRequestDispatcher(path).forward(request, response);
    }

    // Revert event name to its original value
    request.setAttribute(StripesConstants.REQ_ATTR_EVENT_NAME, oldEvent);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:ForwardResolution.java

示例8: doStartTag

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Determine if the body should be evaluated or not.
 *
 * @return EVAL_BODY_INCLUDE if the body should be included, or SKIP_BODY
 * @throws JspException when the tag cannot (decide if to) write the body content
 */
@Override
public int doStartTag() throws JspException {

    // Retrieve the action bean and event handler to secure.

    SecurityAwareActionBean actionBean = (SecurityAwareActionBean) pageContext
            .findAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN);

    boolean render = !actionBean.isAtLeastOneSecuredTagRendered();

    if (actionBean.getContext().getValidationErrors().size() > 0) {
        render = false;
    }
    return render ? EVAL_BODY_AGAIN : SKIP_BODY;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:NoSecuredTagRenderedTag.java

示例9: preparePage

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
protected void preparePage(ContainerRequestContext requestContext, Object resource) {
    if(resource instanceof PageAction) {
        PageAction pageAction = (PageAction) resource;
        HttpServletRequest request = ElementsThreadLocals.getHttpServletRequest();
        request.setAttribute(StripesConstants.REQ_ATTR_ACTION_BEAN, pageAction);
        if(!pageAction.getPageInstance().isPrepared()) {
            ElementsActionBeanContext context = new ElementsActionBeanContext();
            context.setRequest(request);
            context.setResponse(response);
            context.setServletContext(request.getServletContext());
            context.setEventName("");
            String path = requestContext.getUriInfo().getPath();
            if(!path.startsWith("/")) {
                path = "/" + path;
            }
            context.setActionPath(path); //TODO
            pageAction.setContext(context);
            Resolution resolution = pageAction.preparePage();
            if(resolution != null) {
                requestContext.abortWith(Response.serverError().entity(resolution).build());
            }
        }
    }
}
 
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:25,代码来源:PortofinoFilter.java

示例10: resolveVariable

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Recognizes a couple of special variables, and if the property requested
 * isn't one of them, just looks up a property on the action bean.
 *
 * @param property the name of the variable/property being looked for
 * @return the property value or null
 * @throws javax.servlet.jsp.el.ELException
 */
public Object resolveVariable(String property) throws ELException {
    if (isSelfKeyword(bean, property)) {
        return this.currentValue;
    }
    else if (StripesConstants.REQ_ATTR_ACTION_BEAN.equals(property)) {
        return this.bean;
    }
    else {
        try { return BeanUtil.getPropertyValue(property, bean); }
        catch (Exception e) { return null; }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:ExpressionExecutorSupport.java

示例11: getTagStack

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
    * Fetches a tag stack that is stored in the request. This tag stack is used to help
    * Stripes tags find one another when they are spread across multiple included JSPs
    * and/or tag files - situations in which the usual parent tag relationship fails.
    */
   @SuppressWarnings("unchecked")
protected Stack<StripesTagSupport> getTagStack() {
       Stack<StripesTagSupport> stack = (Stack<StripesTagSupport>)
               getPageContext().getRequest().getAttribute(StripesConstants.REQ_ATTR_TAG_STACK);

       if (stack == null) {
           stack = new Stack<StripesTagSupport>();
           getPageContext().getRequest().setAttribute(StripesConstants.REQ_ATTR_TAG_STACK, stack);
       }

       return stack;
   }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:StripesTagSupport.java

示例12: getValue

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Implementation of the interface method that will follow the search described in the class
 * level JavaDoc and attempt to find a value for this tag.
 *
 * @param tag the form input tag whose value to populate
 * @return Object will be one of null, a single Object or an Array of Objects depending upon
 *         what was submitted in the prior request, and what is declared on the ActionBean
 */
@Override
public Object getValue(InputTagSupport tag) throws StripesJspException {
    // If the specific tag is in error, grab the values from the request
    if (tag.hasErrors()) {
        return super.getValue(tag);
    }
    else {
        // Try getting from the ActionBean.  If the bean is present and the property
        // is defined, then the value from the bean takes precedence even if it's null
        ActionBean bean = tag.getActionBean();
        Object value = null;
        boolean kaboom = false;
        if (bean != null) {
            try {
                value = BeanUtil.getPropertyValue(tag.getName(), bean);
            }
            catch (ExpressionException ee) {
                if (!StripesConstants.SPECIAL_URL_KEYS.contains(tag.getName())) {
                    log.info("Could not find property [", tag.getName(), "] on ActionBean.", ee);
                }
                kaboom = true;
            }
        }

        // If there's no matching bean property, then look elsewhere
        if (bean == null || kaboom) {
            value = getValueFromTag(tag);

            if (value == null) {
                value = getValuesFromRequest(tag);
            }
        }

        return value;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:45,代码来源:BeanFirstPopulationStrategy.java

示例13: writeSourcePageHiddenField

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/** Write out a hidden field with the name of the page in it. */
protected void writeSourcePageHiddenField(JspWriter out) throws IOException {
    out.write("<input type=\"hidden\" name=\"");
    out.write(StripesConstants.URL_KEY_SOURCE_PAGE);
    out.write("\" value=\"");
    out.write(getSourcePageValue());
    out.write(isXmlTags() ? "\" />" : "\">");
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:FormTag.java

示例14: buildUrl

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/**
 * Builds the URL based on the information currently stored in the tag. Ensures that all
 * parameters are appended into the URL, along with event name if necessary and the source
 * page information.
 *
 * @return the fully constructed URL
 * @throws StripesJspException if the base URL cannot be determined
 */
protected String buildUrl() throws StripesJspException {
    HttpServletRequest request = (HttpServletRequest) getPageContext().getRequest();
    HttpServletResponse response = (HttpServletResponse) getPageContext().getResponse();


    // Add all the parameters and reset the href attribute; pass to false here because
    // the HtmlTagSupport will HtmlEncode the ampersands for us
    String base = getPreferredBaseUrl();
    UrlBuilder builder = new UrlBuilder(pageContext.getRequest().getLocale(), base, false);
    if (this.event != VALUE_NOT_SET) {
        builder.setEvent(this.event == null || this.event.length() < 1 ? null : this.event);
    }
    if (addSourcePage) {
        builder.addParameter(StripesConstants.URL_KEY_SOURCE_PAGE,
                CryptoUtil.encrypt(request.getServletPath()));
    }
    if (this.anchor != null) {
        builder.setAnchor(anchor);
    }
    builder.addParameters(this.parameters);

    // Prepend the context path, but only if the user didn't already
    String url = builder.toString();
    String contextPath = request.getContextPath();
    if (contextPath.length() > 1) {
        boolean prepend = prependContext != null && prependContext
                || prependContext == null && beanclass != null
                || prependContext == null && url.startsWith("/") && !url.startsWith(contextPath);

        if (prepend) {
            if (url.startsWith("/"))
                url = contextPath + url;
            else
                log.warn("Use of prependContext=\"true\" is only valid with a URL that starts with \"/\"");
        }
    }

    return response.encodeURL(url);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:48,代码来源:LinkTagSupport.java

示例15: getCurrentPagePath

import net.sourceforge.stripes.controller.StripesConstants; //导入依赖的package包/类
/** Get the context-relative path of the page that invoked this tag. */
public String getCurrentPagePath() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    String path = (String) request.getAttribute(StripesConstants.REQ_ATTR_INCLUDE_PATH);
    if (path == null)
        path = HttpUtil.getRequestedPath(request);
    return path;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:9,代码来源:LayoutTag.java


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