繁体   English   中英

单击撇号中的命令按钮后,消息未显示

[英]Messages are not displaying after clicking command button in primefaces

我使用输入文本,上传文件和命令按钮属性。我的文件上传模式是基本的。在命令按钮中,我使ajax = false。我在两个字段中都使用了required = true。当单击带有空字段的保存时,正在执行相应的方法并且消息在控制台中显示,但错误消息不在UI中显示。

<p:dialog widgetVar="addDialogWidgetVar" id="addDialogWidgetVarId"  dynamic="true" >

                <table  style="width: 100%;">
                        <tr>
                            <td>
                                <p:messages for="errorMsgId" id="errorMsgId" autoUpdate="true" showDetail="false" showSummary="true" closable="true"/>
                            </td>
                        </tr>
                    </table>

                <h:form id="formId" enctype="multipart/form-data">



                    <table>
                        <tr>
                            <td>
                                <label style="margin-top: 5%"><h:outputText value="Name:"/><h:outputText value="*" style="color:red"/></label>
                            </td>
                            <td width="10%"/>
                            <td>
                                <p:inputText value="#{manageBean.attachment.fileName}" id="fileNameId" maxlength="60" style="width:70"
                                            required="#{not empty param[save.clientId]}" requiredMessage="Please enter Attachment name"></p:inputText>
                            </td>
                        </tr>
                        <tr height="10"></tr>
                        <tr>
                            <td>
                                <label style="margin-top: 5%"><h:outputText value="Upload Attachment:"/><h:outputText value="*" style="color:red"/></label>
                            </td>
                            <td width="10%"/>
                            <td>
                                <p:fileUpload label="Select a file" mode="simple" value="#{manageBean.attachment.file}"
                                            allowTypes="/(\.|\/)(pdf|doc|docx|xls|xlsx|gif|jpg|jpeg|png|PNG|GIF|JPG|JPEG)$/"
                                            invalidFileMessage="Allow only (pdf|doc|docx|xls|xlsx|gif|jpg|jpeg|png|PNG|GIF|JPG|JPEG) file."
                                            multiple="false" required="#{not empty param[save.clientId]}" requiredMessage="Please select a file" >
                                </p:fileUpload>

                            </td>
                        </tr>
                        </table>
                        <br />
                        <table style="margin-left: 30%;">                           
                        <tr align="center">

                            <td>
                                <p:commandButton value="Close" actionListener="#{manageBean.cancelAttachment}" oncomplete="addDialogWidgetVar.hide()" />
                            </td>

                            <td> 
                                <p:commandButton id="submitbtnid" value="Save" ajax="false" binding="#{save}"
                                            actionListener="#{manageBean.saveAttachment}" update=":errorMsgId"/>
                            </td>
                        </tr>
                    </table>

                </h:form>

            </p:dialog>

尝试在没有ajax的情况下进行提交测试,并将p:growl放入页面中,尝试获取没有更新消息组件的消息并查找错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM