Tapestry学习笔记,3个配置文件

*********************

| applicationContext .xml  |

*********************

   applicationContext.xml 配置文件是用来配置DAO的配置

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
  3. <beans>
  4.     <description>HISPACTA - Hibernate / Spring + Acegi security / Tapestry example application</description>
  5.     <!--数据库连接信息-->
  6.     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  7.         <property name="driverClassName">
  8.             <value>oracle.jdbc.driver.OracleDriver</value>
  9.         </property>
  10.         <property name="url">
  11.             <value>jdbc:oracle:thin:@10.128.4.69:1521:oracl</value>
  12.         </property>
  13.         <property name="username">
  14.             <value>datasupport</value>
  15.         </property>
  16.         <property name="password">
  17.             <value>datasupport</value>
  18.         </property>
  19.     </bean>
  20.     <bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />
  21.     <!--处理lob字段 -->
  22.     <bean id="oracleLobHandle" class="org.springframework.jdbc.support.lob.OracleLobHandler">
  23.         <property name="nativeJdbcExtractor">
  24.             <ref local="nativeJdbcExtractor" />
  25.         </property>
  26.     </bean>
  27.     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  28.         <property name="dataSource">
  29.             <ref local="dataSource" />
  30.         </property>
  31.         <property name="mappingResources">
  32.             <list>
  33.                 <!--
  34.                     写hibernate配置文件要加注释
  35.                     说明该配置文件的表名及中文名称
  36.                 -->
  37.                 <!-- 数据支撑平台-->
  38.                 <value>UserManager.hbm.xml</value>
  39.                 <!-- 信息管理 -->
  40.                 <value>Document.hbm.xml</value>
  41.             </list>
  42.         </property>
  43.         <property name="lobHandler">
  44.             <ref bean="oracleLobHandle" />
  45.         </property>
  46.         <property name="hibernateProperties">
  47.             <props>
  48.                 <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
  49.                 <prop key="hibernate.show_sql">true</prop>
  50.                 <prop key="hibernate.hbm2ddl.auto">update</prop>
  51.                 <!--prop key="hibernate.jdbc.batch_size">0</prop>
  52.                 <prop key="hibernate.jdbc.use_streams_for_binary">true</prop-->
  53.                 <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
  54.             </props>
  55.         </property>
  56.     </bean>
  57.     <!-- 事务的回滚 -->
  58.     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  59.         <property name="sessionFactory">
  60.             <ref local="sessionFactory" />
  61.         </property>
  62.     </bean>
  63.     <bean name="transactionAttributes" class="org.springframework.transaction.interceptor.NameMatchTransactionAttributeSource">
  64.         <property name="properties">
  65.             <props>
  66.                 <prop key="save*">PROPAGATION_REQUIRES_NEW</prop>
  67.                 <prop key="delete*">PROPAGATION_REQUIRED</prop>
  68.                 <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
  69.             </props>
  70.         </property>
  71.     </bean>
  72.     <bean id="nameMatchTxInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
  73.         <property name="transactionManager">
  74.             <ref bean="transactionManager" />
  75.         </property>
  76.         <property name="transactionAttributeSource">
  77.             <ref bean="transactionAttributes" />
  78.         </property>
  79.     </bean>
  80.     <bean id="autoTxProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
  81.         <property name="interceptorNames">
  82.             <list>
  83.                 <idref local="nameMatchTxInterceptor" />
  84.             </list>
  85.         </property>
  86.         <property name="beanNames">
  87.                 <list>
  88. <!-- 在这里加DAO的引用-->
  89.                 <idref local="videoDAO" />
  90.                  </list>
  91.         </property>
  92. <!--DAO的具体配置--> 
  93.     <bean id="videoDAO" class="com.jbcom.support.bus.dao.impl.VideoDAOImpl">
  94.         <property name="sessionFactory">
  95.             <ref local="sessionFactory" />
  96.         </property>
  97.     </bean> 
  98. </beans>

 如图在表示的地方加入DAO的配置

  在applicationContext.xml里还可以配置数据库的连接

 

 

 

 

 

*************

| *.application  |

