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

  • 相关阅读:
    sql server 常用脚本之table操作
    sql server 常用脚本之数据库操作
    PHP 生成日历
    转 mysql 问题一则
    转 php 前端知识点
    转 nbu 知识点
    转 php python 知识点
    oralce 问题几则 ORA-19504 报错
    AWR 报告脚本实现
    转 php 框架 Php 依赖框架 后台 调用python 脚本
  • 原文地址:https://www.cnblogs.com/voctrals/p/2972255.html
Copyright © 2011-2022 走看看