Primefaces CommandLink

时间:2020-02-23 14:41:38  来源:igfitidea点击:

今天,我们将研究Primefaces CommandLink组件。
Primefaces CommandLink扩展了具有Ajax功能的标准JSF commandLink。

Primefaces CommandLink

下表包含Primefaces CommandLink组件的一些基本信息。

TagcommandLink
Component Classorg.primefaces.component.commandlink.CommandLink
Component Typeorg.primefaces.component.CommandLink
Component Familyorg.primefaces.component
Renderer Typeorg.primefaces.component.CommandLinkRenderer
Renderer Classorg.primefaces.component. commandlink.CommandLinkRenderer

Primefaces CommandLink属性

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 side UIComponent instance in a backing bean
valuenullStringHref value of the rendered anchor.
actionnullMethodExpr/StringA method expression or a String outcome that’d be processed when link is clicked.
actionListenernullMethodExprAn actionlistener that’d be processed when link is clicked.
immediatefalseBooleanBoolean value that determines the phaseId, when true actions are processed at apply_request_values, when false at invoke_application phase.
asyncfalseBooleanWhen set to true, ajax requests are not queued.
processnullStringComponent(s) to process partially instead of whole view.
ajaxtrueBooleanSpecifies the submit mode, when set to true(default), submit would be made with Ajax.
updatenullStringComponent(s) to be updated with ajax.
onstartnullStringClient side callback to execute before ajax request is begins.
oncompletenullStringClient side callback to execute when ajax request is completed.
onsuccessnullStringClient side callback to execute when ajax request succeeds.
onerrornullStringClient side callback to execute when ajax request fails.
globaltrueBooleanDefines whether to trigger ajaxStatus or not.
delaynullStringIf 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.
partialSubmitfalseBooleanEnables serialization of values belonging to the partially processed components only.
resetValuesfalseBooleanIf true, local values of input components to be updated within the ajax request would be reset.
ignoreAutoUpdatefalseBooleanIf 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.
stylenullStringStyle to be applied on the anchor element
styleClassnullStringStyleClass to be applied on the anchor element
onblurnullStringClient side callback to execute when link loses focus.
onclicknullStringClient side callback to execute when link is clicked.
ondblclicknullStringClient side callback to execute when link is double clicked.
onfocusnullStringClient side callback to execute when link receives focus.
onkeydownnullStringClient side callback to execute when a key is pressed down over link.
onkeypressnullStringClient side callback to execute when a key is pressed and released over link.
onkeyupnullStringClient side callback to execute when a key is released over link.
onmousedownnullStringClient side callback to execute when a pointer button is pressed down over link.
onmousemovenullStringClient side callback to execute when a pointer button is moved within link.
onmouseoutnullStringClient side callback to execute when a pointer button is moved away from link.
onmouseovernullStringClient side callback to execute when a pointer button is moved onto link.
onmouseupnullStringClient side callback to execute when a pointer button is released over link.
accesskeynullStringAccess key that when pressed transfers focus to the link.
charsetnullStringCharacter encoding of the resource designated by this hyperlink.
coordsnullStringPosition and shape of the hot spot on the screen for client use in image maps.
dirnullStringDirection indication for text that does not inherit directionality. Valid values are LTR and RTL.
disablednullBooleanDisables the link
hreflangnullStringLanguae code of the resource designated by the link.
relnullStringRelationship from the current document to the anchor specified by the link, values are provided by a space-separated list of link types.
revnullStringA reverse link from the anchor specified by this link to the current document, values are provided by a space-separated list of link types.
shapenullStringShape of hot spot on the screen, valid values are default, rect, circle and poly.
tabindexnullIntegerPosition of the button element in the tabbing order.
targetnullStringName of a frame where the resource targeted by this link will be displayed.
titlenullStringAdvisory tooltip information.
typenullStringType of resource referenced by the link.

Primefaces CommandLink示例

Primefaces CommandLink与JSFh:commandLink类似,不同之处在于默认情况下该表单是使用ajax提交的。

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.theitroad.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 "";
	}
}