📅  最后修改于: 2021-01-08 04:27:51             🧑  作者: Mango
它是带有Ajax,部分处理和确认功能的JSF h:commandLink的扩展版本。它用于创建将控制重定向到指定目标的链接。
组件用于在JSF应用程序中创建链接。它具有下表列出的各种属性。
Attribute | Default value | Type | Description |
---|---|---|---|
id | null | String | Unique identifier of the component |
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. |
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. |
global | true | Boolean | Defines whether to trigger ajaxStatus or not. |
resetValues | false | Boolean | If true, local values of input components to be updated within the ajax request would be reset. |
timeout | 0 | Integer | Timeout for the ajax request in milliseconds. |
type | null | String | Type of resource referenced by the link. |
form | null | String | Form to serialize for an ajax request. Default is the enclosing form. |
在下面的示例中,我们正在实现组件。本示例包含以下文件。
// commandLink.xhtml
CommandLink
CommandLink Example
// CommandLink.java
package com.javatpoint;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
@ManagedBean
public class CommandLink {
public void buttonAction(ActionEvent actionEvent) {
addMessage("You just clicked a link");
}
public void addMessage(String summary) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, null);
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
输出: