日期:2014-05-16 浏览次数:20503 次
<h:body>
<!-- . . . -->
<h:outputScript
name="jsf.js"
library="javax.faces"
target="body"/>
<!-- . . . -->
</h:body><h:form prependId="false">
<h:inputText value="#{user.name}" id="name"/>
<h:inputText value="#{user.password}" id="password"/>
<h:commandButton value="Login"
type="button"
actionListener="#{user.login}"
onclick="jsf.ajax.request(this, event, {execute:
'name password', render: 'status'}); return false;"/>
<h:outputText value="#{user.status}" id="status"/>
</h:form>| 值 | 描述 |
| @all | 页面上的所有组件 |
| @none | 无组件,这是默认值 |
| @this | 触发请求的组件 |
| @form | form 表单中的所有组件 |
| ID 列表 | 组件 ID 的列表 |
| EL 表达式 | 返回一组 String 列表的 EL 表达式 |
@Named
@SessionScoped
public class User implements Serializable {
private String name;
private String password;
private String status;
public void login(ActionEvent evt) {
if (name.equals(password))
status = "Login successful";
else
status = "Login failed";
}
}<h:form prependId="false">
<h:inputText value="#{user.name}"
id="name"/>
<h:inputText value="#{user.password}"
id="password"/>
<h:commandButton value="Login"
type="button"
actionListener="#{user.login}">
<f:ajax execute="name password"
render="status"/>
</h:commandButton>
<h:outputText value="#{user.status}"
id="status"/>
</h:form><f:ajax delay="200" ...> . . . </f:ajax>
public void checkFormat(AjaxBehaviorEvent evt) {
//. . .
}