primefaces_Primefaces消息,消息和低吼组件示例

本文档详细介绍了Primefaces中的消息组件,包括Message、Messages和Growl的基本信息、属性、显示模式和生命周期。Message是JSF消息组件的扩展,用于与特定组件关联的消息显示。Messages用于显示通用消息,而Growl则提供了一种叠加显示FacesMessages的方式,类似于Mac的通知中心。文章还涵盖了如何控制消息的严重性、自动更新、定位和显示部分。
摘要由CSDN通过智能技术生成

primefaces

Messages are normally used for notifying, informing and keep the users aware of the actions that they are achieved. Typically, messages used for displaying information, errors, warnings and so on. Primefaces like all of jsf implementations, provides a different types of components that are used for doing so. Messages, message and growl are the only components get used for this purpose. This tutorial will help you getting featured these components into your application.

消息通常用于通知,通知用户并使他们知道所实现的操作。 通常,用于显示信息,错误,警告等的消息。 像所有jsf实现一样,Primefaces提供了用于执行此操作的不同类型的组件。 消息,消息和咆哮是用于此目的的唯一组件。 本教程将帮助您在应用程序中使用这些组件。

Primefaces消息基本信息 (Primefaces Message Basic Info)

Message is a pre-skinned extended verison of the standard JSF message component.

消息是标准JSF消息组件的预先皮肤扩展的版本。

Tag message
Component Class org.primefaces.component.message.Message
Component Type org.primefaces.component.Message
Component Family org.primefaces.component
Renderer Type org.primefaces.component.MessageRenderer
Renderer Class org.primefaces.component.message.MessageRenderer
标签 信息
组件类别 org.primefaces.component.message.Message
组件类型 org.primefaces.component.Message
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.MessageRenderer
渲染器类 org.primefaces.component.message.MessageRenderer

Primefaces消息属性 (Primefaces Message Attributes)

Name Default Type Description
id null String Unique identifier of the component.
rendered true Boolean Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding null Object An el expression that maps to a server side UIComponent instance in a backing bean.
showSummary false Boolean Specifies if the summary of the FacesMessage should be displayed.
showDetail true Boolean Specifies if the detail of the FacesMessage should be displayed.
for null String Id of the component whose messages to display.
redisplay true Boolean Defines if already rendered messages should be displayed
display both String Defines the display mode.
escape true Boolean Defines whether html would be escaped or not.
severity null String Comma separated list of severities to display only.
style null String Inline style of the component.
styleClass null String Style class of the component.
名称 默认 类型 描述
ID 空值 组件的唯一标识符。
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 一个el表达式,它映射到后备bean中的服务器端UIComponent实例。
显示摘要 布尔型 指定是否显示FacesMessage的摘要。
查看详细 真正 布尔型 指定是否显示FacesMessage的详细信息。
对于 空值 要显示其消息的组件的ID。
重新显示 真正 布尔型 定义是否应显示已渲染的消息
显示 定义显示模式。
逃逸 真正 布尔型 定义是否对html进行转义。
严重程度 空值 以逗号分隔的严重性列表仅显示。
样式 空值 组件的内联样式。
styleClass 空值 组件的样式类。

Primefaces消息入门 (Getting Started With Primefaces Message)

In general, for adding messages into your application you need to add FacesMessage instances into your own FacesContext instance to be rendered at the RenderResponse phase after then. Many of these messages are added manually and at the same time others are added by jsf implementation. When you deal with validation and conversion, a lot of messages are displayed that actually aren’t part of your code. Following example shows you a simple example of validation process that generates an error message that get displayed when submitting a form without filling required input.

通常,要将消息添加到应用程序中,您需要将FacesMessage实例添加到您自己的FacesContext实例中,然后在之后的RenderResponse阶段进行渲染。 其中许多消息是手动添加的,而其他消息是通过jsf实现添加的。 当您进行验证和转换时,会显示很多实际上不属于您的代码的消息。 以下示例向您展示了一个简单的验证过程示例,该示例将生成一条错误消息,该错误消息在提交表单时不填写所需的输入而显示。

index.xhtml

index.xhtml

<html xmlns="https://www.w3.org/1999/xhtml"
	xmlns:ui="https://java.sun.com/jsf/facelets"
	xmlns:h="https://java.sun.com/jsf/html"
	xmlns:f="https://java.sun.com/jsf/core"
	xmlns:p="https://primefaces.org/ui">
<h:head>
	<script name="jquery/jquery.js" library="primefaces"></script>
</h:head>
<h:form id="form">
	<p:outputPanel>
		<p:outputLabel value="Typing of your message is mandatory:"></p:outputLabel>
	</p:outputPanel>
	<h:inputText id="input" value="#{messageManagedBean.message}" required="true"/>
	<p:message id="message" for="input"></p:message>
	<p:commandButton value="Execute JSF Lifecycle - Invoke Action" action="#{messageManagedBean.doSomeAction}" update="input message"></p:commandButton>
</h:form>
</html>

MessageManagedBean.java

MessageManagedBean.java

package com.journaldev;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class MessageManagedBean {
	private String message;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String doSomeAction(){
		return "";
	}
}

Primefaces Message - Validation Error - Initial View
Here’s detailed explanation for the above code:

