📜  Primefaces旋钮

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

PrimeFaces旋钮

它是用于获取数值的输入组件。用于获取指定范围内的用户输入。 PrimeFaces提供了组件,该组件用于创建图形圆。我们可以从中选择任何数值。它还提供了下表中列出的各种属性。

旋钮属性

Attribute Default value Type Description
Value null Object It is used to set value of the component.
required false Boolean It is used to mark component as required.
min 0 Integer It represents min valid value of the component.
max 100 Integer It is used to set max valid value of the component.
step 1 Integer It is used t to set Increment/decrement step of the component.
thickness null Float It is used to set thickness of the bar.
width auto String It is used to set width of the component.
height auto String It is used to set height of the component.
foregroundColor null Object It is used to set foreground color of the component.
backgroundColor null Object It is used to set background color of the component.
colorTheme null String It is used to set theme of the knob.
disabled false Boolean It disables the input element.
showLabel true Boolean It is used to hide/show the label.
cursor false Boolean When set true to show only a cursor instead of the full bar.
labelTemplate {value} String Template of the progress value.

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

JSF文件

// toggle.xhtml





Knobs




Provide input in Range

ManagedBean

// Knob.java

package com.javatpoint;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
@ManagedBean
public class Knob implements Serializable {  
private int value = 30;  
public int getValue() {  
return value;  
}  
public void setValue(int value) {  
this.value = value;  
} 
public void onChange(){  
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, 
"You have selected: " + value, null));  
}  
}  

输出: