• 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;这一种情况。。。

  • 相关阅读:
    数据库之主表、从表、主键、外键
    eclipse编写js代码没有提示
    思维导图xmind的使用方法
    整理一下Apache与Tomcat的关系
    全栈开发者,一个很好的自学编程网站
    svn文件被锁不能提交的解决办法
    在SQL Server数据库中执行存储过程很快,在c#中调用很慢的问题
    php安装redis扩展
    PHP点击按钮拷贝
    PHP文件下载
  • 原文地址:https://www.cnblogs.com/voctrals/p/2972255.html
Copyright © 2020-2023  润新知