📜  Primefaces Confirmdialog

📅  最后修改于: 2021-01-08 04:35:28             🧑  作者: Mango

PrimeFaces ConfirmDialog

它是JavaScript确认框的高级版本。它包括各种功能,例如:蒙皮,自定义和避免弹出窗口阻止程序。它用于创建确认对话框以获取用户响应。

组件用于在JSF应用程序中创建一个确认对话框。它具有下表列出的各种属性。

ConfirmDialog属性

Attribute Default value Type Description
id null String It is an unique identifier of the component.
message null String It is used to set text to be displayed in body.
header null String It is used to set text for the header.
severity null String It is used to set message severity for the displayed icon.
width auto Integer It is used to set width of the dialog in pixels.
height auto Integer It is used to set width of the dialog in pixels.
style null String It is used to set inline CSS of the dialog container.
closable true Boolean It is used to define if close icon should be displayed or not.
appendTo null String It is used to append the dialog to the element defined by the given
search expression.
visible false Boolean Whether to display confirm dialog on load.
global false Boolean When enabled, confirmDialog becomes a shared for other
components that require confirmation.
responsive false Boolean In responsive mode, dialog adjusts itself based on screen
width.

在下面的示例中,我们正在实现组件。本示例包含以下文件。

JSF文件

// ConfirmDialog.xhtml





ConfirmBox














ManagedBean

// ConfirmBox.java

package com.javatpoint;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
@ManagedBean
public class ConfirmBox {
public void confirm() {
addMessage("Delete record","Record has been deleted.");
}
public void addMessage(String summary, String detail) {
FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, summary, detail);
FacesContext.getCurrentInstance().addMessage(null, message);
}
}

输出: