JSF2.0 + Primefaces 3.0.1 + jquery 1.6.4 + p:commandLink + IE8 throws Unexpected call to method or property

懵懂的女人 提交于 2020-01-04 09:30:12

问题


Team,

i am running the described setup on a maven based jetty (8.0.1) and get some strange exceptions in IE8 (only!).

The Error that IE is given me, looks like:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
Timestamp: Wed, 29 Feb 2012 14:09:38 UTC

Message: Unexpected call to method or property access.
Line: 23
Char: 22640
Code: 0
URI: http://127.0.0.1:8080/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=3.0.1

The described piece of code in 'javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces&v=3.0.1' on line 23, char 22640 is the '{' after the 'finally':

resolveWith:function(bw,bv){
   if(!bs&&!bu&&!br){
      bv=bv||[];
      br=1;
      try{
         while(bt[0]){
            bt.shift().apply(bw,bv)
         }
      }finally{
         bu=[bw,bv];
         br=0
      }
   }
   return this
}

Here the JSF XHTML to reproduce this error:

<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:c="http://java.sun.com/jstl/core"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
   <h:head>
   </h:head>
   <h:body>
      <h:form>
         <h:form>
            <p:dialog id="testDialog" header="Test Dialog" modal="true"
               widgetVar="testDialog" dynamic="true" resizable="true"
               maximizable="true" showEffect="fade" hideEffect="explode">
               <h:outputText value="Dialog!" />
            </p:dialog>
            <p:commandLink styleClass="button" oncomplete="testDialog.show()">
               <h:outputText value="Click me!" />
            </p:commandLink>
         </h:form>
      </h:form>
   </h:body>
</f:view>
</html>

The following JSF XHTML is not throwing the error:

<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:c="http://java.sun.com/jstl/core"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:p="http://primefaces.org/ui">
<f:view contentType="text/html">
   <h:head>
   </h:head>
   <h:body>
      <h:form>
         <p:dialog id="testDialog" header="Test Dialog" modal="true"
            widgetVar="testDialog" dynamic="true" resizable="true"
            maximizable="true" showEffect="fade" hideEffect="explode">
            <h:outputText value="Dialog!" />
         </p:dialog>
         <p:commandLink styleClass="button" oncomplete="testDialog.show()">
            <h:outputText value="Click me!" />
         </p:commandLink>
      </h:form>
   </h:body>
</f:view>
</html>

The difference is the nested form in the first example. This is heavily idealized example but reflects the same behavior if i nest components and dialogs. Whenever a form is nested, the above error occurs in IE8. FF and others just open the Dialog as expected.

If would avoid to nest forms but this is impossible because mojarra would not allow me to put, e.g. a commandLink that is contained in a component without sorrounding it by a form.

CommandButton is behaving the same way. I've read several other approaches and bugs related to the error message of the IE but did'nt found any solution or useful hint.

The following would be interesting to me:

a) Are you able to reproduce this given behavior? b) Do you have any ideas how to work around or solve this (maybe updating jquery in some way)?

Fist i attempted to validate my HTML5, but even with non-HTML5 and very reduced html it occurs.

Thanks for any help, hint or maybe link to any information in advance!

Regards,

the Dude

PS: Please if you think you know something, push me to put some more details or required resources, i would be lucky to also help others here!


回答1:


Nesting forms is illegal in HTML. The browser behaviour is unspecified. From JSF perspective, you should thus never nest <h:form> components.

As to the reason why you needed to nest the forms,

If would avoid to nest forms but this is impossible because mojarra would not allow me to put, e.g. a commandLink that is contained in a component without sorrounding it by a form.

This is not true. Perhaps you're taking the following well known warning too serious.

WARNING: The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>

This is "just" a warning, not an error. If your page works fine, then you can just ignore the warning. This warning will only show when you've set the project stage to Development. It will not show when you set it to Production.

On early Mojarra versions there was however a bug which makes this warning to also occur when you've put for example the command link in some child/include template file, while the form is placed in the master template (which is thus inside a physically different file). Upgrading the Mojarra version should fix this incorrect and confusing warning.

See also:

  • The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>
  • How to use <h:form> in JSF page? Single form? Multiple forms? Nested forms?


来源:https://stackoverflow.com/questions/9501448/jsf2-0-primefaces-3-0-1-jquery-1-6-4-pcommandlink-ie8-throws-unexpected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!