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

时间:2013-02-11 07:59:15

标签: jsf-2 primefaces commandbutton

我在p:tabView中遇到问题,动态=“真”,我被困了几天。 我有三个选项卡,每个选项卡都有单独的表单和p:fileUpload with命令按钮,用于提交表单和上传文件。 问题是我的第一个表单或选项卡工作正常,但其他两个不工作或完全触发命令按钮操作,而是刷新页面。只有在第二次填写表格并按下按钮时才会调用它们。 并且为了添加一个更多的东西,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>  

1 个答案:

答案 0 :(得分:0)

您的commandButton id="DocUploadbtn"位于h:表单之外,可能会影响某些事情。在同一区域似乎还有三个关闭h:panelGrid标签;它可能是格式错误的XHTML吗?