2

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!

the dude
  • 799
  • 9
  • 26

1 Answers1

4

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:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • So you mean, in theory i could drop all my forms that live within components and just surround the component-includes with a form? Quite some work, butt i'll try that, thanks! – the dude Feb 29 '12 at 15:15
  • 1
    Whatever you do, you need to make sure that you end up with only **one** parent form in the hierarchy. You can use a "God" form around all include templates, but you can also just group the related inputs and buttons together in its own form in a single template. You can have multiple parallel forms, but not multiple nested forms. See also http://stackoverflow.com/questions/7371903/multiple-hform-in-a-jsf-page – BalusC Feb 29 '12 at 15:21
  • Thanks BalusC, i quickly changed my working sources and checked it in IE8, that works! Anyway, this is one of the points that make me wonder about JSF. It is a kinda heavy (over?) specified component framework that makes you want to handle it like one, on the other hand hinders you by its (conflicting) specification constraints. I think the next logical step would be to have a compiler that validates and optimizes the output (e.g. automatically reducing nested form, etc.). Thanks, i always learn something here! – the dude Feb 29 '12 at 16:15