primefaces_Primefaces工具栏,工具栏组和工具提示

本文介绍了Primefaces的工具栏、工具栏组和工具提示组件。工具栏是命令和其他内容的水平分组,具有左右占位符,可用于封装JSF/Primefaces组件。ToolbarGroup是工具栏的辅助组件,用于定义占位符。工具提示组件提供了自定义效果、事件和HTML内容,可与Primefaces组件配合使用,还支持全局和异步更新。
摘要由CSDN通过智能技术生成

primefaces

Primefaces Toolbar is a horizontal grouping for commands and other contents.

Primefaces工具栏是命令和其他内容的水平分组。

Primefaces工具栏基本信息 (Primefaces Toolbar Basic Info)

TagToolbar
Component Classorg.primefaces.component.toolbar.Toolbar
Component Typeorg.primefaces.component.Toolbar
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.ToolbarRenderer
Renderer Classorg.primefaces.component.toolbar.ToolbarRenderer
标签 工具列
组件类别 org.primefaces.component.toolbar.Toolbar
组件类型 org.primefaces.component.Toolbar
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.ToolbarRenderer
渲染器类 org.primefaces.component.toolbar.ToolbarRenderer

Primefaces工具栏属性 (Primefaces Toolbar Attributes)

NameDefaultTypeDescription
idnullStringUnique identifier of the component
renderedtrueBooleanBoolean value to specify the rendering of the component, when set to false component will not be rendered.
stylenullStringInline style of the container element.
bindingnullObjectAn el expression that maps to a server sideUIComponent instance in a backing bean
styleClassnullStringStyle class of the container element.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
样式 空值 容器元素的内联样式。
捆绑 空值 目的 El表达式,它映射到支持bean中的服务器sideUIComponent实例
styleClass 空值 容器元素的样式类。

工具栏入门 (Getting Started With Toolbar)

Toolbar component has two placeholders (left & right) that are defined with facets. Following the most simple example help you understanding Toolbar component and its Left/Right sections.

工具栏组件有两个用facet定义的占位符(左和右)。 通过最简单的示例,可以帮助您了解工具栏组件及其左/右部分。

<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>
		<p:toolbar>
			<f:facet name="left">
				Left Side
			</f:facet>
			<f:facet name="right">
				Right Side
			</f:facet>
		</p:toolbar>
	</h:form>
</html>
  • Facets component used for defining Toolbar’s Left/Right Side.

    构面组件,用于定义工具栏的左侧/右侧。
  • It’s applicable for your, setting whatever components you want inside these defined sections.

    它适用于您,在这些定义的部分中设置所需的任何组件。

Primefaces Toolbar - Left & Right Sections

Now, let’s see how can we use the same Toolbar component for enclosing different types of JSF/Primefaces components.


现在,让我们看看如何使用相同的工具栏组件来封装不同类型的JSF / Primefaces组件。

<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>
	<p:toolbar>
		<f:facet name="left">
			<p:commandButton type="push" value="New" image="ui-icon-document" />
			<p:commandButton type="push" value="Open" image="ui-icon-folder-open" />
			<h:outputText value="<h2>Just HTML Separator</h2>" escape="false"></h:outputText>
		</f:facet>
		<f:facet name="right">
			<p:menuButton value="Navigate">
				<p:menuitem value="Home" url="#" />
				<p:menuitem value="Logout" url="#" />
			</p:menuButton>
		</f:facet>
	</p:toolbar>
</h:form>
</html>
  • JSF/Primefaces components can be used in conjunction with Toolbar’s sections.

    JSF / Primefaces组件可与工具栏的部分结合使用。
  • It’s also applicable for using rendered HTML using <h:outputText/>.

    它也适用于通过<h:outputText />使用呈现HTML。

Primefaces ToolbarGroup基本信息 (Primefaces ToolbarGroup Basic Info)

ToolbarGroup is a helper component for Toolbar component to define Placeholders.

ToolbarGroup是用于Toolbar组件定义占位符的帮助器组件。

TagToolbarGroup
Tagorg.primefaces.component.toolbar.ToolbarGroup
Component Typeorg.primefaces.component.ToolbarGroup
Component Familyorg.primefaces.component
标签 工具栏组
标签 org.primefaces.component.toolbar.ToolbarGroup
组件类型 org.primefaces.component.ToolbarGroup
组件族 org.primefaces.component

Primefaces ToolbarGroup属性 (Primefaces ToolbarGroup Attributes)

