[java]代码库
<h:body>
<!-- . . . -->
<h:outputScript
name="jsf.js"
library="javax.faces"
target="body"/>
<!-- . . . -->
</h:body>//源代码片段来自云代码http://yuncode.net
<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>//源代码片段来自云代码http://yuncode.net
@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";
}
}//源代码片段来自云代码http://yuncode.net