0

我正在使用带有 primefaces 的 jsf 2.0。在我的应用程序中,我有登录页面,并且我已包含此登录所有页面,并显示在 primefaces 灯箱上(内联方法)...它在除歌剧之外的所有浏览器中都可以正常工作...但是在歌剧中,当我单击登录按钮它没有得到验证以及表单也没有提交......

我的 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>

提前致谢。

4

1 回答 1

1

你有无效的HTML 语法。一个<table>元素不能有一个<form>直接子元素,而只能有<thead>, <tbody>,<tfoot>和/或<tr>。如果 HTML 无效,则未指定浏览器行为。虽然大多数浏览器对这种开发人员的错误是宽容和宽容的,并试图自动纠正它,但众所周知,Opera 浏览器对此非常严格。

相应地重新排列 JSF<h:form id="loginid">组件,以便您的代码最终生成有效的 HTML。您可以将 放在<h:form>周围<table>或 之内<td>,但肯定不能放在它们之间。<h:form>您可以通过将整个表放在一个表单中来实现这一点,并通过使其成为正常的“忘记密码”链接摆脱嵌套<h:link>,或者通过添加来实现非验证操作,或者通过orimmediate="true"来实现 ajax 操作。<f:ajax><p:commandLink>

于 2012-08-01T16:14:44.627 回答