here are 3 possible examples how to initialize component:
1. Using @Unwrap with method returning object - method doesn't have to be getter:
@Name("search")
public class SearchAction {
// can't be used with @Out
@Unwrap
public Map<String,Integer> initList() {
System.out.println("In-method initList");
Map<String,Integer> list = new TreeMap<String,Integer>();
list.put("one", 1);
list.put("two", 2);
list.put("three", 3);
return list;
}
}
to use this component on the page you need to call it search:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
template="layout/template.xhtml">
<ui:define name="body">
<h:form id="search" styleClass="edit">
<h:selectOneMenu>
<s:selectItems
value="#{search}"/>
</h:selectOneMenu>
</h:form>
</ui:define>
</ui:composition>
2. Using @Factory with method returning void - method doesn't have to be getter and @Out must be used to outject object to page:
@Name("search")
public class SearchAction {
// use with @Out because creation method is returning void
@Out
private Map<String,Integer> list;
@Factory("list")
public void initList() {
System.out.println("In-method initList");
list = new TreeMap<String,Integer>();
list.put("one", 1);
list.put("two", 2);
list.put("three", 3);
list.put("six", 6);
}
}
to use this component on the page you need to call it list:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
template="layout/template.xhtml">
<ui:define name="body">
<h:form id="search" styleClass="edit">
<h:selectOneMenu>
<s:selectItems
value="#{list}"/>
</h:selectOneMenu>
</h:form>
</ui:define>
</ui:composition>
3. Using @Factory with method returning object - method mut be getter, @Out is not needed
@Name("search")
public class SearchAction {
// without @Out annotation
@Factory("list")
public Map<String,Integer> getList() {
System.out.println("In-method initList");
Map<String,Integer> list = new TreeMap<String,Integer>();
list.put("one", 1);
list.put("two", 2);
list.put("three", 3);
return list;
}
}
component usage is like in example (2.)
Additionally class used in all these examples doesn't have to be EJB bean - they only have to be Seam component (marked by @Name annotation).
Each of these method is different - details can be found in http://chiralsoftware.com/jboss-seam-book/unwrap.seam as previously mentioned Thiago Rocha (thanks).
相关推荐
java jboss seam jboss-seam-selectitems
SEAM 中文开发指南(官方)
seam 中文文档 pdf 格式 JSF+EJB3.0快速开发框架Seam的中文版向导。。。
个人收集整理的最全面seam文档 包括seam_reference(中、英) richfaces jsf a4j 以及seam一些其他主要功能
Seam 中文开发指南 seam中文文档
JBOSS SEAM组件中文手册 Seam_2.0_Reference_zh_CN
seam下一代web开发框架
jboss seam 和jsf2 开发好书
seam in action 中文 english seam提供了快速开发 好长。netjava 新手学习的利器 中英文各一本,英文的好像不是很好
seam中的注解总结,包括三种JPA和seam自身的标签
Seam为 应 业务业业 义 种统 组 你的 用程序中所有的 定 了一 一的 件模型。 Seam组件可能是 态义 关关 态 有状 的,包含与几个定 良好的上下文中任何一个相 的状 , 包括长开间运行上 下文、持久化上下文、业务流程...
seam框架需要的所有jar包,支持seam ui组件
整理自jboss seam 中文站,压缩为chm格式,便于广大jboss seam爱好者阅读,所有版权归jboss seam中文站所有。
Beginning JSF 2 APIs and JBoss? Seam You’ll learn to create and enhance an eShop using practical methods, and can repurpose the template for your own personal and professional projects. What you’...
JBoss_Seam--中文、Seam教程,中文Seam针对初学者很好的讲解及实例。希望对您有所收获。
Jboss Seam中文参考手册,通过大量的实例详细介绍seam的使用
9 Seam-managed transactions and persistence 10 Rapid Seam development Part 4 – Sinking the business requirements 11 Securing Seam applications 12 Ajax and JavaScript remoting 13 File uploads, rich ...
姜耀东,赵毅鑫,The numerical approach to translatory coal bumps analysis is used to examine the effects of joint and coal seam stiffness on the outburst velocity, deformation magnitude of the ope
2007年Shai Avidan 和Ariel Shamir论文《Seam Carving for Content-Aware Image Resizing》所提出方法的Matlab代码实现和作者的论文。 效果非常炫,而且代码不长
seam资料seam资料seam资料seam资料seam资料seam资料seam资料seam资料