Primefaces消息-验证错误-初始视图
以下是上述代码的详细说明:

  • The rendered message isn’t part of your code, it’s queued by the jsf implementation through executing of ProcessValidation phase.

    呈现的消息不是代码的一部分,它由jsf实现通过执行ProcessValidation阶段进行排队。
  • RenderResponse phase is responsible of getting messages displayed.

    RenderResponse阶段负责获取显示的消息。
  • Queuing messages require to pass through jsf lifecycle. Normal starting of jsf lifecycle get done by activating an action.

    排队消息需要通过jsf生命周期。 正常启动jsf生命周期可通过激活操作来完成。
  • To ensure that certain input is required, required attribute m
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PrimeFaces主要标签学习。 1 PrimeFaces综述 3 1.1 安装 3 1.2 配置,JSF2.0环境下用PrimeFace2.x 4 1.3 Hello World入门示例 4 1.4 UI组件: 4 2 UI组件 5 2.1 布局 5 2.1.1 Layout 页面布局 5 2.1.2 Panel用于包含其它组件,提供象windows窗口式的外观。 8 2.1.3 TabView 分页式面板组件 8 2.1.4 OutputPanel 仅用于显示元素 9 2.1.5 Fieldset 9 2.1.6 Dashboard 仪表盘 10 2.1.7 Themeswitcher 主题切换器,动态切换主题 11 2.1.8 Separator空白分隔区域 11 2.1.9 Spacer行内加空格 11 2.2 菜单 11 2.2.1 Menu 11 2.2.2 Menubar 12 2.2.3 MenuButton 13 2.2.4 Toolbar 13 2.2.5 Stack :堆叠式菜单(竖向) 13 2.2.6 Dock :动画鱼眼式菜单(横向) 14 2.3 按钮: 15 2.3.1 Button 15 2.3.2 CommandButton 15 2.3.3 CommandLink 17 2.3.4 ContextMenu 17 2.3.5 HotKey 17 2.4 输入组件 18 2.4.1 文本输入 18 2.4.1.1 Editor 18 2.4.1.2 Password 19 2.4.1.3 Password Strength 19 2.4.1.4 inputMask 输入掩码,实现格式化输入。 19 2.4.1.5 InputText 20 2.4.1.6 InputTextarea 20 2.4.1.7 Watermark :文本输入内容提示 20 2.4.1.8 Keyboard 显示一个虚拟键盘,用以支持输入字符。 21 2.4.1.9 Inplace 替换文本 22 2.4.2 选择式输入 22 2.4.2.1 AutoComplete :自动补全 22 2.4.2.2 PickList 选择列表 25 2.4.2.3 Slider 滑动条 26 2.4.2.4 Spinner 27 2.4.3 其它格式数据的输入: 27 2.4.3.1 Spreadsheet电子表格 27 2.4.3.2 Calendar 各种格式的日期输入与显示 28 2.4.3.3 Schedule 日程计划输入组件 31 2.4.3.4 Captcha :变形字符验证 31 2.4.3.5 Color Picker 32 2.5 集合(复杂格式)数据的输出与显示: 33 2.5.1 BreadCrumb :层次化页面导航条 >…>….> 33 2.5.2 Accordion:一个容器组件,它用tab动态地显示折叠或展开过程。 34 2.5.3 Carousel:多用途,标签式、分布式显示 35 2.5.4 Galleria 图片陈列廊 36 2.5.5 LightBox :图片加亮显示 37 2.5.6 DataGrid 数据栅格 37 2.5.7 DataList 用列表的形式显示数据,每个栅格可显示多个数据项 39 2.5.8 DataTable数据表格 41 2.5.9 Tree 树形显示 46 2.5.10 TreeTable 树表 47 2.5.11 DragDrop 50 2.5.11.1 Draggable组件: 50 2.5.11.2 Droppable组件 51 2.5.12 Charts基于flash的图形生成与显示 52 2.6 数据导出: 54 2.6.1 Data Exporter 54 2.6.2 Printer 56 2.7 状态: 56 2.7.1 ProgressBar 56 2.7.2 NotificationBar 57 2.8 对话框: 58 2.8.1 ConfirmDialog 58 2.8.2 Dialog 58 2.9 图形图像多媒体: 59 2.9.1 ImageCompare :提供丰富的接口比较两副图像 59 2.9.2 Graphic Text 文本图象化显示 60 2.9.3 ImageCropper 60 2.9.4 ImageSwitch 61 2.9.5 Google Maps 地图 61 2.9.6 Dyna Image 63 2.9.7 Media 65 2.9.8 Star Rating 65 2.9.9 Wizard: 66 2.10 消息: 66 2.10.1 Growl Mac风格的消息显示 66 2.10.2 Message/Messages 67 2.10.3 Tooltip 67 2.11 文件处理: 67 2.11.1 FileUpload 上传文件 67 2.11.2 FileDownload 下载文件 69 2.11.3 IdleMonitor 屏幕凝滞 70 2.11.4 Terminal 70 2.12 辅助功能(辅助其它JSF组件,给它们添加新的功能和行为): 71 2.12.1 Ajax Engine 71 2.12.2 Ajax Poll轮询 72 2.12.3 Ajax远程调用p:remoteCommand 72 2.12.4 Ajax Status 显示ajax后台运行状态。 72 2.12.5 Focus 73 2.12.6 Effect: 73 2.12.7 Collector : 74 2.12.8 Resizable 给任何JSF组件添加可调整大小的行为。 74 2.12.9 RequestContext : 75 3 TouchFaces 76 3.1.1 移动UI工具 76 3.1.2 Ajax Push/Comet 77 3.1.3 几分钟实现聊天应用: 78 4 附录 79 4.1 全部UI组件列表 84 4.2 PrimeFaces常用属性集 85
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值