在Glassfish 4.1上使用PF 5.1,JSF 2.2.7.
我有一个简单的例子selectOneMenu
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Test</title>
</h:head>
<h:body>
<h:form>
<p:selectOneMenu value="#{testBean.text}">
<p:ajax listener="#{testBean.test()}" update="outputpanel"/>
<f:selectItem itemLabel="1" itemValue="1"/>
<f:selectItem itemLabel="2" itemValue="2"/>
<f:selectItem itemLabel="3" itemValue="3"/>
</p:selectOneMenu>
<p:outputPanel id="outputpanel">
#{testBean.text}
</p:outputPanel>
</h:form>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
豆:
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
@Named
@ViewScoped
public class TestBean implements Serializable
{
private String text;
public String getText() {
return text;
}
public void setText(String text) {
System.out.println("settext: " + …
Run Code Online (Sandbox Code Playgroud)