• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StripesFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getSingleItemTypeConverter

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
    * Fetches an instance of {@link TypeConverter} that can be used to convert the individual
    * items split out of the input String. By default uses the {@link TypeConverterFactory} to
    * find an appropriate {@link TypeConverter}.
    *
    * @param targetType the type that each item should be converted to.
    * @return a TypeConverter for use in converting each individual item.
    */
   @SuppressWarnings("unchecked")
protected TypeConverter getSingleItemTypeConverter(Class targetType) {
       try {
           TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
           return factory.getTypeConverter(targetType, this.locale);
       }
       catch (Exception e) {
           throw new StripesRuntimeException(
                   "You are using the OneToManyTypeConverter to convert a String to a List of " +
                           "items for which there is no registered converter! Please check that the " +
                           "TypeConverterFactory knows how to make a converter for: " +
                           targetType, e
           );
       }
   }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:OneToManyTypeConverter.java


示例2: getValidationMetadata

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
protected ValidationMetadata getValidationMetadata() throws StripesJspException {
    // find the action bean class we're dealing with
    Class<? extends ActionBean> beanClass = getParentFormTag().getActionBeanClass();

    if (beanClass != null) {
        // ascend the tag stack until a tag name is found
        String name = getName();
        if (name == null) {
            InputTagSupport tag = getParentTag(InputTagSupport.class);
            while (name == null && tag != null) {
                name = tag.getName();
                tag = tag.getParentTag(InputTagSupport.class);
            }
        }

        // check validation for encryption flag
        return StripesFilter.getConfiguration().getValidationMetadataProvider()
                .getValidationMetadata(beanClass, new ParameterName(name));
    }
    else {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:InputTagSupport.java


示例3: format

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Attempts to format an object using the Stripes formatting system.  If no formatter can
 * be found, then a simple String.valueOf(input) will be returned.  If the value passed in
 * is null, then the empty string will be returned.
 * 
 * @param input The object to be formatted
 * @param forOutput If true, then the object will be formatted for output to the JSP. Currently,
 *            that means that if encryption is enabled for the ActionBean property with the same
 *            name as this tag then the formatted value will be encrypted before it is returned.
 */
@SuppressWarnings("unchecked")
protected String format(Object input, boolean forOutput) {
    if (input == null) {
        return "";
    }

    // format the value
    FormatterFactory factory = StripesFilter.getConfiguration().getFormatterFactory();
    Formatter formatter = factory.getFormatter(input.getClass(),
                                               getPageContext().getRequest().getLocale(),
                                               this.formatType,
                                               this.formatPattern);
    String formatted = (formatter == null) ? String.valueOf(input) : formatter.format(input);

    // encrypt the formatted value if required
    if (forOutput && formatted != null) {
        try {
            ValidationMetadata validate = getValidationMetadata();
            if (validate != null && validate.encrypted())
                formatted = CryptoUtil.encrypt(formatted);
        }
        catch (JspException e) {
            throw new StripesRuntimeException(e);
        }
    }

    return formatted;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:InputTagSupport.java


示例4: format

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Attempts to format an object using an appropriate {@link Formatter}. If
 * no formatter is available for the object, then this method will call
 * <code>toString()</code> on the object. A null <code>value</code> will
 * be formatted as an empty string.
 * 
 * @param value
 *            the object to be formatted
 * @return the formatted value
 */
@SuppressWarnings("unchecked")
protected String format(Object value) {
    if (value == null)
        return "";

    FormatterFactory factory = StripesFilter.getConfiguration().getFormatterFactory();
    Formatter formatter = factory.getFormatter(value.getClass(),
                                               getPageContext().getRequest().getLocale(),
                                               this.formatType,
                                               this.formatPattern);
    if (formatter == null)
        return String.valueOf(value);
    else
        return formatter.format(value);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:26,代码来源:FormatTag.java


示例5: getKeyMaterialFromConfig

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Attempts to load material from which to manufacture a secret key from the Stripes
 * Configuration. If config is unavailable or there is no material configured null
 * will be returned.
 *
 * @return a byte[] of key material, or null
 */
protected static byte[] getKeyMaterialFromConfig() {
    try {
        Configuration config = StripesFilter.getConfiguration();
        if (config != null) {
            String key = config.getBootstrapPropertyResolver().getProperty(CONFIG_ENCRYPTION_KEY);
            if (key != null) {
                return key.getBytes();
            }
        }
    }
    catch (Exception e) {
        log.warn("Could not load key material from configuration.", e);
    }

    return null;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:CryptoUtil.java


示例6: getDefaultValue

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
    * <p>Attempts to create a default value for a given node by either a) creating a new array
    * instance for arrays, b) fetching the first enum for enum classes, c) creating a default
    * instance for interfaces and abstract classes using ReflectUtil or d) calling a default
    * constructor.
    *
    * @param node the node for which to find a default value
    * @return an instance of the appropriate type
    * @throws EvaluationException if an instance cannot be created
    */
   @SuppressWarnings("unchecked")
private Object getDefaultValue(NodeEvaluation node) throws EvaluationException {
       try {
           Class clazz = convertToClass(node.getValueType(), node);

           if (clazz.isArray()) {
               return Array.newInstance(clazz.getComponentType(), 0);
           }
           else if (clazz.isEnum()) {
               return clazz.getEnumConstants()[0];
           }
           else {
               return StripesFilter.getConfiguration().getObjectFactory().newInstance(clazz);
           }
       }
       catch (Exception e) {
           throw new EvaluationException("Encountered an exception while trying to create " +
           " a default instance for property '" + node.getNode().getStringValue() + "' in " +
           "expression '" + this.expression.getSource() + "'.", e);
       }
   }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:PropertyExpressionEvaluation.java


示例7: getValidationMetadata

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Get a map of property names to {@link ValidationMetadata} for the {@link ActionBean} class
 * bound to the URL being built. If the URL does not point to an ActionBean class or no
 * validation metadata exists for the ActionBean class then an empty map will be returned.
 * 
 * @return a map of ActionBean property names to their validation metadata
 * @see ValidationMetadataProvider#getValidationMetadata(Class)
 */
protected Map<String, ValidationMetadata> getValidationMetadata() {
    Map<String, ValidationMetadata> validations = null;
    Configuration configuration = StripesFilter.getConfiguration();
    if (configuration != null) {
        Class<? extends ActionBean> beanType = null;
        try {
            beanType = configuration.getActionResolver().getActionBeanType(this.baseUrl);
        }
        catch (UrlBindingConflictException e) {
            // This can be safely ignored
        }

        if (beanType != null) {
            validations = configuration.getValidationMetadataProvider().getValidationMetadata(
                    beanType);
        }
    }

    if (validations == null)
        validations = Collections.emptyMap();

    return validations;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:UrlBuilder.java


示例8: setupContext

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
@BeforeClass
public void setupContext() {
    context = new MockServletContext("waitpage");
    
    // Add the Stripes Filter
    Map<String,String> filterParams = new HashMap<String,String>();
    filterParams.put("CoreInterceptor.Classes",
            "org.stripesstuff.tests.waitpage.TestableWaitPageInterceptor," +
            "net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor," +
            "net.sourceforge.stripes.controller.HttpCacheInterceptor");
    filterParams.put("ActionResolver.Packages",
            "org.stripesstuff.tests.waitpage.action");
    context.addFilter(StripesFilter.class, "StripesFilter", filterParams);
    
    // Add the Stripes Dispatcher
    context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
}
 
开发者ID:StripesFramework,项目名称:stripes-stuff,代码行数:18,代码来源:WaitPageTest.java


示例9: testValidateTypeConverterExtendsStock

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Tests the use of an auto-loaded type converter versus a type converter explicitly configured
 * via {@code @Validate(converter)}, where the auto-loaded type converter extends the stock
 * type converter.
 *
 * @see http://www.stripesframework.org/jira/browse/STS-610
 */
@Test(groups="extensions")
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testValidateTypeConverterExtendsStock() throws Exception {
    MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
    Locale locale = trip.getRequest().getLocale();
    TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
    TypeConverter<?> tc = factory.getTypeConverter(Integer.class, locale);
    try {
        factory.add(Integer.class, MyIntegerTypeConverter.class);
        trip.addParameter("shouldBeDoubled", "42");
        trip.addParameter("shouldNotBeDoubled", "42");
        trip.execute("validateTypeConverters");
        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.shouldBeDoubled, new Integer(84));
        Assert.assertEquals(actionBean.shouldNotBeDoubled, new Integer(42));
    }
    finally {
        Class<? extends TypeConverter> tcType = tc == null ? null : tc.getClass();
        factory.add(Integer.class, (Class<? extends TypeConverter<?>>) tcType);
    }
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:29,代码来源:ValidationAnnotationsTest.java


示例10: testValidateTypeConverterDoesNotExtendStock

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Tests the use of an auto-loaded type converter versus a type converter explicitly configured
 * via {@code @Validate(converter)}, where the auto-loaded type converter does not extend the
 * stock type converter.
 *
 * @see http://www.stripesframework.org/jira/browse/STS-610
 */
@SuppressWarnings("unchecked")
@Test(groups="extensions")
public void testValidateTypeConverterDoesNotExtendStock() throws Exception {
    TypeConverterFactory factory = StripesFilter.getConfiguration().getTypeConverterFactory();
    Class<? extends TypeConverter> oldtc = factory.getTypeConverter(//
            String.class, Locale.getDefault()).getClass();
    try {
        MockRoundtrip trip = new MockRoundtrip(getMockServletContext(), getClass());
        factory.add(String.class, MyStringTypeConverter.class);
        trip.addParameter("shouldBeUpperCased", "test");
        trip.addParameter("shouldNotBeUpperCased", "test");
        trip.execute("validateTypeConverters");
        ValidationAnnotationsTest actionBean = trip.getActionBean(getClass());
        Assert.assertEquals(actionBean.shouldBeUpperCased, "TEST");
        Assert.assertEquals(actionBean.shouldNotBeUpperCased, "test");
    }
    finally {
        factory.add(String.class, (Class<? extends TypeConverter<?>>) oldtc);
    }
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:28,代码来源:ValidationAnnotationsTest.java


示例11: getMockServletContext

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
private MockServletContext getMockServletContext()
{
    MockServletContext ctx = new MockServletContext("test");

    // Add the Stripes Filter
    Map<String, String> filterParams = new HashMap<String, String>();
    filterParams.put("ActionResolver.Packages", "org.stripesrest");
    filterParams.put("Interceptor.Classes", "org.stripesrest.RestActionInterceptor");
    ctx.addFilter(StripesFilter.class, "StripesFilter", filterParams);

    // Add the Stripes Dispatcher
    ctx.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
    
    return ctx;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:16,代码来源:RestActionBeanTest.java


示例12: getErrorMessage

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Looks up the specified key in the error message resource bundle. If the
 * bundle is missing or if the resource cannot be found, will return null
 * instead of throwing an exception.
 *
 * @param locale the locale in which to lookup the resource
 * @param key the exact resource key to lookup
 * @return the resource String or null
 */
public static String getErrorMessage(Locale locale, String key) {
    try {
        Configuration config = StripesFilter.getConfiguration();
        ResourceBundle bundle = config.getLocalizationBundleFactory().getErrorMessageBundle(locale);
        return bundle.getString(key);
    }
    catch (MissingResourceException mre) {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:LocalizationUtility.java


示例13: getActionResolver

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/** Find and return the {@link AnnotatedClassActionResolver} for the given context. */
private static AnnotatedClassActionResolver getActionResolver(MockServletContext context) {
    for (Filter filter : context.getFilters()) {
        if (filter instanceof StripesFilter) {
            ActionResolver resolver = ((StripesFilter) filter).getInstanceConfiguration()
                    .getActionResolver();
            if (resolver instanceof AnnotatedClassActionResolver) {
                return (AnnotatedClassActionResolver) resolver;
            }
        }
    }

    return null;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:MockRoundtrip.java


示例14: getActionBeanUrl

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Similar to the {@link #getActionBeanType(Object)} method except that instead of
 * returning the Class of ActionBean it returns the URL Binding of the ActionBean.
 *
 * @param nameOrClass either the String FQN of an ActionBean class, or a Class object
 * @return the URL of the appropriate ActionBean class or null
 */
protected String getActionBeanUrl(Object nameOrClass) {
    Class<? extends ActionBean> beanType = getActionBeanType(nameOrClass);
    if (beanType != null) {
        return StripesFilter.getConfiguration().getActionResolver().getUrlBinding(beanType);
    }
    else {
        return null;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:StripesTagSupport.java


示例15: setAction

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Sets the action for the form. If the form action begins with a slash, and does not already
 * contain the context path, then the context path of the web application will get prepended to
 * the action before it is set. In general actions should be specified as &quot;absolute&quot;
 * paths within the web application, therefore allowing them to function correctly regardless of
 * the address currently shown in the browser&apos;s address bar.
 * 
 * @param action the action path, relative to the root of the web application
 */
public void setAction(String action) {
    // Use the action resolver to figure out what the appropriate URL binding if for
    // this path and use that if there is one, otherwise just use the action passed in
    String binding = StripesFilter.getConfiguration().getActionResolver()
            .getUrlBindingFromPath(action);
    if (binding != null) {
        this.actionWithoutContext = binding;
    }
    else {
        this.actionWithoutContext = action;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:FieldMetadataTag.java


示例16: doStartTag

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Final implementation of the doStartTag() method that allows the base InputTagSupport class
 * to insert functionality before and after the tag performs it's doStartTag equivalent
 * method. Finds errors related to this field and intercepts with a {@link TagErrorRenderer}
 * if appropriate.
 *
 * @return int the value returned by the child class from doStartInputTag()
 */
@Override
public final int doStartTag() throws JspException {
    getTagStack().push(this);
    registerWithParentForm();

    // Deal with any error rendering
    if (getFieldErrors() != null) {
        this.errorRenderer = StripesFilter.getConfiguration()
                .getTagErrorRendererFactory().getTagErrorRenderer(this);
        this.errorRenderer.doBeforeStartTag();
    }

    return doStartInputTag();
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:23,代码来源:InputTagSupport.java


示例17: getActionBeanUrlBinding

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/** Get the URL binding for the form's {@link ActionBean} from the {@link ActionResolver}. */
protected String getActionBeanUrlBinding() {
    ActionResolver resolver = StripesFilter.getConfiguration().getActionResolver();
    if (actionBeanClass == null) {
        String path = StringUtil.trimFragment(this.actionWithoutContext);
        String binding = resolver.getUrlBindingFromPath(path);
        if (binding == null)
            binding = path;
        return binding;
    }
    else {
        return resolver.getUrlBinding(actionBeanClass);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:FormTag.java


示例18: getActionBeanClass

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/** Lazily looks up and returns the type of action bean the form will submit to. */
protected Class<? extends ActionBean> getActionBeanClass() {
    if (this.actionBeanClass == null) {
        ActionResolver resolver = StripesFilter.getConfiguration().getActionResolver();
        this.actionBeanClass = resolver.getActionBeanType(getActionBeanUrlBinding());
    }

    return this.actionBeanClass;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:10,代码来源:FormTag.java


示例19: isEventName

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Returns true if {@code name} is the name of an event handled by {@link ActionBean}s of type
 * {@code beanType}.
 * 
 * @param beanType An {@link ActionBean} class
 * @param name The name to look up
 */
protected boolean isEventName(Class<? extends ActionBean> beanType, String name) {
    if (beanType == null || name == null)
        return false;

    try {
        ActionResolver actionResolver = StripesFilter.getConfiguration().getActionResolver();
        return actionResolver.getHandler(beanType, name) != null;
    }
    catch (StripesServletException e) {
        // Ignore the exception and assume the name is not an event
        return false;
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:WizardFieldsTag.java


示例20: getHtmlMode

import net.sourceforge.stripes.controller.StripesFilter; //导入依赖的package包/类
/**
 * Get the HTML mode for the given page context. If the request attribute
 * {@link #REQ_ATTR_HTML_MODE} is present then use that value. Otherwise, use the global
 * configuration property {@link #CFG_KEY_HTML_MODE}.
 */
public static String getHtmlMode(PageContext pageContext) {
    String htmlMode = (String) pageContext.getAttribute(REQ_ATTR_HTML_MODE,
            PageContext.REQUEST_SCOPE);

    if (htmlMode == null) {
        htmlMode = StripesFilter.getConfiguration().getBootstrapPropertyResolver()
                .getProperty(CFG_KEY_HTML_MODE);
    }

    return htmlMode;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:PageOptionsTag.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServiceStatus类代码示例发布时间:2022-05-22
下一篇:
Java StringSource类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap