zoukankan      html  css  js  c++  java
  • Tapestry5的注解之@Inject

    @Inject

    Tapestry5中有好多个有用的注解,今天记录些@Inject相关的东西。

    Injection is Tapestry's way of making a dependency – such as a resource, asset, component, block or service – available in a page, component, mixin or service class.

    Injection是Tapestry中定义从属关系的方式 - 例如,resource, asset, component, block or service - 在page,component,mixin或者服务类中都可以定义。

    胡乱翻译的。

    1 Block Injection 插入一个块儿。。。

    @Inject
    private Block foo; //默认id为foo的
    
    或者
    @Inject @Id(
    "bar") private Block barBlock; //id已经被指定

    2 Resource Injection 资源插入

    • java.util.Locale – The locale for the component (all components within a page use the same locale).
    • org.slf4j.Logger – A Logger instance configured for the component, based on the component's class name. SLF4J is a wrapper around Log4J or other logging toolkits.
    • org.apache.tapestry5.ComponentResources – The resources for the component, often used to generate links related to the component.
    • org.apache.tapestry5.ioc.Messages – The component message catalog for the component, from which localized messages can be generated.
    @Inject
    private ComponentResources resources;

    3 Asset Injection class或者src什么的

    @Inject
    @Path("context:images/top_banner.png")
    private Asset banner;

    4 Service Injection

    这个比较普遍。。。

    5 Request Injection

    这个目前只见过,request.isXHR() ? someZone.getBody() : null;这一种情况。。。

  • 相关阅读:
    C语言之逻辑运算符
    iOS:实现图片的无限轮播---之使用第三方库SDCycleScrollView
    Mac 环境下svn服务器的配置
    ld: warning: directory not found for option 去掉警告的方法
    Mac怎么设置wifi热点
    如何获取AppStore软件安装包的路径
    四种卸载Mac软件的方法
    UIAlertController
    uiview关联xib
    OC学习篇之---文件的操作
  • 原文地址:https://www.cnblogs.com/voctrals/p/2972255.html
Copyright © 2011-2022 走看看