JSF的PhaseListener的扩展
来源:互联网 发布:推广淘宝店铺帖子范文 编辑:程序博客网 时间:2024/05/21 17:17
最近做 JSF和我们自己实现的 pageFlow的整合,基本已经完全调通了。过程中间考虑到了对JSF的 PhaseListener的扩展,后来发现这个思路对我们这个工作并没有帮助,但是 已经摸透了这个技术点,就记录下来,以后可以查查看。
1)faces-config.xml的编辑
<lifecycle>
<phase-listener>com.primeton.jsf.FlowPhaseListener</phase-listener>
</lifecycle>
就可以了。
2)listener的编辑
因为马上就要从 自己的代码中把这个多余的代码去掉,所以,还是把code全部copy出来吧。
public class FlowPhaseListener implements PhaseListener {
public void afterPhase(PhaseEvent event) {
// TODO Auto-generated method stub
}
public void beforePhase(PhaseEvent event) {
FacesContext context=event.getFacesContext();
HttpServletRequest request=(HttpServletRequest)( context.getExternalContext().getRequest());
UIViewRoot root=context.getViewRoot();
String theActionString=getActionString(root);
if(theActionString==null)
return ;
else
{//下面是我们想在listener中做的事情
int i=theActionString.indexOf(".flow");
request.setAttribute("_eosFlowID", theActionString.substring(0, i+5));
request.setAttribute("_eosFlowAction", theActionString.substring(i+6,theActionString.length()));
}
}
//访问组件树哦,这个功能不错
private String getActionString(UIComponent comp)
{
String theActionString=null;
for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
{
UIComponent childOrFacet = (UIComponent)it.next();
if(childOrFacet instanceof ActionSource)
{
ActionSource source = (ActionSource) childOrFacet;
theActionString=source.getAction().toString();
if(null!=theActionString&&theActionString.length()>0&&theActionString.indexOf(".flow")>0)
return theActionString;
}
theActionString=getActionString(childOrFacet);
}
return theActionString;
}
//指定某个阶段
public PhaseId getPhaseId() {
// TODO Auto-generated method stub
return PhaseId.PROCESS_VALIDATIONS;
}
PhaseListener的思路和在JSF中的地位大家应该都已经清楚的,否则应该也不会看这个文章,这里就不说了。
1)faces-config.xml的编辑
<lifecycle>
<phase-listener>com.primeton.jsf.FlowPhaseListener</phase-listener>
</lifecycle>
就可以了。
2)listener的编辑
因为马上就要从 自己的代码中把这个多余的代码去掉,所以,还是把code全部copy出来吧。
public class FlowPhaseListener implements PhaseListener {
public void afterPhase(PhaseEvent event) {
// TODO Auto-generated method stub
}
public void beforePhase(PhaseEvent event) {
FacesContext context=event.getFacesContext();
HttpServletRequest request=(HttpServletRequest)( context.getExternalContext().getRequest());
UIViewRoot root=context.getViewRoot();
String theActionString=getActionString(root);
if(theActionString==null)
return ;
else
{//下面是我们想在listener中做的事情
int i=theActionString.indexOf(".flow");
request.setAttribute("_eosFlowID", theActionString.substring(0, i+5));
request.setAttribute("_eosFlowAction", theActionString.substring(i+6,theActionString.length()));
}
}
//访问组件树哦,这个功能不错
private String getActionString(UIComponent comp)
{
String theActionString=null;
for (Iterator it = comp.getFacetsAndChildren(); it.hasNext(); )
{
UIComponent childOrFacet = (UIComponent)it.next();
if(childOrFacet instanceof ActionSource)
{
ActionSource source = (ActionSource) childOrFacet;
theActionString=source.getAction().toString();
if(null!=theActionString&&theActionString.length()>0&&theActionString.indexOf(".flow")>0)
return theActionString;
}
theActionString=getActionString(childOrFacet);
}
return theActionString;
}
//指定某个阶段
public PhaseId getPhaseId() {
// TODO Auto-generated method stub
return PhaseId.PROCESS_VALIDATIONS;
}
PhaseListener的思路和在JSF中的地位大家应该都已经清楚的,否则应该也不会看这个文章,这里就不说了。
- JSF的PhaseListener的扩展
- JSF的URL扩展 PrettyFaces
- 使用一个PhaseListener来熟悉JSF 生命周期
- 使用一个PhaseListener来熟悉JSF 生命周期
- 使用一个PhaseListener来熟悉JSF 生命周期
- JSF点滴积累--利用PhaseListener实现权限验证
- 用JBuilder2007开发扩展JSF标签的插件
- 怀疑论者的 JSF: JSF 应用程序的生命周期
- JSF的生命周期 (图例JSF的生命周期)
- 从JSF的切入点控制JSF
- 从JSF的切入点控制JSF
- 怀疑论者的 JSF
- JSF 应用程序的生命周期
- JSF环境的配置
- JSF 应用程序的生命周期
- JSF的第一课
- JSF session的用法
- jsf的国际化
- Linux内核Makefile文件
- DEBIAN 下安装 PHP5+mysql+APACHE2
- server.xml 中各个域的说明
- tomcat5.5.9配置
- JDBC基础(一)
- JSF的PhaseListener的扩展
- 数据结构之线性表
- Linux 内核源代码的结构
- Linux内核主要五个子系统详解
- oracle 驱动下载地址
- 寒假学习心得--从0开始学破解
- 王者归来
- Linux下安装jdk和Tomcat
- Oracle内置SQL函数-分类整理大全-1