RichFaces 4.x Demo
a4j:commandButton
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
xmlns:f
=
"http://java.sun.com/jsf/core"
xmlns:ui
=
"http://java.sun.com/jsf/facelets"
xmlns:a4j
=
"http://richfaces.org/a4j"
<
h:outputStylesheet
>
.outhello {
font-weight: bold;
}
</
h:outputStylesheet
>
<
h:form
>
<
h:panelGrid
columns
=
"3"
>
<
h:outputText
value
=
"Name:"
/>
<
h:inputText
value
=
"#{userBean.name}"
/>
<
a4j:commandButton
value
=
"Say Hello"
render
=
"out"
execute
=
"@form"
/>
</
h:panelGrid
>
</
h:form
>
<
br
/>
<
a4j:outputPanel
id
=
"out"
>
<
h:outputText
value
=
"Hello #{userBean.name} !"
rendered
=
"#{not empty userBean.name}"
styleClass
=
"outhello"
/>
</
a4j:outputPanel
>
</
ui:composition
>
后台Bean
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.web.ManagerBean;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
/**
*
* @author dell
*/
@Named(value = "userBean")
@RequestScoped
public class UserBean {
private String name;
public UserBean() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}