私はリッチフェイス 4 を使用しています。 http://livedemo.exadel.com/richfaces-demo/richfaces/stateAPI.jsf?c=stateAPIから例を取り上げました。livedemo サイトでは問題なく動作します。しかし、私にとってはうまくいきません。a4j:commandLink をクリックしてもサーバーへのリクエストがないことが (開発者ツールによって) chrome でわかります。インターネットで答えを見つけることに絶望しています。コードの何が問題になっていますか?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head>
<h:body>
<center>
<rich:panel style="width:320px;" id="panel">
<f:facet name="header">
<h:panelGroup>
<h:outputText value="Login"/>
<a4j:commandLink action="#{userBean.doSwitch}" value="(to register)" immediate="true"
render="panel" />
</h:panelGroup>
</f:facet>
<rich:message for="action"/>
<h:panelGrid columns="3" columnClasses="col1,col2">
<h:outputText value="username"/>
<h:inputText value="#{userBean.login}" id="login" required="true">
<f:validateLength minimum="3" maximum="30"/>
</h:inputText>
<rich:message for="login" showSummary="false"/>
<h:outputText value="password"/>
<h:inputSecret value="#{userBean.password}" id="password" required="true">
<f:validateLength minimum="5" maximum="30"/>
</h:inputSecret>
<rich:message for="password"/>
<h:outputText value="confirm" rendered="#{userBean.state}"/>
<h:inputSecret value="#{userBean.passwordConfirmation}"
rendered="#{userBean.state}" id="passwordConfirmation" required="true">
<f:validateLength minimum="5" maximum="30"/>
</h:inputSecret>
<rich:message for="passwordConfirmation"/>
</h:panelGrid>
<a4j:commandButton action="#{userBean.doLogin}" rendered="#{!userBean.state}" value="login" id="actionL"/>
<a4j:commandButton action="#{userBean.doRegister}" rendered="#{userBean.state}" value="register" id="actionR"/>
</rich:panel>
</center>
</h:body>
</html>
そしてマネージドBean
@ManagedBean
@SessionScoped
public class UserBean {
private String login;
private String password;
private String passwordConfirmation;
private boolean state;
public UserBean() {
super();
this.state = false;
}
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public String doSwitch(){
this.setState(true);
return "loginss";
}
public String doLogin() {
return "done";
}
public String doRegister() {
そして、私はライブラリを使用します:
richfaces-core-impl-4.3.1.Final richfaces-core-api-4.3.1.Final richfaces-components-ui-4.3.1.Final richfaces-components-api-4.3.1.Final sac-1.3 javax.faces -2.1.7 グアバ-14.0.1 cssparser-0.9.7
また、a4j:commandlink を押しても、Eclipse にエラー メッセージは表示されません。そして私のweb.xml
<welcome-file-list>
<welcome-file>/faces/register.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>2</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>glassX</param-value>
</context-param>
<filter>
<display-name>Ajax4jsf Filter</display-name>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>