2012-08-01 84 views
0

我正在使用jsf 2.0與primefaces。在我的應用程序中,我有登錄頁面,並且我已經包含此登錄所有頁面,並且它顯示在primefaces lightbox(內聯方法)上......它在所有瀏覽器中都可以正常工作,但歌劇除外...但在歌劇中,當我單擊登錄按鈕,它是沒有得到驗證,以及表單還沒有提交...jsf表單在opera中提交問題

我的index.xhtml

<h:body style="background:url(images/index_bg.jpg) repeat-x;"> 
     <!--Header-->  
    <ui:include src="/webheader.xhtml"></ui:include> 
    <!--End Header-->  
<!--Menu--> 
    <ui:include src="/webmenu.xhtml"></ui:include> 
    ............. 
    </h:body> 

webheader.xhtml

.............. 
<p:lightBox style="display:inline;" width="1010px"> <h:outputLink  
    value="Registration.xhtml">Register</h:outputLink> </p:lightBox>| 
    <p:lightBox style="display:inline;" width="810px" group="false"> 
    <h:outputLink value="#"> 
    <h:outputText value="Login"/> 
</h:outputLink> 
<f:facet name="inline"> 
<ui:include src="login.xhtml"></ui:include> 
</f:facet> 
</p:lightBox> 
........................... 

我login.xhtml

<!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.prime.com.tr/ui"> 
    <h:head> 
    <script type="text/javascript"> 
     function resetval() { 
      document.getElementById("loginid:log_pass_input").value = null; 

      document.getElementById("loginid:log_pass_input").focus(); 
     } 
    </script> 
    </h:head> 
     <h:body> 
    <f:view> 

     <!-- Login --> 
     <div class="login"> 
      <h:form id="ajxstaform"> 
       <p:ajaxStatus style="width:16px;height:16px;" 
    id="ajaxStatusPanel"> 
        <f:facet name="start"> 
         <h:graphicImage value="../images/ajax- 
    loader.gif" /> 


        </f:facet> 
        <f:facet name="complete"> 
         <h:outputText value="" /> 
        </f:facet> 
       </p:ajaxStatus> 
      </h:form> 

      <div class="loginInner"> 
       <table width="90%" border="0" cellspacing="0" \ 
    cellpadding="0"> 

        <tr> 
         <td><h1>Login</h1> 
         </td> 
        </tr> 
        <tr> 
         <td> 
          <div class="loginTEXT"> 
           <table width="80%" 
    border="0" align="center" cellpadding="0" 
            cellspacing="0" 
    id="loginPanel"> 
            <tr> 
      <td>&nbsp; 
    </td> 
     <td>&nbsp; 
    </td> 
            </tr> 

    <h:form id="loginid"> <tr> 
                <td width="34%" align="center"><p>Email Id</p> 
                </td> 
                <td width="66%" align="center"><h:inputText 
                value="#{loginBean.email_id}" id="log_email" 
                binding="#{login}" required="true" 
                requiredMessage="Enter the Email ID" immediate="true" 
                validatorMessage="Invalid Email ID"> 
                <p:ajax event="blur" update="msg1" /> 
                <f:validateRegex 
                 pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" /> 
               </h:inputText></td> 
              <td width="100%" align="center"><h:message 
                for="log_email" id="msg1" styleClass="alert" /> 
              </td> 
             </tr> 
             <tr> 
              <td align="center"><p>Password</p> 
              </td> 
     <td align="center"><p:password 
                value="#{emailBean.password}" id="log_pass" 
                feedback="false" required="true" 
                requiredMessage="Enter the Password" immediate="true"> 
                <p:ajax event="blur" update="msg2" /> 
                <f:validator validatorId="loginValidator" /> 
                <f:attribute name="login" value="#{login.value}" /> 
               </p:password></td> 
              <td align="center"><h:message for="log_pass" id="msg2" 
                styleClass="alert" /></td> 
     </tr> 
     <tr> 
              <td colspan="2" align="center"> 
               <div> 
     <p:commandButton value="Login" 
                 action="#{commonControl.loginCtrl}" 
                 update="ajxstaform:ajaxStatusPanel,loginid,msg1,msg2" 
                 oncomplete="resetval()"> 
                </p:commandButton> 
              </div></td> 
             </tr> 
            </h:form> 

            <tr> 
             <td colspan="2" align="center"><p:spacer height="20px" 
               width="27px"></p:spacer> <h:form> 
               <h:commandLink 
                action="#{registrationControl.forgotpasswordredirect}"> 
                <b>Forgot Password</b> 
               </h:commandLink> 
              </h:form> <!-- <a href="PasswordReset.xhtml" title="Forgot password">Forgot Password</a> --> 
             </td> 
            </tr> 
           </table> 
          </div></td> 
        </tr> 
       </table> 


      </div> 

     </div> 

    </f:view> 
    <!--End Login --> 
</h:body> 
</html> 

在此先感謝。

回答

1

你在那裏invalid HTML語法。 A <table>元素不能具有作爲直接孩子的<form>,但僅具有<thead>,<tbody><tfoot>和/或<tr>。如果HTML無效,則瀏覽器行爲未指定。雖然大多數瀏覽器對這類開發者的錯誤都是寬容和有經驗的,並且試圖自動糾正它,但Opera瀏覽器對此非常嚴格。

相應地重新排列JSF <h:form id="loginid">組件,以便您的代碼最終生成有效的HTML。您可以將<h:form>設置爲<table><td>,但當然不在其中間。你可以通過將整個表格放在一個表格中,並通過使其成爲正常的<h:link>或通過添加immediate="true"或通過添加immediate="true"的ajax動作來擺脫嵌套的<h:form>來獲得「忘記密碼」鏈接<f:ajax><p:commandLink>

+1

謝謝jsf大師.. – sathesh 2012-08-02 07:27:14