显示确认信息

时间:2013-06-03 13:14:32

标签: forms primefaces rendering

我想显示一条消息以确认创建群组,但我无法将其显示出来。

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";
   }}

当我点击按钮执行方法测试时,不显示消息。

1 个答案:

答案 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>