*************

   以工程名命名的 . application配置文件 是用来配置Page页面的路径

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE application PUBLIC
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  5. <!-- generated by Spindle, http://spindle.sourceforge.net -->
  6. <application name="DataSupport">
  7.     <!--BASE -->
  8.     <meta key="org.apache.tapestry.visit-class"
  9.         value="com.jbcom.support.tapestry.Visit"/>
  10.     <meta key="org.apache.tapestry.engine-class"
  11.         value="com.jbcom.support.tapestry.SupportEngine"/>
  12.     <meta key="org.apache.tapestry.disable-caching" value="false"/>
  13.     <meta key="org.apache.tapestry.output-encoding" value="GBK"/>
  14.     <!--Pages配置-->
  15.     <page name="Home" specification-path="pages/Home.page"/>
  16.     <page name="LoginPage" specification-path="pages/LoginPage.page"/>   
  17.     <page name="Success"
  18.         specification-path="pages/Success.page"/>
  19. </application>

 

 

***********

| *.hbm.xml  |

***********

  *. hbm . xml 文件配置HBM的字段

 

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3. <hibernate-mapping>
  4.     <!--Organization-->
  5.     <class name="com.jbcom.support.manager.hbm.OrganizationHBM" table="T_SUPPORT_ORGANIZATION">
  6.         <id name="organizationId" type="string">
  7.             <generator class="uuid.hex" />
  8.         </id>
  9.         <property length="50" name="organizationName" not-null="true" type="string" />
  10.         <property length="500" name="describe" not-null="false" type="string" />
  11.         <many-to-one name="parentOrganization" class="com.jbcom.support.manager.hbm.OrganizationHBM" column="parentId" not-null="false" />
  12.     </class>
  13. </hibernate-mapping>

   

 

 

 

另外每个页面组成的  .page文件里也有关于页面的配置

 

 

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE page-specification PUBLIC
  3.   "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  4.   "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
  5. <!-- generated by Spindle, http://spindle.sourceforge.net -->
  6. <page-specification class="com.jbcom.support.bus.pages.VideoList">
  7.     <inject property="videoDAO" object="spring:videoDAO"/> 
  8. <!-- JAVA文件路径 -->
  9.     <property name="videoHBM"
  10.         initial-value="new com.jbcom.support.bus.hbm.VideoHBM()"/>
  11. <!-- Model查询路径 -->
  12.     <property name="queryVideoModel"
  13.         persist="session"
  14.         initial-value="new com.jbcom.support.bus.model.VideoModel()"/>
  15. <!-- 数据库连接 -->
  16.     <property name="hqlBuilder"
  17.         persist="session"
  18.         initial-value="new com.jbcom.platform.sql.HqlBuilder()"/>
  19. <!-- 查询字段的值,比如根据部门查找 -->
  20.     <component id="querypanel" type="jbcom:QueryPanelAdv">
  21.         <binding name="hqlBuilder" value="hqlBuilder"/>
  22.         <binding name="listener" value="listeners.reQuery"/>
  23.         <binding name="queryModel" value="queryVideoModel"/>
  24.         <binding name="relationAndOr" value="false"/>
  25.         <binding name="queryModelClass"
  26.             value="literal:com.jbcom.support.bus.model.VideoModel"/>
  27.         <binding name="conditionXml"
  28.             value="literal:pages/bus/conds/VideoCond.xml"/>
  29.         <binding name="autoLoad" value="false"/>
  30.     </component>
  31. <!-- 查询后显示的字段 -->
  32.     <component id="table" type="jbcomgrid:JbcomListTable">
  33.         <binding name="row" value="videoHBM"/>
  34.         <binding name="tableQueryState" value="tableQueryState"/>
  35.         <binding name="tableConfigXml"
  36.             value="literal:pages/bus/tablexml/VideoList.table.xml"/>
  37.         <binding name="pagesClass" value="literal:tablePagesClass"/>
  38.         <binding name="columnsClass" value="literal:tableColumnsClass"/>
  39.         <binding name="rowsClass" value="literal:tableRowsClass"/>
  40.         <binding name="valuesClass" value="literal:tableValuesClass"/>
  41.         <binding name="pageSize" value="10"/>
  42.     </component>
  43. </page-specification>
阅读更多
相关热词
换一批

没有更多推荐了,返回首页