You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marcus Schmidke <ma...@prosystemsit.de> on 2007/10/12 12:32:53 UTC

Problems Tomahawk / Extensionsfilter / Facelets / XHTML / CDATA / JSCookMenu

Hello all,

I'm using Tomahawk 1.1.5 in a JBoss Seam / Facelets / RI environment, and I am having problems displaying JSCookMenu. In IE it is deployed, in
Firefox, it isn't, so I suspect it's some xhtml issue.

I've had a look at the generated source and found one single line of JavaScript which is not embedded in CDATA:

<script type="text/javascript"><!--
var
myThemeOfficeBase='http://localhost:8080/Argos3Web/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11920263/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemeOffice/';
//--></script>

Might be it's the reason. All else JavaScript is within an autogenerated CDATA block.

I've tried to figure out the reason (why are there some CDATAs, but not all?), but I'm far too new to this all to understand it completely. I've
debugged a bit around in DefaultAddResource, HtmlResponseWriterImpl and so on. I saw that there are different ResponseWriters in use, some of them
know about xhtml, others don't, but if I force the latter to xhtml by patching DefaultAddResource, I get a NullPointerException in
isAllowedCdataSection().

Can anybody help me? Will I have to replace RI by Myfaces? Will that help? But Seam recommends using RI, and for legacy reasons I am forced to use
Tomahawk.

Please help!!

Marcus.
_____________________________________________________________________
prosystems IT GmbH
Anwendungsentwicklung
Postfach 31 51
53021 Bonn (Germany)

Tel: 0228 / 3366 - 3329, Fax: 0228 / 3366 - 73329
mailto:Marcus.Schmidke@prosystemsIT.de http://www.prosystemsIT.de
Amtsgericht Bonn - HR B 13189
Geschaeftsfuehrer: Vassilios Timiliotis, Richard Adams


Der Austausch von Nachrichten mit der prosystems IT GmbH via E-Mail dient ausschliesslich Informationszwecken. Rechtsgeschaeftliche Erklaerungen
duerfen ueber dieses Medium nicht ausgetauscht werden. Verfaelschungen des urspruenglichen Inhaltes dieser Nachricht bei der Datenuebertragung koennen
nicht ausgeschlossen werden.



Re: Antwort: Re: Problems Tomahawk / Extensionsfilter / Facelets / XHTML / CDATA / JSCookMenu

Posted by Brett Birschbach <br...@nsighttel.com>.
First off, I would like to say THANK YOU THANK YOU THANK YOU Marcus.

Your tips were invaluable in helping me get jscookmenu working with tomahawk
1.1.6.  I don't think I would have been able to figure it out without your
help.

I followed steps 1 and 2 verbatim.

However, I found an alternative solution that covers steps 3 and 4, and is
potentially future proof against tomahawk 1.1.7 where the check for fc==null
returns false.

See the following code in:
org.apache.myfaces.custom.navmenu.jscookmenu.HtmlJSCookMenuRenderer
==========================================================================
        if ((imageLocation != null) || (themeLocation != null)) {
            // Generate a javascript variable containing a reference to the
            // directory containing theme image files, for use by the theme
            // javascript file. If neither of these is defined (ie a custom
            // theme was specified but no imageLocation) then presumably the
            // theme.js file uses some other mechanism to determine where
            // its image files are.
            StringBuffer buf = new StringBuffer();
            buf.append("var my");
            buf.append(themeName);
            buf.append("Base='");
            ExternalContext externalContext = context.getExternalContext();
            if (imageLocation != null) {
               
buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
                                                                                       
imageLocation + "/" + themeName)));
            }
            else {
               
buf.append(externalContext.encodeResourceURL(addResource.getResourceUri(context,
                                                                                       
HtmlJSCookMenuRenderer.class, themeLocation)));
            }
            buf.append("';");
            
            // XXX THIS IS A HACK TO MAKE JSCOOKMENU WORK  
            buf.insert(0, "//-->\n//<![CDATA[\n");
            buf.append("\n//]]>\n<!--\n");
            // END HACK
            
            addResource.addInlineScriptAtPosition(context,
AddResource.HEADER_BEGIN, buf.toString());
        }
