- 浏览: 282096 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (121)
- jsf (16)
- 技术 (1)
- seam (27)
- jpa/hibernate (6)
- seam-对话 (3)
- 复用组件 (1)
- java基础 (18)
- JBOSS (1)
- Facelets (3)
- EL表达式 (2)
- 正则表达式 (1)
- sogi (2)
- 工具 (2)
- 设计模式/重构 (2)
- 项目管理-maven (5)
- EJB (1)
- ClassLoader (2)
- eclipse (1)
- jQuery (0)
- seam2源码分析 (0)
- osgi (0)
- TEST (0)
- 日志记录 (1)
- 批处理工作流 (0)
- 业务需求 (0)
- 语言 (2)
- 架构 (2)
- svn (1)
- sql (1)
- 异常处理 (1)
- mybatis (2)
- http (2)
- 代码可读性 (3)
- 配置化 (0)
- 错误恢复 (0)
- 状态查询 (1)
- 误操作恢复 (0)
- 工作安排 (0)
- 自动化 (0)
- 解耦 (1)
- 交流 (1)
- spring (6)
- 代码质量 (2)
- 方案 (1)
- 分布式 (1)
- mvc (2)
最新评论
-
luchuanbaker:
经过测试,实际上,mybatis并没有此问题,我也碰到了这样的 ...
mybatis 异常不友好 举例 -
huang882088:
jboss的war发布到tomcat里报这个错误怎么办?
classloader常见问题总结 -
yourenyouyu2008:
大型,可持续扩展的系统适合使用静态语言。大型系统中的部分地方可 ...
Nuxeo公司探秘:从Python迁移到Java -
yourenyouyu2008:
既然Nuxeo同时使用了Pytho ...
Nuxeo公司探秘:从Python迁移到Java -
panshunchang:
还有一种可能,真的缺这个jar包,在tomcat lib目录下 ...
classloader常见问题总结
components.xml 的配置采用反射机制来实现,组件类的私有属性照样可以设置(private String f1;)
如下的私有属性resolverChains没有提供get、set方法照样可以配置赋值 。之前我一直以为私有的属性是不可以设置的,原来大错特错了。
public class PermissionMapper implements Serializable
{
private Map<Class,Map<String,String>> resolverChains = new HashMap<Class,Map<String,String>>();
<security:permission-mapper default-resolver-chain="defaultChain" resolver-chains="#{resolverChains}">
</security:permission-mapper>
基本component配置
所有seam组件都可以使用基本component方式来配置,示例如下
<component class="org.jboss.seam.bpm.Jbpm"/>
<component name="customerDatabase"
class="org.jboss.seam.persistence.ManagedPersistenceContext">
<component name="accountingDatabase"
class="org.jboss.seam.persistence.ManagedPersistenceContext">
<property name="persistenceUnitJndiName">java:/accountingEntityManagerFactory</
property>
</component>
<component class="com.helloworld.Hello" name="hello">
<property name="name">#{user.name}</property>
</component>
xs:element name="component"
<xs:element name="component">
<xs:annotation>
<xs:documentation> The component tag defines a single Seam component. It may serve as to the root element of
a fine-grained *.component.xml file. </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="components:property"
/>
</xs:sequence>
<xs:attributeGroup ref="components:attlist.component"/>
<xs:attributeGroup ref="components:attlist.ejbcomponent"/>
</xs:complexType>
</xs:element>
xs:element name="property"
<xs:element name="property">
<xs:annotation>
<xs:documentation>
A generic property. The body contains the value or values.
</xs:documentation>
</xs:annotation>
<xs:complexType mixed="true">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="components:key" />
<xs:element ref="components:value" />
</xs:choice>
<xs:attributeGroup ref="components:attlist.property"/>
</xs:complexType>
</xs:element>
attlist.property
<property name=“name” type="org.manaty.mvno.portal.Party">
<xs:attributeGroup name="attlist.property">
<xs:attribute name="name" use="required" type="components:string">
<xs:annotation>
<xs:documentation>The property name</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="components:string" >
<xs:annotation>
<xs:documentation>Concrete type to use if the property is multi-valued</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
key
与vlaue配合使用
<property name="issueStatusOptions" type="java.util.LinkedHashMap">
<key>open</key> <value>open issue</value>
<key>resolved</key> <value>issue resolved by developer</value>
<key>closed</key> <value>resolution accepted by user</value>
</property>
<xs:element name="key" type="components:string">
<xs:annotation>
<xs:documentation>For map values, the key for the following value</xs:documentation>
</xs:annotation>
</xs:element>
最低级元素了,不能再有子元素
value
设置list,与key配合可以设置map
<value>processTestStock/processdefinition.xml</value>
<value>processTestStockRoaming/processdefinition.xml</value>
<xs:element name="value" type="components:string">
<xs:annotation>
<xs:documentation>
For list values, the value to be added.
For map values, the value for the preceding key
</xs:documentation>
</xs:annotation>
</xs:element>
最低级元素了,不能再有子元素
property属性取值
有三种方式设置property的值
1)直接字符串,只能设置String类型的属性
<property name="persistenceUnitJndiName">java:/accountingEntityManagerFactory</
property>
</component>
2)使用表达式,可以设置任意Object类型的属性
<property name="user">#{user}</property>
3)从components.properties(组件属性文件)中获取,只能是String
<property name="filename">@properties.filename@</property>
components.properties文件内容如下
jndiPattern=portal/#{ejbName}/local
debug=true
properties.filename=portal.properties
properties.reload=true
不是以@开头的直接返回即可 ,任何以@开头的都会从components.properties中获取,不单单是在 property中
<core:init debug="true" jndi-pattern="@jndiPattern@"/>
private String replace(String value, Properties replacements)
{
if (value.startsWith("@"))
{
value = replacements.getProperty(value.substring(1, value.length() - 1));
}
return value;
}
component只能有property子节点,property的属性级子节点的属性(key,value)都可以使用字符串和表达式两种形式,表达式可以设置object类型的值
map
可以使用key,value元素来实现map的配置,需要注意的是bean属性(map属性)的写法,配置会获取bean的属性,不管该属性是否有对应的set方法,将配置的值put进map中,所以属性值必须首先赋值( = new HashMap)
<security:permission-mapper default-resolver-chain="defaultChain">
<security:resolver-chains>
<key>org.manaty.model.party.Party</key><value>#{partyResolverMap.configMap}</value>
<key>org.manaty.model.order.Order</key><value>#{partyResolverMap.configMap}</value>
</security:resolver-chains>
</security:permission-mapper>
public class PermissionMapper implements Serializable
{
private Map<Class,Map<String,String>> resolverChains = new HashMap<Class,Map<String,String>>();
定义map组件
由于key、value是最底层的元素,所以不能定义嵌套的map,比如Map<Class,Map<String,String>>是不能直接定义的,需要将Map<String,String>定义成一个组件。
定义一个包含map的组件
<component name="partyResolverMap" class="org.manaty.util.SeamUtil" auto-create="true" scope="application">
<property name="configMap">
<key>restrictPartyResource</key><value>partyChain</value>
</property>
</component>
使用上面定义的map
<security:permission-mapper default-resolver-chain="defaultChain">
<security:resolver-chains>
<key>org.manaty.model.party.Party</key><value>#{partyResolverMap.configMap}</value>
<key>org.manaty.model.order.Order</key><value>#{partyResolverMap.configMap}</value>
</security:resolver-chains>
</security:permission-mapper>
public class SeamUtil {
private Map<String,String> configMap=new HashMap<String,String>();
public Map<String,String> getConfigMap() {
return configMap;
}
特定组件配置
seam对一些常用的内置组件定义定义了些schema,这样就可以利用编辑器的提示功能还编写组件配置了,这样可以提高效率。
<core:manager concurrent-request-timeout="500"
conversation-timeout="120000" conversation-id-parameter="cid"
parent-conversation-id-parameter="pid" />
所有特定组件都按照规定的模式来解析配置,所以即使系统没有提供对应的schema,我们也可以按照规则来使用。
1)在包中增加 package-info.java,用来定义namespace和prefix
@Namespace(value="http://jboss.com/products/seam/security", prefix="org.jboss.seam.security")
@AutoCreate
package org.jboss.seam.security.management;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Namespace;
不同的包可以有相同的 package-info.java定义
如下两个包中的package-info.java的定义是相同的
package org.jboss.seam.security.management
package org.jboss.seam.security;
2)tag name和属性名的拼写规则
<security:permission-mapper default-resolver-chain="defaultChain" resolver-chains="#{resolverChains}">
</security:permission-mapper>
tag name:permission-mapper对应类名PermissionMapper,将类名的首字母小写,中间的大写字母换成(-小写)
属性:default-resolver-chain对应private String defaultResolverChain;大写字母换成(-小写)
发表评论
-
spring seam比较
2014-01-14 14:06 9191)获取框架中的bean spring通过静态方法中传递 ... -
Nuxeo公司探秘:从Python迁移到Java
2013-07-21 10:57 1046成立于2000年的Nuxeo公 ... -
自定义组件问题
2013-03-01 10:14 01)ios:dataTable组件中不加buttonPane ... -
seam中内嵌的事务回滚拦截器RollbackInterceptor
2012-12-28 15:17 2076seam中有两种事务管理方 ... -
使用JTA的事务同步机制实现分布式事务j的功能avax.transaction.Synchronization
2012-12-05 18:43 0分布式事务强大功能,但也会带来性能和管理上的压力(这是听专家门 ... -
seam中的test
2012-04-25 11:25 0seam中提供了一些非seam环境下的unit testing ... -
Hibernate的FlushMode 和seam对话中的FlushMode
2012-02-21 17:29 0hibernate提供了5种flushmode。 1) NE ... -
seam 中的注释分类
2012-02-14 11:08 0seam中注释主要分为2大类,seam组件对象构造阶段的注释和 ... -
seam2 热部署
2011-09-30 10:25 1165seam能很好地支持 页面(faceslet)、非ejb cl ... -
使用长对话的"manual" flush-mode ,多操作一次提交
2011-03-24 10:27 1520一次长对话访问中可以包括多个页面,每个页面只处理部分数据,但不 ... -
seam 属性配置与installed="false"的冲突
2011-03-08 15:09 1094问题 在测试和运行环境使用不同的事务配置,默认不需要指定事务 ... -
最简单的richfaces tree使用方式
2010-10-30 12:54 2323richfaces tree提供的示例都是一次全部构造出树,对 ... -
page scope介绍及用途
2010-06-02 00:13 6258jsf1.2只提供了3中作用域,application、ses ... -
seam框架中@Unwrap的使用示例
2009-09-07 10:07 16311) 把FacesContext当seam组件使用,可以直接 ... -
基于seam技术的中文网站
2009-09-05 16:28 1325基于seam的中文网站,欢迎大家提供实际的seam项目 ht ... -
在seam项目启动后执行数据库操作
2009-07-15 15:33 1753项目启动时执行些初始化数据操作,问题是事务不能提交,这样虽然方 ... -
基于seam-gen的热部署(hot deploy)相关问题
2009-07-06 12:04 1465使用seam-gen生成的seam项目是支持热部署的。 ... -
提升jsf/seam性能
2009-05-23 22:07 1407转载:http://www.jsfcentral.com/ar ... -
根据组件名字获取组件对象Component.getInstance(String name)
2009-05-05 22:02 3982Component.getInstance(String ... -
下拉框的国际化
2009-04-22 17:32 2064<f:selectItem itemLabel=&quo ...
相关推荐
Seam - 语境相关的组件[满江红20071230]............................................................................................................................ 1 Java EE 框架...........................
Practical.JBoss.Seam.Projects.pdf
Apress.Beginning.JBoss.Seam.Feb.2007.rar
Apress.Beginning.JBoss.Seam.Feb.2007.pdf 自己备份用的
Beginning.JBoss.Seam.很好的东西,只有英文版
seam框架需要的所有jar包,支持seam ui组件
此教程从基础讲述了使用Seam的开发过程,是一本很好的入门英文教程,英文内容也比较简单
JBOSS SEAM组件中文手册 Seam_2.0_Reference_zh_CN
运用seamcarving的方式,实现了对主体感知的图像放缩,以及删除图片中选中的部分
Seam - 语境相关的组件 ,学习seam的好资料.
Seam 2.X Web Development
本文描述了seam+eclipse+jboss的下载地址配置过程等
Seam环境配置.docSeam环境配置.docSeam环境配置.docSeam环境配置.doc
JBOSS.SEAM.WEB应用开发 中文版 (美)MichaelYuan.
jboss-seam2.0文档.rarjboss-seam2.0文档.rar
in Seam. You can layer your application according to whatever architecture you devise, rather than being forced to shoehorn your application logic into an unnatural layering scheme forced upon you by ...
7.避免滥用XML 8.为测试而设计 9. 卓越的工具支持 10. 让我们开始编码吧 Seam Hello World 1. 创建一个数据模型 2. 将数据模型映射到web表单 2. 处理web事件 4. 更易于理解的seam编程模型 5. 配置和打包 6....
Manning.Seam.in.Action.Sep.2008.pdf
4. Ajax4JSF 组件库 a4j:ajaxListener a4j:region a4j:page a4j:support a4j:commandLink a4j:commandButton a4j:outputPanel a4j:actionparam a4j:status a4j:loadBundle a4j:mediaOutput 5. Ajax4jsf内...
组件库 a4j:ajaxListener a4j:region a4j:page a4j:support a4j:commandLink a4j:commandButton a4j:outputPanel a4j:actionparam a4j:status a4j:loadBundle a4j:mediaOutput 5. Ajax4jsf内建的换肤...