同様の質問がある多くのページを読んで検索してきましたが、commandButton がアクションを呼び出さない理由がわかりません (デバッグしましたが、それが問題です)。私のコードは単純に見えますが...動作しません。初心者の問題かもしれませんが、どこにあるのかわかりません。
JSF2 と Liferay Faces Alloy を使用して、liferay のポートレットを作成しています。
また、質問commandLink/commandButton/ajax backing bean action/listener method not invokedを読みましたが、非常に教育的ですが、どのポイントも私の問題を解決していません。
ここに私の mainView.xhtml ファイルがあります:
<?xml version="1.0"?>
<f:view
xmlns="http://www.w3.org/1999/xhtml"
xmlns:aui="http://liferay.com/faces/aui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head />
<h:body>
<h:form>
<h:messages globalOnly="true" layout="table" />
<h:outputText id="esteTexto" value="#{ramSession.texto}" />
<br />
<h:commandButton action="#{ramSession.add}" styleClass="btn btn-default" value="#{ramSession.texto}">
</h:commandButton>
</h:form>
</h:body>
</f:view>
そして、これが私の SessionScoped ManagedBean ファイル、RamSession.java です。
@ManagedBean
@SessionScoped
public class RamSession extends AbstractBaseBean implements Serializable {
private static final long serialVersionUID = 919724848720360000L;
private String texto;
public void add() {
this.texto = new String("Entrando");
}
@PostConstruct
public void postConstruct() {
this.texto = new String("Jereje");
}
public String getTexto() {
logger.info("gettingTexto");
addGlobalSuccessInfoMessage();
return this.texto;
}
public void setTexto(String texto) {
this.texto = texto;
}
}
また、actionListener メソッドを使用して、さらには ajax を使用して、文字列 (必要でなくても) を返すことも試みましたが、何もしませんでした。誰でも私を助けることができますか?どうもありがとう。