NameDefaultTypeDescription
idnullStringUnique identifier of the component
renderedtrueBooleanBoolean value to specify the rendering of the component, when set to false component will not be rendered.
alignnullStringDefines the alignment within toolbar, valid valuesare left and right.
stylenullStringInline style of the container element.
bindingnullObjectAn el expression that maps to a server side UIComponent instance in a backing bean
styleClassnullStringStyle class of the container element.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
对齐 空值 定义工具栏中的对齐方式,有效值位于左侧和右侧。
样式 空值 容器元素的内联样式。
捆绑 空值 目的 El表达式,它映射到支持Bean中的服务器端UIComponent实例
styleClass 空值 容器元素的样式类。

ToolbarGroup入门 (Getting Started With ToolbarGroup)

ToolbarGroup component is working in conjunction with Toolbar component, rather using of facets component for determining Right/Left place. Primefaces 5 has supported it as it’s might be not supported in the next coming version. Following simple example shows you how can we use ToolbarGroup for positioning the Toolbar’s content.

ToolbarGroup组件与Toolbar组件结合使用,而不是使用构面组件来确定“右/左”位置。 Primefaces 5支持它,因为在下一版本中可能不支持。 下面的简单示例向您展示了如何使用ToolbarGroup定位工具栏的内容。

<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>
	<p:toolbar>
		<p:toolbarGroup align="right">
			<p:commandButton type="push" value="New" image="ui-icon-document" />
			<p:commandButton type="push" value="Open" image="ui-icon-folder-open" />
		</p:toolbarGroup>
		<p:toolbarGroup align="left">
			<p:menuButton value="Navigate">
				<p:menuitem value="Home" url="#" />
				<p:menuitem value="Logout" url="#" />
			</p:menuButton>
		</p:toolbarGroup>
	</p:toolbar>
</h:form>
</html>

Primefaces工具提示基本信息 (Primefaces Tooltip Basic Info)

Similar to html, Tooltip component has the same functionality with more advantage by providing custom effects, events, html content and advance theme support.

与html相似,Tooltip组件具有相同的功能,并且通过提供自定义效果,事件,html内容和高级主题支持而具有更多优势。

NameDefaultTypeDescription
idnullStringUnique identifier of the component
renderedtrueBooleanBoolean value to specify the rendering of the component, when set to false component will not be rendered.
bindingnullObjectAn el expression that maps to a server sideUIComponent instance in a backing bean
valuenullObjectValue of the component than can be either an ELexpression of a literal text
converternullConverter/StringAn el expression or a literal text that defines aconverter for the component. When it’s an ELexpression, it’s resolved to a converter instance. Incase it’s a static text, it must refer to a converter id
widgetVarnullStringName of the client side widget.
showEventmouseoverStringEvent displaying the tooltip.
showEffectfadeStringEffect to be used for displaying.
hideEventmouseoutStringEvent hiding the tooltip.
hideEffectfadeStringEffect to be used for hiding.
showDelay150IntegerDelay time to show tooltip in milliseconds.
名称 默认 类型 描述
ID 空值 组件的唯一标识符
呈现 真正 布尔型 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。
捆绑 空值 目的 El表达式,它映射到支持bean中的服务器sideUIComponent实例
空值 目的 组件的值可以是文字文本的ELexpression
转换器 空值 转换器/字符串 定义组件转换器的el表达式或文字文本。 当它是ELexpression时,它将解析为转换器实例。 如果是静态文本,则必须引用转换器ID
widgetVar 空值 客户端小部件的名称。
showEvent 鼠标移到 显示工具提示的事件。
showEffect 褪色 用于显示的效果。
hideEvent 鼠标移出 事件隐藏工具提示。
hideEffect 褪色 用于隐藏的效果。
showDelay 150 整数 延迟时间以毫秒为单位显示工具提示。

Primefaces工具提示属性 (Primefaces Tooltip Attributes)

TagTooltip
Tagorg.primefaces.component.tooltip.Tooltip
Component Typeorg.primefaces.component.Tooltip
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.TooltipRenderer
Renderer Classorg.primefaces.component.tooltip.TooltipRenderer
标签 工具提示
标签 org.primefaces.component.tooltip.Tooltip
组件类型 org.primefaces.component.Tooltip
组件族 org.primefaces.component
渲染器类型 org.primefaces.component.TooltipRenderer
渲染器类 org.primefaces.component.tooltip.TooltipRenderer

工具提示入门 (Getting Started With Tooltip)

Tooltip component is working in conjunction with any of Primefaces components. For providing a Tooltip, two options can be used:

工具提示组件可与任何Primefaces组件一起使用。 为了提供工具提示,可以使用两个选项:

  • Provide a value and a for Tooltip’s attributes for determining the value of the Tooltip and the component that is the Tooltip is for, respectively.

    工具提示的属性提供一个和一个属性,分别确定工具提示的值和该工具提示所针对的组件。
  • Just provide a for Tooltip’s attribute, in such cases, be careful that the component the Tooltip is for has specified the title attribute.

    只需提供一个用于 Tooltip的属性,在这种情况下,请注意Tooltip所针对的组件已指定title属性。