=========================================================================

The two line hack results in HTML that looks like the following:

<script type="text/javascript"><!--
//-->
//<![CDATA[
var
myThemeOfficeBase='/Portal/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/12127889/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemeOffice/';
//]]>
<!--

//--></script>

Firefox 2.0.0.14, IE 6.0.2900.2180..., and Opera 9.27 all appear to be able
to read the myThemeOfficeBase variable.

Good luck to the next sorry soul that hits this issue!

-Brett Birschbach



Marcus Schmidke wrote:
> 
> Hello Dirk,
> 
> I did not really solve the problem, but I figured out the causes and
> constructed some workarounds.
> 
> Part of the problems are solved with current Tomahawk 1.1.7 Snapshot, but
> only part, so I turned back to 1.1.6 and applied the following patches.
> 
> All patches affect files in the tomahawk-1.1.6.jar. If you put
> tomahawk-1.1.6.jar in the WEB-INF/lib folder, it is simply sufficient to
> put the
> patched files in the WEB-INF/classes folder which will take precedence. So
> you don't have to patch the jarfile itself, if you don't want to.
> 
> ...
> 
> Good luck!
> 
> Marcus.                                                                                                                                                          
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-Tomahawk---Extensionsfilter---Facelets---XHTML---CDATA---JSCookMenu-tp13172753p17702222.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Antwort: Re: Problems Tomahawk / Extensionsfilter / Facelets / XHTML / CDATA / JSCookMenu

Posted by Marcus Schmidke <ma...@prosystemsit.de>.
Hello Dirk,

I did not really solve the problem, but I figured out the causes and constructed some workarounds.

Part of the problems are solved with current Tomahawk 1.1.7 Snapshot, but only part, so I turned back to 1.1.6 and applied the following patches.

All patches affect files in the tomahawk-1.1.6.jar. If you put tomahawk-1.1.6.jar in the WEB-INF/lib folder, it is simply sufficient to put the
patched files in the WEB-INF/classes folder which will take precedence. So you don't have to patch the jarfile itself, if you don't want to.

1. The JSCookMenu version delivered with Tomahawk 1.1.6 is very old and isn't XHTML ready. This is corrected in 1.1.7, but for 1.1.6, you have to
manually download JSCookMenu.js v.1.4.4 (google for JSCookMenu) and put it in place. This is not the newest JSCookMenu version, but it is compatible
with Tomahawk 1.1.6. The right place is org/apache/myfaces/custom/navmenu/jscookmenu/resource/JSCookMenu.js.

2. theme.js of the JSCookMenu theme we are using (ThemeOffice) had to be patched. Copy file
org/apache/myfaces/custom/navmenu/jscookmenu/resource/ThemeOffice/theme.js from the Tomahawk sources, search for "<img" and change the '">' at end of
line to '"/>' (4 times).

3. DefaultAddResource has to be patched. Copy file org/apache/myfaces/renderkit/html/util/DefaultAddResource.java. Search for method
"writeWithFullHeader" containing lines:
        ResponseWriter writer = new HtmlResponseWriterImpl(response.getWriter(),
                HtmlRendererUtils.selectContentType(request.getHeader("accept")),
                response.getCharacterEncoding());
Change these lines to:
        String contenttype = "application/xhtml+xml";
        ResponseWriter writer = new HtmlResponseWriterImpl(
      response.getWriter(), contenttype, response.getCharacterEncoding());

Note: this is only a hack, but it works for me.

4. Finally, HtmlRendererUtils has to be patched. Copy file org/apache/myfaces/shared_tomahawk/renderkit/html/HtmlRendererUtils.java. Search for method
"isAllowedCdataSection". In 1.1.6, this method looks like:
      public static boolean isAllowedCdataSection(FacesContext fc) {
            Boolean value = (Boolean) fc.getExternalContext().getRequestMap().get(ALLOW_CDATA_SECTION_ON);
            return value != null && ((Boolean) value).booleanValue();
      }

 Add as first line in method:
      if (fc==null) return true;

In 1.1.7, this method is changed such that it returns false in case of fc==null, but then the DefaultAddResource hack wouldn't work any longer. For
me, my patch works fine, but you see that somebody who understands some more of this should have a look at it to make it really correct.

So far for the patches. With all this, the menu gets displayed. If you furthermore want to have it working (ie that clicking menu items results in
actions) :-), you have to manually add a hidden input field to your xhtml pages:

      <input type="hidden" name="jscook_action" />

Just put it immediately before the closing </h:form> tag.

Good luck!

Marcus.




                                                                                                                                                                
                      neander                                                                                                                                   
                      <dirk_neander@hot        An:       users@myfaces.apache.org                                                                               
                      mail.com>                Kopie:                                                                                                           
                                               Thema:    Re: Problems Tomahawk / Extensionsfilter / Facelets / XHTML / CDATA / JSCookMenu                       
                      17.10.2007 14:09                                                                                                                          
                      Bitte antworten                                                                                                                           
                      an "MyFaces                                                                                                                               
                      Discussion"                                                                                                                               
                                                                                                                                                                





Hi Marcus,

I'm facing the same problem you do. At first everything worked fine with my
webapplication.
My problem occured after I enhanced my webapplication with facelets.
The IE browser ignores the problem, but doesn't seem to accept
the css-definition of the styleLocation-Attribut and displays the navigation
menu in default-look.
For me it looks like the Extension-Filter of Tomahawk is not able to resolve
the correct path
of the given css-Definition anymore.
I believe if the css is correctly loaded there won't be a problem anymore
...
Please let me know if you solved the problem.

Regards

Dirk


Marcus Schmidke wrote:
>
>
> Hello all,
>
> I'm using Tomahawk 1.1.5 in a JBoss Seam / Facelets / RI environment, and
> I am having problems displaying JSCookMenu. In IE it is deployed, in
> Firefox, it isn't, so I suspect it's some xhtml issue.
>
> I've had a look at the generated source and found one single line of
> JavaScript which is not embedded in CDATA:
>
> <script type="text/javascript"><!--
> var
>
myThemeOfficeBase='http://localhost:8080/Argos3Web/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11920263/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemeOffice/';

> //--></script>
>
> Might be it's the reason. All else JavaScript is within an autogenerated
> CDATA block.
>
> I've tried to figure out the reason (why are there some CDATAs, but not
> all?), but I'm far too new to this all to understand it completely. I've
> debugged a bit around in DefaultAddResource, HtmlResponseWriterImpl and so
> on. I saw that there are different ResponseWriters in use, some of them
> know about xhtml, others don't, but if I force the latter to xhtml by
> patching DefaultAddResource, I get a NullPointerException in
> isAllowedCdataSection().
>
> Can anybody help me? Will I have to replace RI by Myfaces? Will that help?
> But Seam recommends using RI, and for legacy reasons I am forced to use
> Tomahawk.
>
> Please help!!
>
> Marcus.
> _____________________________________________________________________
> prosystems IT GmbH
> Anwendungsentwicklung
> Postfach 31 51
> 53021 Bonn (Germany)
>
> Tel: 0228 / 3366 - 3329, Fax: 0228 / 3366 - 73329
> mailto:Marcus.Schmidke@prosystemsIT.de http://www.prosystemsIT.de
> Amtsgericht Bonn - HR B 13189
> Geschaeftsfuehrer: Vassilios Timiliotis, Richard Adams
>
>
> Der Austausch von Nachrichten mit der prosystems IT GmbH via E-Mail dient
> ausschliesslich Informationszwecken. Rechtsgeschaeftliche Erklaerungen
> duerfen ueber dieses Medium nicht ausgetauscht werden. Verfaelschungen des
> urspruenglichen Inhaltes dieser Nachricht bei der Datenuebertragung
> koennen
> nicht ausgeschlossen werden.
>
>
>
>

--
View this message in context:
http://www.nabble.com/Problems-Tomahawk---Extensionsfilter---Facelets---XHTML---CDATA---JSCookMenu-tf4612626.html#a13252273
Sent from the MyFaces - Users mailing list archive at Nabble.com.




_____________________________________________________________________
prosystems IT GmbH
Anwendungsentwicklung
Postfach 31 51
53021 Bonn (Germany)

Tel: 0228 / 3366 - 3329, Fax: 0228 / 3366 - 73329
mailto:Marcus.Schmidke@prosystemsIT.de http://www.prosystemsIT.de
Amtsgericht Bonn - HR B 13189
Geschaeftsfuehrer: Vassilios Timiliotis, Richard Adams


Der Austausch von Nachrichten mit der prosystems IT GmbH via E-Mail dient ausschliesslich Informationszwecken. Rechtsgeschaeftliche Erklaerungen
duerfen ueber dieses Medium nicht ausgetauscht werden. Verfaelschungen des urspruenglichen Inhaltes dieser Nachricht bei der Datenuebertragung koennen
nicht ausgeschlossen werden.



Re: Problems Tomahawk / Extensionsfilter / Facelets / XHTML / CDATA / JSCookMenu

Posted by neander <di...@hotmail.com>.
Hi Marcus,

I'm facing the same problem you do. At first everything worked fine with my
webapplication. 
My problem occured after I enhanced my webapplication with facelets. 
The IE browser ignores the problem, but doesn't seem to accept
the css-definition of the styleLocation-Attribut and displays the navigation
menu in default-look.
For me it looks like the Extension-Filter of Tomahawk is not able to resolve
the correct path 
of the given css-Definition anymore.
I believe if the css is correctly loaded there won't be a problem anymore
...
Please let me know if you solved the problem.

Regards

Dirk


Marcus Schmidke wrote:
> 
> 
> Hello all,
> 
> I'm using Tomahawk 1.1.5 in a JBoss Seam / Facelets / RI environment, and
> I am having problems displaying JSCookMenu. In IE it is deployed, in
> Firefox, it isn't, so I suspect it's some xhtml issue.
> 
> I've had a look at the generated source and found one single line of
> JavaScript which is not embedded in CDATA:
> 
> <script type="text/javascript"><!--
> var
> myThemeOfficeBase='http://localhost:8080/Argos3Web/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11920263/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemeOffice/';
> //--></script>
> 
> Might be it's the reason. All else JavaScript is within an autogenerated
> CDATA block.
> 
> I've tried to figure out the reason (why are there some CDATAs, but not
> all?), but I'm far too new to this all to understand it completely. I've
> debugged a bit around in DefaultAddResource, HtmlResponseWriterImpl and so
> on. I saw that there are different ResponseWriters in use, some of them
> know about xhtml, others don't, but if I force the latter to xhtml by
> patching DefaultAddResource, I get a NullPointerException in
> isAllowedCdataSection().
> 
> Can anybody help me? Will I have to replace RI by Myfaces? Will that help?
> But Seam recommends using RI, and for legacy reasons I am forced to use
> Tomahawk.
> 
> Please help!!
> 
> Marcus.
> _____________________________________________________________________
> prosystems IT GmbH
> Anwendungsentwicklung
> Postfach 31 51
> 53021 Bonn (Germany)
> 
> Tel: 0228 / 3366 - 3329, Fax: 0228 / 3366 - 73329
> mailto:Marcus.Schmidke@prosystemsIT.de http://www.prosystemsIT.de
> Amtsgericht Bonn - HR B 13189
> Geschaeftsfuehrer: Vassilios Timiliotis, Richard Adams
> 
> 
> Der Austausch von Nachrichten mit der prosystems IT GmbH via E-Mail dient
> ausschliesslich Informationszwecken. Rechtsgeschaeftliche Erklaerungen
> duerfen ueber dieses Medium nicht ausgetauscht werden. Verfaelschungen des
> urspruenglichen Inhaltes dieser Nachricht bei der Datenuebertragung
> koennen
> nicht ausgeschlossen werden.
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Problems-Tomahawk---Extensionsfilter---Facelets---XHTML---CDATA---JSCookMenu-tf4612626.html#a13252273
Sent from the MyFaces - Users mailing list archive at Nabble.com.