primefaces
Today we will look into Primefaces CommandLink component. Primefaces CommandLink extends standard JSF commandLink with Ajax capabilities.
今天,我们将研究Primefaces CommandLink组件。 Primefaces CommandLink扩展了具有Ajax功能的标准JSF commandLink。
Primefaces CommandLink (Primefaces CommandLink)
Below table contains some of the basic information of Primefaces CommandLink component.
下表包含Primefaces CommandLink组件的一些基本信息。
Tag | commandLink |
---|---|
Component Class | org.primefaces.component.commandlink.CommandLink |
Component Type | org.primefaces.component.CommandLink |
Component Family | org.primefaces.component |
Renderer Type | org.primefaces.component.CommandLinkRenderer |
Renderer Class | org.primefaces.component. commandlink.CommandLinkRenderer |
标签 | 命令链接 |
---|---|
组件类别 | org.primefaces.component.commandlink.CommandLink |
组件类型 | org.primefaces.component.CommandLink |
组件族 | org.primefaces.component |
渲染器类型 | org.primefaces.component.CommandLinkRenderer |
渲染器类 | org.primefaces.component。 commandlink.CommandLinkRenderer |
Primefaces CommandLink属性 (Primefaces CommandLink 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 |
value | null | String | Href value of the rendered anchor. |
action | null | MethodExpr/ String | A method expression or a String outcome that’d be processed when link is clicked. |
actionListener | null | MethodExpr | An actionlistener that’d be processed when link is clicked. |
immediate | false | Boolean | Boolean value that determines the phaseId, when true actions are processed at apply_request_values, when false at invoke_application phase. |
async | false | Boolean | When set to true, ajax requests are not queued. |
process | null | String | Component(s) to process partially instead of whole view. |
ajax | true | Boolean | Specifies the submit mode, when set to true(default), submit would be made with Ajax. |
update | null | String | Component(s) to be updated with ajax. |
onstart | null | String | Client side callback to execute before ajax request is begins. |
oncomplete | null | String | Client side callback to execute when ajax request is completed. |
onsuccess | null | String | Client side callback to execute when ajax request succeeds. |
onerror | null | String | Client side callback to execute when ajax request fails. |
global | true | Boolean | Defines whether to trigger ajaxStatus or not. |
delay | null | String | If less than delay milliseconds elapses between calls to request() only the most recent one is sent and all other requests are discarded. If this option is not specified, or if the value of delay is the literal string ‘none’ without the quotes, no delay is used. |
partialSubmit | false | Boolean | Enables serialization of values belonging to the partially processed components only. |
resetValues | false | Boolean | If true, local values of input components to be updated within the ajax request would be reset. |
ignoreAutoUpdate | false | Boolean | If true, components which autoUpdate=”true” will not be updated for this request. If not specified, or the value is false, no such indication is made. |
style | null | String | Style to be applied on the anchor element |
styleClass | null | String | StyleClass to be applied on the anchor element |
onblur | null | String | Client side callback to execute when link loses focus. |
onclick | null | String | Client side callback to execute when link is clicked. |
ondblclick | null | String | Client side callback to execute when link is double clicked. |
onfocus | null | String | Client side callback to execute when link receives focus. |
onkeydown | null | String | Client side callback to execute when a key is pressed down over link. |
onkeypress | null | String | Client side callback to execute when a key is pressed and released over link. |
onkeyup | null | String | Client side callback to execute when a key is released over link. |
onmousedown | null | String | Client side callback to execute when a pointer button is pressed down over link. |
onmousemove | null | String | Client side callback to execute when a pointer button is moved within link. |
onmouseout | null | String | Client side callback to execute when a pointer button is moved away from link. |
onmouseover | null | String | Client side callback to execute when a pointer button is moved onto link. |
onmouseup | null | String | Client side callback to execute when a pointer button is released over link. |
accesskey | null | String | Access key that when pressed transfers focus to the link. |
charset | null | String | Character encoding of the resource designated by this hyperlink. |
coords | null | String | Position and shape of the hot spot on the screen for client use in image maps. |
dir | null | String | Direction indication for text that does not inherit directionality. Valid values are LTR and RTL. |
disabled | null | Boolean | Disables the link |
hreflang | null | String | Languae code of the resource designated by the link. |
rel | null | String | Relationship from the current document to the anchor specified by the link, values are provided by a space-separated list of link types. |
rev | null | String | A reverse link from the anchor specified by this link to the current document, values are provided by a space-separated list of link types. |
shape | null | String | Shape of hot spot on the screen, valid values are default, rect, circle and poly. |
tabindex | null | Integer | Position of the button element in the tabbing order. |
target | null | String | Name of a frame where the resource targeted by this link will be displayed. |
title | null | String | Advisory tooltip information. |
type | null | String | Type of resource referenced by the link. |
名称 | 默认 | 类型 | 描述 |
---|---|---|---|
ID | 空值 | 串 | 组件的唯一标识符 |
呈现 | 真正 | 布尔型 | 布尔值,用于指定组件的呈现,当设置为false时将不呈现组件。 |
捆绑 | 空值 | 目的 | El表达式,它映射到支持Bean中的服务器端UIComponent实例 |
值 | 空值 | 串 | 渲染锚点的Href值。 |
行动 | 空值 | MethodExpr /字符串 | 单击链接时将处理的方法表达式或字符串结果。 |
actionListener | 空值 | 方法专家 | 单击链接时将要处理的动作监听器。 |
即时 | 假 | 布尔型 | 当在apply_request_values处理为真时,在invoke_application阶段为false时,确定phaseId的布尔值。 |
异步的 | 假 | 布尔型 | 设置为true时,ajax请求不会排队。 |
处理 | 空值 | 串 | 要部分处理而不是整个视图的组件。 |
阿贾克斯 | 真正 | 布尔型 | 指定提交模式,当设置为true(默认)时,将使用Ajax进行提交。 |
更新 | 空值 | 串 | 用ajax更新的组件。 |
启动时 | 空值 | 串 | 在ajax请求开始之前执行的客户端回调。 |
未完成 | 空值 | 串 | 在ajax请求完成时执行的客户端回调。 |
成功 | 空值 | 串 | 在ajax请求成功时执行的客户端回调。 |
错误 | 空值 | 串 | 在ajax请求失败时执行的客户端回调。 |
全球 | 真正 | 布尔型 | 定义是否触发ajaxStatus。 |
延迟 | 空值 | 串 | 如果两次对request()的调用之间的延迟时间少于毫秒,则只会发送最近的一次,而所有其他请求都将被丢弃。 如果未指定此选项,或者delay的值是不带引号的文字字符串“ none”,则不使用延迟。 |
部分提交 | 假 | 布尔型 | 启用仅属于部分处理的组件的值的序列化。 |
resetValues | 假 | 布尔型 | 如果为true,则将重置ajax请求中要更新的输入组件的本地值。 |
ignoreAutoUpdate | 假 | 布尔型 | 如果为true,则不会为此请求更新autoUpdate =“ true”的组件。 如果未指定,或者值为false,则不会进行任何指示。 |
样式 | 空值 | 串 | 应用于锚元素的样式 |
styleClass | 空值 | 串 | 要应用于锚元素的StyleClass |
Onblur | 空值 | 串 | 当链接失去焦点时执行客户端回调。 |
点击 | 空值 | 串 | 单击链接时执行的客户端回调。 |
ondblclick | 空值 | 串 | 双击链接时执行客户端回调。 |
专注 | 空值 | 串 | 当链接获得焦点时执行客户端回调。 |
按键 | 空值 | 串 | 在链接上按下键时执行客户端回调。 |
按键 | 空值 | 串 | 按下并通过链接释放键时执行的客户端回调。 |
按键 | 空值 | 串 | 通过链接释放键时执行的客户端回调。 |
鼠标停下 | 空值 | 串 | 在链接上按下指针按钮时执行客户端回调。 |
情绪激动 | 空值 | 串 | 当指针按钮在链接内移动时执行客户端回调。 |
暂停 | 空值 | 串 | 当指针按钮从链接移开时执行客户端回调。 |
鼠标悬停 | 空值 | 串 | 当指针按钮移到链接上时执行客户端回调。 |
鼠标悬停 | 空值 | 串 | 通过链接释放指针按钮时执行的客户端回调。 |
快捷键 | 空值 | 串 | 按下访问键会将焦点转移到链接。 |
字符集 | 空值 | 串 | 此超链接指定的资源的字符编码。 |
座标 | 空值 | 串 | 屏幕上热点的位置和形状,供客户在图像地图中使用。 |
目录 | 空值 | 串 | 不继承方向性的文本的方向指示。 有效值为LTR和RTL。 |
残障人士 | 空值 | 布尔型 | 禁用链接 |
hreflang | 空值 | 串 | 链接指定的资源的语言代码。 |
rel | 空值 | 串 | 从当前文档到链接指定的锚点的关系,值由链接类型的空格分隔的列表提供。 |
转速 | 空值 | 串 | 从此链接指定的锚点到当前文档的反向链接,值由空格分隔的链接类型列表提供。 |
形状 | 空值 | 串 | 屏幕上热点的形状,有效值为默认值,矩形,圆形和多边形。 |
标签索引 | 空值 | 整数 | 按钮元素在制表顺序中的位置。 |
目标 | 空值 | 串 | 将显示此链接目标资源的框架的名称。 |
标题 | 空值 | 串 | 咨询工具提示信息。 |
类型 | 空值 | 串 | 链接引用的资源类型。 |
Primefaces CommandLink示例 (Primefaces CommandLink Example)
Primefaces CommandLink is similar to JSF h:commandLink
except that the form is submitted with ajax by default.
Primefaces CommandLink与JSF h:commandLink
相似,除了默认情况下使用ajax提交表单。
simpleCommandLink.xhtml
simpleCommandLink.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>
<p:commandLink value="Do Action" action="#{commandLinkManagedBean.doSomeAction}"></p:commandLink>
</h:form>
</html>
package com.journaldev.primefaces.beans;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
@ManagedBean
@SessionScoped
public class CommandLinkManagedBean {
public String doSomeAction(){
System.out.println("CommandLink is used");
return "";
}
}
Below image shows the console output when you click on the Primefaces CommandLink link multiple times.
下图显示了多次单击Primefaces CommandLink链接时的控制台输出。
That’s all for a quick roundup on Primefaces CommandLink component. You can download the Primefaces CommandLink example project from below link.
这就是对Primefaces CommandLink组件的快速总结。 您可以从下面的链接下载Primefaces CommandLink示例项目。
翻译自: https://www.journaldev.com/12150/primefaces-commandlink
primefaces