我想显示一条消息以确认创建群组,但我无法将其显示出来。
group.xhtml:
<h:form id="grp">
<h:panelGrid columns="2">
<h:outputText value="Titre:"></h:outputText>
<p:inputText value="#{gpeBean.titre}"></p:inputText>
<p:commandButton id="btn_save"
value="Créer"
actionListener="#{gpeBean.test}">
</p:commandButton>
</h:panelGrid>
</h:form>
</center>
</h:panelGrid>
<h:form id="cr" rendered = "#{gpeBean.created}">
<h:outputText value="#{gpeBean.message}"/>
</h:form>
我的豆子:
@ManagedBean(name = "gpeBean")
@RequestScoped
public class GroupeBean implements Serializable{
GroupDAO daoGrp = new GroupDaoImpl();
UserDAO dao = new UserDaoImpl();
private String titre;
public String message = "";
private boolean created = false;
public String test(ActionEvent event){
Groupe p = new Groupe();
p.setTitre(this.titre);
daoGrp.Nouveau_groupe(p);
created = true;
this.setMessage("Groupe crée!");
return "p1";
}}
当我点击按钮执行方法测试时,不显示消息。
答案 0 :(得分:0)
您在bean中使用@ViewScoped。
Xhtml:
<h:form id="grp">
<h:panelGrid columns="2">
<h:outputText value="Titre:"></h:outputText>
<p:inputText value="#{gpeBean.titre}"></p:inputText>
<p:commandButton update=":grp:cr" id="btn_save"
value="Créer"
actionListener="#{gpeBean.test}">
</p:commandButton>
</h:panelGrid>
<p:outputPanel id="cr">
<h:outputText rendered="#{gpeBean.created}" value="#{gpeBean.message}"/>
</p:outputPanel >
</h:form>