Following sample, shows you the most simple example that help you define a Toolbar using mentioned both of ways.

下面的示例向您展示了最简单的示例,可以帮助您使用上述两种方法来定义工具栏。

<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 style="width:50%">
	Enter Username : <p:inputText id="username"></p:inputText>
	<p:separator/>
	Enter Password : <p:inputText id="password" title="Enter Password"></p:inputText>
	<p:tooltip for="username" value="Enter Username"></p:tooltip>
	<p:tooltip for="password"></p:tooltip>
</h:form>
</html>

全局工具提示 (Global Tooltip)

Primefaces has also provided a global Tooltip component. Global Tooltip binds to elements with title attributes. Global Tooltip is more efficient than using of individual instances. It’s suggested to be used instead of using individual Tooltip components unless a custom case would be implemented. Global Tooltip also has supported Ajax updates, in case your Targeted components are updating asynchronously, Global Tooltip component can still bind.

Primefaces还提供了一个全局的工具提示组件。 全局工具提示绑定到具有标题属性的元素。 全局工具提示比使用单个实例更有效。 除非要实现自定义案例,否则建议不要使用单个Tooltip组件。 Global Tooltip还支持Ajax更新,以防您的Targeted组件异步更新,Global Tooltip组件仍然可以绑定。

Following a simple example that depicts you how can you use the Global Tooltip for achieving both of Global Tooltip and Asynchronously Global Tooltip.

下面的简单示例向您描述如何使用全局工具提示来实现全局工具提示和异步全局工具提示。

<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 style="width:50%">
	<p:tooltip id="tooltip"/>
	Enter Username : <p:inputText id="username" title="Enter Username"></p:inputText>
	<p:separator/>
	Enter Password : <p:inputText id="password" title="Enter Password"></p:inputText>
	<p:separator/>
	<p:commandButton value="Change Tooltip Asynchrounsly"
		action="#{tooltipManagedBean.changeTooltipValues}"
			title="Asynchrouns Action"
				update="username password tooltip"></p:commandButton>
</h:form>
</html>

工具提示焦点,事件和效果 (Tooltip Focus, Events & Effects)

A Tooltip is shown on mouseover event and hidden when mouse is out by default. If you need to change this behavior you should use showEvent and hideEvent feature. Also, you can control the effect to be used for controlling the form that the Tooltip will use while showing.

默认情况下,鼠标悬停事件上会显示工具提示,鼠标悬停时会隐藏工具提示。 如果需要更改此行为,则应使用showEventhideEvent功能。 另外,您可以控制用于控制工具提示在显示时使用的形式的效果。

Following example shows you how can you use these events and effects for controlling the Tooltip behavior.

下面的示例向您展示如何使用这些事件和效果来控制工具提示行为。

<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 style="width:50%">
	Enter Username : <p:inputText id="username"></p:inputText>
	<p:tooltip for="username" value="Enter Username" showEvent="focus" hideEvent="blur" showEffect="bounce" hideEffect="explode" trackMouse="true"></p:tooltip>
</h:form>
</html>

工具提示HTML内容 (Tooltip HTML Content)

It’s also applicable for you to display custom content as a tooltip rather using of just text value. Just inject whatever content you want inside Tooltip component. Following example shows you a Tooltip component that contains a text value in addition to image content.

它也适用于将自定义内容显示为工具提示,而不仅仅是使用文本值。 只需将任何所需的内容注入到Tooltip组件中即可。 下面的示例向您显示一个Tooltip组件,该组件除了图像内容外还包含文本值。

<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>
<p:tooltip/>
<h:form style="width:50%">
	Enter Username : <p:inputText id="username" title="Enter Username"></p:inputText>
	<p:tooltip for="username" showEvent="focus"
					hideEvent="blur" showEffect="bounce"
						hideEffect="explode">
		<h:graphicImage value="/resources/images/journaldev.jpg"></h:graphicImage>
	</p:tooltip>

</h:form>
</html>

摘要 (Summary)

This tutorial intended to cover Toolbar, ToolbarGroup and Tooltip that’s used intensively inside any Primefaces application. Contribute us by commenting below and download the given source code.

本教程旨在介绍在任何Primefaces应用程序中大量使用的工具栏,工具栏组和工具提示。 通过在下面发表评论来贡献我们,并下载给定的源代码。

翻译自: https://www.journaldev.com/3540/primefaces-toolbar-toolbargroup-tooltip

primefaces

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值