Jsf 2 命令按钮不调用多个选项卡上的操作p:tabView

Jsf 2 命令按钮不调用多个选项卡上的操作p:tabView,jsf-2,primefaces,commandbutton,Jsf 2,Primefaces,Commandbutton,我在p:tabView中遇到了一个dynamic=“true”的问题,我已经被困了好几天了。 我有三个选项卡,每个选项卡都有单独的表单和p:fileUpload,带有提交表单和上载文件的命令按钮。 问题是我的第一个表单或选项卡工作正常,但其他两个根本不工作或启动命令按钮操作,而是ti刷新页面。只有在第二次填写表单并按下按钮时才会调用它们。 还有一件事,fileUploadListeners甚至在所有这些选项卡中都可以正常工作,但命令按钮不起作用,或者对其他两个选项卡使用激发操作方法(只有第一次填

我在p:tabView中遇到了一个dynamic=“true”的问题,我已经被困了好几天了。 我有三个选项卡,每个选项卡都有单独的表单和p:fileUpload,带有提交表单和上载文件的命令按钮。 问题是我的第一个表单或选项卡工作正常,但其他两个根本不工作或启动命令按钮操作,而是ti刷新页面。只有在第二次填写表单并按下按钮时才会调用它们。 还有一件事,fileUploadListeners甚至在所有这些选项卡中都可以正常工作,但命令按钮不起作用,或者对其他两个选项卡使用激发操作方法(只有第一次填写表单并提交表单之后才能正常工作):

这个primefaces标签有什么问题吗(我也在使用最新版本的primefaces 3.5)或者我弄错了或者遗漏了什么??任何形式的指导都会有帮助

以下是另一个主页中包含的页面代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  

<ui:composition 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"  
   template="/MasterPage/Master.xhtml">  

   <ui:define name="Search">  

      <div class="searchBarDiv"></div>  
      <br class="clear" />  

      <div class="resultMainDiv" style="background-color: white;">  
         <p:layout style="width:1218px;height:558px;" id="layout">  

            <p:ajax event="toggle" />  
            <p:layoutUnit position="west" size="300" header="UPDATES"  
               resizable="true" collapsible="true" styleClass="sliderDiv"  
               style="color:pink;">  
            </p:layoutUnit>  

         <p:layoutUnit position="center" styleClass="resultDiv">  
               <div class="uploadDiv">  

                    <p:tabView id="tabview" cache="false" dynamic="true">  
                       <p:tab id="docTab" title="Document">  
                         <h:form id="docf" >  

                          <h:panelGrid id="grid" columns="1">  

                                   <h:panelGroup>  

                                   <h:outputLabel styleClass="advLabel"  
                                       for="mId" value="Title ">  
                                    </h:outputLabel><h:outputLabel style="color: red;">*</h:outputLabel>  
                                 <h:inputText id="mId"  
                                       styleClass="txtfield"  
                                       value="#{documentInsertController.documentTitle}">  

                                    </h:inputText>  
                                   </h:panelGroup>  



                                   <h:panelGroup>  
                                   <h:outputLabel class="advLabel">Dated </h:outputLabel>  
                                 <p:calendar styleClass="txtfield" id="dtxtOrginated"  
                                       mode="popup" navigator="true" yearRange="1900:2015"  
                                       pattern="dd-MMM-yyyy"  
                                       converter="CalendarDateStringConverter"  
                                       value="#{documentInsertController.documentOriginatedOn}" />  

                                   </h:panelGroup>  

                                   <h:panelGroup>  
                                   <h:outputLabel class="advLabel">KeyWord</h:outputLabel><h:outputLabel  
                                    style="color: red;"> *</h:outputLabel>  
                                 <h:inputText id="dtxtKeywordsList"  
                                       value="#{documentInsertController.documentKeywords}"  
                                       styleClass="txtfield"  />  
                                   </h:panelGroup>  

                                      <h:panelGrid rendered="#{renderBean.viewLoad}">  
                                 <h:panelGroup> <h:outputLabel class="advLabel">Select Document</h:outputLabel><h:outputLabel  
                                    style="color: red;"> *</h:outputLabel>  
                                    <p:fileUpload  id="fu" allowTypes="/(\.|\/)(DOC|DOCX|doc|docx|ppt|xls|xlsx|pdf)$/"  
                                multiple="false" mode="advanced" sizeLimit="41949000" showButtons="false"  
                                 fileUploadListener="#{documentInsertController.uploadPListener}" label="Browse"   
                                 value="#{documentInsertController.file}"  >  
                                 <h:message id="docMSG" for="fu"></h:message>  
                                 </p:fileUpload>  

                                    </h:panelGroup>  

                                    <h:panelGroup>  
                                       <p:commandButton id="DocUpoadLoad" styleClass="btn"  
                                 value="Load File For Preview" ajax="false"  
                                 action="#{documentInsertController.loadDocForPreview}"  

                                 style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold;width:170px; height:25px;">  

                              </p:commandButton>  
                                    </h:panelGroup>  
                                    </h:panelGrid>     

               </h:panelGrid>  
                  </h:form>  

                           <p:commandButton id="DocUploadbtn" value="Upload"  
                              action="#{documentInsertController.saveDocument}"  
                              ajax="false"  
                              style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold; ">  

                           </p:commandButton>  

                        </h:panelGrid>        

                     </p:tab>  

                     <p:tab id="imgTab" title="Image">  

                        <h:form id="imagef" >  
                     <h:panelGrid id="grid" columns="1">  
                           <h:panelGroup> <h:outputLabel class="advLabel">Title </h:outputLabel> <h:outputLabel  
                                    style="color: red;"> *</h:outputLabel>  
                                 <h:inputText id="txtImgTitle"  
                                       value="#{mediaInsertController.mediaTitle}"  
                                       styleClass="txtfield" >  
                                    </h:inputText>  
                                     </h:panelGroup>  
                              <h:panelGroup> <h:outputLabel class="advLabel">Taken Date</h:outputLabel>  
                                 <p:calendar styleClass="txtfield"  
                                       id="imgtxtOrginated" mode="popup" navigator="true"  
                                       yearRange="1900:2015" pattern="dd-MMM-yyyy"  
                                       converter="CalendarDateStringConverter"  
                                       value="#{mediaInsertController.mediaTakenOn}" />  
                              </h:panelGroup>  

                              <h:panelGroup> <h:outputLabel class="advLabel">Description</h:outputLabel>  
                                   <h:inputTextarea id="txtImgDescription"  
                                       value="#{mediaInsertController.mediaDescription}"  
                                       styleClass="txtImgDescription" /></h:panelGroup>  

                              <h:panelGroup> <h:outputLabel class="advLabel">Select Image</h:outputLabel><h:outputLabel  
                                    style="color: red;"> *</h:outputLabel>  


                                 <p:fileUpload id="fuImage" allowTypes="/(\.|\/)(jpeg|jpg|png|bmp|gif|GIF|PNG)$/"  
                                multiple="false" mode="advanced" sizeLimit="6291456" showButtons="false"  
                                 label="Browse"   invalidSizeMessage="File exceeds limmit 6 MB "  
                                 value="#{mediaInsertController.file}" fileUploadListener="#{mediaInsertController.uploadPListener}"  />  
                                 <h:message id="imgMSG" for="fuImage"></h:message>  
                                    </h:panelGroup>  


                           <p:commandButton styleClass="btn" id="btnUploadImage_Click" ajax="false"  
                                             value="Upload"  actionListener="#{mediaInsertController.saveImage}"  
                                             style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold; ">  

                              </p:commandButton>  

                           </h:panelGrid>  

                        </h:form>  

                     </p:tab>  

                     <p:tab id="vidTab" title="Video">  

                           <h:form id="videof" >  
                     <h:panelGrid   id="grid" columns="1">  
                                 <h:panelGroup>  
                                 <h:outputLabel class="advLabel">Title </h:outputLabel> <h:outputLabel  
                                    style="color: red;"> *</h:outputLabel>  
                                 <h:inputText id="vtxtTitle"  
                                       value="#{mediaInsertController.mediaTitle}"  
                                       styleClass="txtfield" maxlength="50" >  
                                    </h:inputText></h:panelGroup>  

                              <h:panelGroup> <h:outputLabel class="advLabel">Taken Date</h:outputLabel>  
                                 <p:calendar styleClass="txtfield" id="vtxtOrginated"  
                                       mode="popup" navigator="true" yearRange="1900:2015"  
                                       pattern="dd-MMM-yyyy"  
                                       converter="CalendarDateStringConverter"  
                                       value="#{mediaInsertController.mediaTakenOn}" />  
                              </h:panelGroup>  

                              <h:panelGroup> <h:outputLabel for="txtVidDescription"  
                                       value="Description" styleClass="advLabel"></h:outputLabel>  

                                   <h:inputTextarea id="txtVidDescription"  
                                       value="#{mediaInsertController.mediaDescription}"  
                                       styleClass="txtUploading" style="height:40px" />  
                              </h:panelGroup>  
                              <h:panelGroup> <h:outputLabel class="advLabel">Select Video</h:outputLabel><h:outputLabel  
                                    style="color: red;"> *</h:outputLabel>  

                                 <p:fileUpload id="fuVideo" allowTypes="/(\.|\/)(mp4|flv|swf)$/" invalidFileMessage="Invalid file content"  
                                multiple="false" mode="advanced" sizeLimit="629145699" showButtons="false" update="vidMSG"  
                                 fileUploadListener="#{mediaInsertController.uploadPListener}" label="Browse" invalidSizeMessage="Size exeeds limit 600MB"  
                                 value="#{mediaInsertController.file}" />  
                              <h:message id="vidMSG" for="fuVideo"></h:message>  


                                 </h:panelGroup>  




                           <p:commandButton styleClass="btn" id="btnUploadVideo_Click" ajax="false"  
                              value="Upload" action="#{mediaInsertController.saveVideo}"  
                              style="background-color:#FEAA41;background-image:none;color:white;font-weight:bold; ">  

                           </p:commandButton>  

                           </h:panelGrid>                             


                        </h:form>  

                     </p:tab>  


                    </p:tabView>  

               </div>  

            </p:layoutUnit>  
         </p:layout>  

         <p:growl autoUpdate="true" sticky="true" id="uploadMSG"></p:growl>  

      </div>  
   </ui:define>  
</ui:composition>  


您的
命令按钮id=“DocUploadbtn”
在h:form之外,这可能会影响一些事情。在同一区域周围似乎也有三个关闭
h:panelGrid
标记;它可能是格式不正确的XHTML吗?

即使是在表单内部也是一样的问题。图像和视频选项卡按钮不调用任何操作我完全删除了p:tab视图和上载的所有选项卡,只是为了检查命令按钮在这些多个表单中是否有效,但即使没有p:tabView,同样的问题也在发生。页面中还有一些我没有看到或没有看到的错误很难说,有很多嵌套的XHTML很难理解;mediaInsertController支持bean可能有问题。我建议您将代码拆分为单独的包含文件,并以这种方式缩小问题的范围。@Zayhf您是否尝试过用相同的组合生成表单,然后发现它可以工作?我建议你不要使用像global之类的东西form@freak这是主要问题。谢谢你指出:)