zoukankan      html  css  js  c++  java
  • Tapestry5之Application Module

    首先说明一下,并不是每一个Tapestry项目的ApplicationModule都是AppModule,而是与这个工程的总的filter决定的。
        <filter>
            <filter-name>app</filter-name>
            <filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>app</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>

       也就是说与红色部分相关联。

    This module is a good place to configure and extend Tapestry, or to place your own service definitions.

    这个模块是配置或者扩展Tapestry的一个好地方,我们也可以在这里放置我们自定义的服务。

    1  public static void bind(ServiceBinder binder)
    binder的功能就是通过:
    a binder.bind(SomeService.class, SomeServiceImpl.class);
    b binder.bind(SomeService.class);
    这样我们就可以Page页面中用@Inject,注入一个SomeService服务。而用到的就是SomeServiceImpl的方法或者是SomeService的方法。

    2 Tell Tapestry about our custom translators, validators, and their message files.
    告诉Tapestry我们自己的转换器,验证器和message文件。

    public static void contributeTranslatorAlternatesSource( MappedConfiguration<String, Translator> configuration, ThreadLocale threadLocale)
    public static void contributeFieldValidatorSource(MappedConfiguration<String, Validator> configuration)
    public void contributeComponentMessagesSource(OrderedConfiguration<String> configuration)

    3 Tell Tapestry about our custom ValueEncoders. We do this by contributing configuration to Tapestry's ValueEncoderSource service.
    告诉Tapestry我们自己的编码器(Encoder)。
    public static void contributeValueEncoderSource(MappedConfiguration<Class, Object> configuration){
      configuration.addInstance(Person.class, PersonEncoder.class);
    }
    4 public static void contributeApplicationDefaults(MappedConfiguration<String, String> configuration)
    这个就是用来修改Tapestry的许多默认的东西的。
    目前我知道的有:
    configuration.add(SymbolConstants.SUPPORTED_LOCALES, "en_US,en_GB,fr"); // 修改国际化信息
    configuration.add(JQuerySymbolConstants.SUPPRESS_PROTOTYPE, "false"); // 修改对JQuery的排他
    configuration.add(JQuerySymbolConstants.JQUERY_ALIAS, "$j"); // 修改JQuery的默认符号
    configuration.add(SymbolConstants.START_PAGE_NAME, "welcome");// 修改默认的首页
    configuration.add(SymbolConstants.CHARSET, "utf-8");// 修改默认字符集
    configuration.add(ComponentParameterConstants.GRID_ROWS_PER_PAGE, "15"); //修改grid默认的表示行数

    5 Tell Tapestry how to handle JBoss 7's classpath URLs - JBoss uses a "virtual file system".
    告诉Tapestry如何去处理JBoss 7的classpath URLs。因为JBoss使用一个虚拟的文件系统。
    public static void contributeServiceOverride(MappedConfiguration<Class, Object> configuration) {
      configuration.add(ClasspathURLConverter.class, new ClasspathURLConverterJBoss7());
    }


    6 Tell Tapestry how to handle @EJB in page and component classes.
    告訴Tapestry如何在頁面中處理@EJB
    @Primary public static void contributeComponentClassTransformWorker(OrderedConfiguration<ComponentClassTransformWorker2> configuration) {   configuration.addInstance("EJB", EJBAnnotationWorker.class, "before:Property"); }

    慢慢总结吧,待续。。。
  • 相关阅读:
    dotnet core 获取 MacAddress 地址方法
    dotnet core 获取 MacAddress 地址方法
    dotnet core 发布只带必要的依赖文件
    dotnet core 发布只带必要的依赖文件
    Developing Universal Windows Apps 开发UWA应用 问答
    Developing Universal Windows Apps 开发UWA应用 问答
    cmd 如何跨驱动器移动文件夹
    cmd 如何跨驱动器移动文件夹
    C++ 驱动开发 error LNK2019
    C++ 驱动开发 error LNK2019
  • 原文地址:https://www.cnblogs.com/voctrals/p/2985572.html
Copyright © 2011-2022 走看看