0

我的问题既简单又困难。

我想在我p:dialog里面显示一些信息。所以我使用我的面板网格来做到这一点。但它不显示信息,我不知道为什么。所以这是我的页面和我的 bean 的代码;)

(我使用的是 PrimeFaces 4.0、Mojara 2.1.6)

消息豆

 package ma.corporate.bean;

    import java.io.Serializable;
    import java.util.List;
    import javax.faces.bean.ManagedBean;

    import javax.faces.bean.SessionScoped;

    import ma.corporate.facade.MessageFacade;
    import ma.corporate.model.Message;

    @ManagedBean(name = "messageBean")
    @SessionScoped
    public class MessageBean implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private MessageFacade messageFacade;
    private List<Message> messages;
    private Message message;
    private static int cpt=0;
    //private Message message2;

    public MessageBean() {
        // messageFacade = new MessageFacade();
        // messages = messageFacade.Lister();
        /*
         * if(messages==null) System.out.println("null"); else
         * System.out.println(messages.get(0).getTextMessage());
         */
        //message2=new Message();
        message = new Message();
        cpt++;
    }

    public List<Message> getMessages() {
        // messages = messageFacade.Lister();
        messageFacade = new MessageFacade();
        messages = messageFacade.Lister();
        return messages;
    }

    public void setMessages(List<Message> messages) {
        this.messages = messages;
    }

    public Message getMessage() {
        return message;
    }

    public void setMessage(Message message) {
        this.message = message;
    }

    public void save() {
        messageFacade.enregistrer(message);
    }

    public void Supprimer(Message message) {
        messageFacade.supprimer(message);
        messages = messageFacade.Lister();
    }

    public void init(Message message) {
        //this.message.setEmail("aaaaaaaaaaaaaa");
        //this.message.setNomComplet("bbbbbbbbbbbbbbbb");
        //this.message.setTelephone("343232");
        this.message = message;
        System.out.println(this.message.getNomComplet());
        System.out.println(cpt);
    }

}

由于我想发布它时出现错误,我无法制作我的 html 页面的代码。

<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head></h:head>
<h:body>
<h:form id="form1">
    <p:growl id="messages" showDetail="true" />
    <p:dataTable var="message" value="#{messageBean.messages}" id="table">
        <p:column headerText="Nom Complet" style="width:200px">
            <h:outputText value="#{message.nomComplet}" />
        </p:column>

        <p:column headerText="Telephone" style="width:200px">
            <h:outputText value="#{message.telephone}" />
        </p:column>

        <p:column headerText="Email" style="width:200px">
            <h:outputText value="#{message.email}" />
        </p:column>

        <p:column headerText="Objet" style="width:200px">
            <h:outputText value="#{message.objet}" />
        </p:column>

        <p:column headerText="Options" style="width:200px">
            <p:commandLink onclick="PF('dlg3').show();" process="@this"
                actionListener="#{messageBean.init(message)}">
                <h:graphicImage value="/Administration/img/afficher2.jpg"
                    style="width:60px;height:60px;" />
            </p:commandLink>
            <p:commandLink>
                <h:graphicImage value="/Administration/img/reply.png"
                    style="width:60px;height:60px;" />
            </p:commandLink>
            <p:commandLink actionListener="#{messageBean.Supprimer(message)}"
                ajax="true" update=":form1:table" process=":form1:table">
                <p:graphicImage value="/Administration/img/spprimer.png"
                    style="width:60px;height:60px;" />
                <p:confirm header="Confirmation" message="êtes vous sur?"
                    icon="ui-icon-alert" />
            </p:commandLink>

            <p:confirmDialog global="true" showEffect="fade"
                hideEffect="explode">
                <p:commandButton value="Yes" type="button"
                    styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
                    update="table" />
                <p:commandButton value="No" type="button"
                    styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
            </p:confirmDialog>

        </p:column>
    </p:dataTable>
<!-- the problem is the dialog below -->
    <p:dialog header="Message" widgetVar="dlg3" showEffect="explode"
        hideEffect="bounce" resizable="true" >
        <h:form>
            <p:panelGrid columns="2">

                <h:outputLabel value="Nom Complet: " />
                <h:inputTextarea id="firstname" value="#{messageBean.message.nomComplet}" />

                <h:outputLabel value="Telephone :" />
                <h:outputLabel id="Telephone"
                    value="#{messageBean.message.telephone}" />

                <h:outputLabel value="Email :" />
                <p:outputLabel id="Email" value="#{messageBean.message.email}" />

                <h:outputLabel value="Objet :" />
                <h:outputLabel id="Objet" value="#{messageBean.message.objet}" />

                <h:outputLabel value="TextMessage :" />
                <h:outputLabel id="TextMessage"
                    value="#{messageBean.message.textMessage}" />

            </p:panelGrid>
        </h:form>
    </p:dialog>
</h:form>
<ui:remove>
    <!--<p:dialog widgetVar="dlg2" global="true" showEffect="fade"
        hideEffect="explode">
        <h:panelGrid columns="1">
            <h:outputText value="êtes vous sur?" />
            <p:separator />
            <h:panelGrid columns="2">
                <p:commandButton value="Yes" type="button"
                    styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
                <p:commandButton value="No" type="button"
                    styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
            </h:panelGrid>
        </h:panelGrid> 
        </p:dialog> -->
</ui:remove>

4

1 回答 1

0

看起来像一个更新问题。bean 从 xhtml 页面获取值?如果他得到它,请尝试替换这两行:

<p:commandLink onclick="PF('dlg3').show();" process="@this" actionListener="#{messageBean.init(message)}">

<p:dialog header="Message" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" resizable="true">

经过 :

<p:commandLink onclick="PF('dlg3').show();" update=":form1:dlg3" process="@this" actionListener="#{messageBean.init(message)}">

<p:dialog header="Message" id="dlg3" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" resizable="true">
于 2014-05-14T16:59:43.917 回答