- 浏览: 754612 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (241)
- 个人思考 (1)
- 数据库 (5)
- java基础 (32)
- 软件工程 (2)
- zk开源框架 (15)
- 设计模式 (25)
- javascript (12)
- css (9)
- UML (2)
- CMMI软件需求 (3)
- CMMI软件设计 (2)
- CMMI软件实现 (1)
- CMMI软件测试 (1)
- 正则表达式 (4)
- 系统日志配置 (4)
- 应用服务器 (1)
- spring (7)
- XML (6)
- java web (10)
- Ajax (3)
- RichFaces (14)
- 问题 (1)
- 评论文章 (2)
- fushioncharts (2)
- MAVN (4)
- jquery (26)
- Ext js学习 (2)
- 学习心得 (2)
- CSS兼容问题 (3)
- XSL-FOP (1)
- Quartz (0)
- OSGI (1)
- spring--security (6)
- apache tools (1)
- eclispe 小技巧 (2)
- Ant (1)
- 杂记 (1)
- spring3系列 (5)
- java cache (4)
- EffectiveJava (2)
- 代码重构 (0)
最新评论
-
psz6696:
可以说是超级简单的Demo了,可惜没有演示设值注入和构造注入两 ...
模拟spring中的ClassPathXmlApplicationContext类的实现 -
ziyourJava:
[flash=200,200][img][url][list] ...
spring security进级篇 V 自定义标签控制显示 -
ztw1122:
...
zk组件开发指南(目录) -
zjysuv:
容我说一句 在座的各位都是垃圾 spring 3.2以后的@C ...
三. spring mvc 异常统一处理 -
chengwu1201:
二 基于Spring的异常体系处理
<h:form id="form1"> <a4j:outputPanel ajaxRendered="true"> <rich:message id="hmessage" for="infor" style="display:none" /> <script language="javascript" type="text/javascript"> //<![CDATA[ try{ var msg= document.getElementById( "form1:hmessage").innerHTML.replace(/<.+?>/gim,''); if(msg){ if(msg.length > 0){ alert(msg); } } }catch(e){} //]]> </script> </a4j:outputPanel> <h:input id="qqq"/> </h:form>
注意,在底层id号的赋值情况
FacesUtils.addErrorMessage("form1:qqq", e .getMessage());
package com.cvicse.report.ui.portal.util; import java.util.ResourceBundle; import javax.faces.FactoryFinder; import javax.faces.application.Application; import javax.faces.application.ApplicationFactory; import javax.faces.application.FacesMessage; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.faces.el.ValueBinding; import javax.faces.webapp.UIComponentTag; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; public class FacesUtils { /** * Get servlet context. * * @return the servlet context */ public static ServletContext getServletContext() { return (ServletContext) FacesContext.getCurrentInstance() .getExternalContext().getContext(); } public static ExternalContext getExternalCpntext() { return FacesContext.getCurrentInstance().getExternalContext(); } /** * Get managed bean based on the bean name. * * @param beanName * the bean name * @return the managed bean associated with the bean name */ public static Object getManagedBean(String beanName) { Object o = getValueBinding(getJsfEl(beanName)).getValue( FacesContext.getCurrentInstance()); return o; } /** * Remove the managed bean based on the bean name. * * @param beanName * the bean name of the managed bean to be removed */ public static void resetManagedBean(String beanName) { getValueBinding(getJsfEl(beanName)).setValue( FacesContext.getCurrentInstance(), null); } /** * Store the managed bean inside the session scope. * * @param beanName * the name of the managed bean to be stored * @param managedBean * the managed bean to be stored */ public static void setManagedBeanInSession(String beanName, Object managedBean) { FacesContext.getCurrentInstance().getExternalContext().getSessionMap() .put(beanName, managedBean); } /** * Get parameter value from request scope. * * @param name * the name of the parameter * @return the parameter value */ public static String getRequestParameter(String name) { return (String) FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap().get(name); } /** * Add information message. * * @param msg * the information message */ public static void addInfoMessage(String msg) { addInfoMessage(null, msg); } /** * Add information message to a sepcific client. * * @param clientId * the client id * @param msg * the information message */ public static void addInfoMessage(String clientId, String msg) { FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg)); } /** * Add error message. * * @param msg * the error message */ public static void addErrorMessage(String msg) { addErrorMessage(null, msg); } /** * Add error message to a sepcific client. * * @param clientId * the client id * @param msg * the error message */ public static void addErrorMessage(String clientId, String msg) { FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg)); } /** * Evaluate the integer value of a JSF expression. * * @param el * the JSF expression * @return the integer value associated with the JSF expression */ public static Integer evalInt(String el) { if (el == null) { return null; } if (UIComponentTag.isValueReference(el)) { Object value = getElValue(el); if (value == null) { return null; } else if (value instanceof Integer) { return (Integer) value; } else { return new Integer(value.toString()); } } else { return new Integer(el); } } private static Application getApplication() { ApplicationFactory appFactory = (ApplicationFactory) FactoryFinder .getFactory(FactoryFinder.APPLICATION_FACTORY); return appFactory.getApplication(); } private static ValueBinding getValueBinding(String el) { return getApplication().createValueBinding(el); } private static HttpServletRequest getServletRequest() { return (HttpServletRequest) FacesContext.getCurrentInstance() .getExternalContext().getRequest(); } private static Object getElValue(String el) { return getValueBinding(el).getValue(FacesContext.getCurrentInstance()); } private static String getJsfEl(String value) { return "#{" + value + "}"; } public static String getMessageByKey(String key) { String messageBundleName = FacesContext.getCurrentInstance() .getApplication().getMessageBundle(); ResourceBundle resourceBundle = ResourceBundle .getBundle(messageBundleName); try { return resourceBundle.getString(key); } catch (Exception e) { return key; } } }
发表评论
-
JSF中的隐含对象
2010-01-06 16:02 1815JSF中的隐含对象 applicationScope ... -
rich:editor具体参数列表
2009-11-10 17:34 1264mode: "textareas" th ... -
jsf中Map值的使用及jsf中数组长度的获取
2009-09-22 14:16 2712public class MapBean { priv ... -
richfaces的Layout布局
2009-09-15 23:23 2712在richfaces中,还可以通过如下的方式进行布局,以适应在 ... -
在richafaces中搭建layout的布局框架
2009-09-15 23:06 2473一直以来,都想做一个layout的布局框架,虽然r ... -
在JSTL中使用字符串处理函数
2009-09-01 10:01 2213因为在jsf要用到jstl标签,这里做有效的整理。 JSTL ... -
richfaces中表格树的展现
2009-08-19 22:50 2256最近,一直在做表格树的展现,终于做完了,发个图片show一下自 ... -
richfaces中删除对话框的提示操作
2009-08-16 11:30 1821在richfaces中操作删除时会有删除的提示,在实现过程中, ... -
richfaces的实现的list展现
2009-08-15 18:27 2195在做richafces的过程中,遇到了好多的问题 ... -
jsf中嵌套jsp
2009-08-13 14:28 1348<iframe name="downloa ... -
Jsf中实现文件的下载注意的问题
2009-08-13 14:15 36951、关于jsf文件的的下载,其实现类很简单,关键是应用需要注意 ... -
richfaces的Layout框架实例
2009-08-09 16:09 1886把richfaces的layout的例子单独摘抄出来,供以后查 ... -
Richfaces
2009-07-10 16:14 1695RichFaces 是用于 JSF 的一种新的用户界 ...
相关推荐
JSF中文教程JSF中文教程JSF中文教程JSF中文教程
jsf 中文文档jsf 中文文档jsf 中文文档jsf 中文文档
精通JSF中文教程精通JSF中文教程精通JSF中文教程精通JSF中文教程精通JSF中文教程精通JSF中文教程
本文为大家详细介绍下JSF中confirm弹出框的使用方法,感兴趣的朋友可以参考下
JSF中文文档
jsf的中文教程chm版的和讲解jsf中使用到的一些参数的传递方式,学习jsf很不错的材料……
jsf实例 JSF学习 JSF jar包 JSF jsf实例 JSF学习 JSF jar包 JSFjsf实例 JSF学习 JSF jar包 JSF jsf实例 JSF学习 JSF jar包 JSF
jsf 分页 jsf 分页 jsf 分页 jsf 分页
jsf中文使用教程jsf中文使用教程
Dhtml手册、 JSF中文教程、JSF API、struts2.0中文帮助手册.chm等等
在未来的发展中,有可能所有的J2EE应用服务器都需要支持JSF。 Java Server Faces技术好处 引入了基于组件和事件驱动的开发模式,使开发人员可以使用类似于处理传统界面的方式来开发Web应用程序。提供了行为与...
适用于JSF RI 1.0 Final Release的弹出窗口程序 <br>演示了如何弹出窗口,如果把弹出窗口的值返回父窗口
JSF入门(中文pdf)
适用于JSF RI 1.0 beta的弹出窗口程序 编辑
这里是jsf的tags的书籍。主要讲述jsf的用法。
《JSF_实战》非常好的JSF学习书《JSF_实战》非常好的JSF学习书《JSF_实战》非常好的JSF学习书《JSF_实战》非常好的JSF学习书《JSF_实战》非常好的JSF学习书《JSF_实战》非常好的JSF学习书《JSF_实战》非常好的JSF...
JSF 使用 Bean 来达到逻辑层与表现层分离的目的,Bean 的管理集中在组态档案中,您只要修改组态档案,就可以修改 Bean 之间的相依关系。 o Backing Beans o Beans 的组态与设定 o Beans 上的 List, Map 数据转换与...
JSF中文入门教程JSF中文入门教程JSF中文入门教程JSF中文入门教程
ajax4jsf中文用户指南,很全面。适合初学者
主要讲述JSF的工作方式 JSF的工作方式 JSF架构 JSF模型 JSF事件类型