0

我想显示一条消息以确认组的创建,但我无法显示它。

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

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

4

1 回答 1

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>
于 2013-06-03T14:07:17.110 回答