Expand my Community achievements bar.

Using JSPX causes Sidekick to not launch

Avatar

Former Community Member

I am experimenting with using a JSP document style (JSPX) within my components.

They work perfectly well however, when I use a JSPX rather than a regular JSP component sidekick doesn't launch. I can easily toggle between getting Sidekick and not just by changing the script that is included (back to a JSP).

Anyone got an idea why this is a how I can fix it ?

A trivial example :-

This simple JSPX (goodbyeWorld.jspx) put the text 'Goodbye Aviva AEM User 2!' on the page and works fine :-

<jsp:root xmlns="http://www.w3.org/1999/xhtml" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:aviva-aem="http://com.aviva.aem.archetypetest99/apps/archetypetest99" version="2.1"> <jsp:directive.include file="/apps/archetypetest99/components/global.jspx"/> <p>A simple component using JSPX</p> <h1><aviva-aem:goodbyeWorld name="Aviva AEM User 2"/></h1> </jsp:root>

I include the script in the main page like this :-

<%-- Application Page component. --%> <%@include file="/libs/foundation/global.jsp" %> <%@page session="false" %> <!DOCTYPE html> <html lang="en-GB" xmlns="http://www.w3.org/1999/xhtml">     <head>      <!-- Initialize WCM so that Sidekick will appear -->      <cq:include script="/libs/wcm/core/components/init/init.jsp"/>    ...     </head>     <body class="t7">         ... <div class="wrapper"> ... <div><cq:include script="goodbyeWorld.jspx"/></div> </div>         ...     </body> </html>

Kind regards

Fraser.

7 Replies

Avatar

Employee

I would guess there's something else going on. JSPX works fine.

What is the difference in the HTML output? Is there any error in the log.

Avatar

Level 10

Just discussed this thread at a meeting. We will be working on a supported AEM Framework document to highlight what is supported and what is not supported. I could not find an AEM topic that states that JSPX works. 

Avatar

Former Community Member

justin_at_adobe wrote...

I would guess there's something else going on. JSPX works fine.

What is the difference in the HTML output? Is there any error in the log.

 


The HTML output looks exactly as I expect in to. There are no errors in the log and, since I included some log events in the OSGI service and taglib classes so I can check what they are up to, I can see that the methods were called correctly and returned without any exceptions :-

2014-01-08 18:06:25.341 INFO [com.aviva.aem.archetypetest99.taglib.GoodbyeWorldTag] ENTERING setName 2014-01-08 18:06:25.341 INFO [com.aviva.aem.archetypetest99.taglib.GoodbyeWorldTag] ENTERING doTag 2014-01-08 18:06:25.341 INFO [com.aviva.aem.archetypetest99.services.GoodbyeWorldService] ENTERING getMessage 2014-01-08 18:06:25.341 INFO [com.aviva.aem.archetypetest99.services.GoodbyeWorldService] getMessage() will return an augmented version of (name) argument : Aviva AEM User 2

So I agree, the JSPX *is* working but it is having some form of side-effect to SidKicks behaviour ??

Something else I can tell you, if you use your JSPX as non-Page components (i.e. if the sling:resourceSuperType is NOT foundation/components/page) they both work correctly and DONT effect SideKick.

I started to look at how I could refactor my page to be a complete JSP document in its own right, but that really looks like a *massively* intrusive and pretty difficult change i.e. replacing all of the standard JSP syntax with JSPX equivalents, wrapping the HTML markup in CDATA and so on as suggested in this document : http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPX3.html with some more details here http://docs.oracle.com/cd/B14099_19/web.1012/b14014/jspxml.htm#i1007246

Syntax Elements    Standard Syntax     XML Syntax ===============    ===============     ========== Comments            <%--.. --%>         <!-- .. --> Declarations        <%! ..%>            <jsp:declaration> .. </jsp:declaration> Directives          <%@ include .. %>   <jsp:directive.include .. /> Directives          <%@ page .. %>      <jsp:directive.page .. /> Directives          <%@ taglib .. %>    xmlns:prefix="tag library URL" Expressions         <%= ..%>            <jsp:expression> .. </jsp:expression> Scriptlets          <% ..%>             <jsp:scriptlet> .. </jsp:scriptlet> 

I guess that would also need to include imported scripts (like global.jsp) as well ... that really doesn't sound like the right approach. Obviously I was hoping just to 'include' my JSPX scripts in the same way as any others and, they do work, but its no good if the kibosh Sidekick ;-)

I really want to use this approach, so hopefully we'll get to the bottom of it.

Cheers

Fraser.

Avatar

Former Community Member

smacdonald2008 wrote...

Just discussed this thread at a meeting. We will be working on a supported AEM Framework document to highlight what is supported and what is not supported. I could not find an AEM topic that states that JSPX works. 

 


That's great. We are in the process of documenting some of our best practice so hopefully this will be a timely addition to what is/isn't possible with JSPX.

Look forward to reading it, and if you uncover anything in the research to complete the doc along the way, please do share it here.

Thanks

Fraser.

Avatar

Employee

If the HTML was the same, the Sidekick would be appearing smiley

Here's the test I did:

* Start fresh 5.6.1 instance

* Open CRXDE Lite and go to /apps/geometrixx/components/homepage/

* Create test.jspx with:

<jsp:root xmlns="http://www.w3.org/1999/xhtml" xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"> <p>A simple component using JSPX</p> </jsp:root>

* Add this line to content.jsp:

<cq:include script="test.jspx"/>

Load http://localhost:4502/content/geometrixx/en.html

You'll see the test text written to the page (and the sidekick).

Avatar

Former Community Member

justin_at_adobe wrote...

If the HTML was the same, the Sidekick would be appearing smiley

Here's the test I did:

* Start fresh 5.6.1 instance

* Open CRXDE Lite and go to /apps/geometrixx/components/homepage/

* Create test.jspx with:

  1. <jsp:root xmlns="http://www.w3.org/1999/xhtml"
  2. xmlns:jsp="http://java.sun.com/JSP/Page"
  3. version="2.1">
  4.  
  5. <p>A simple component using JSPX</p>
  6. </jsp:root>

* Add this line to content.jsp:

 
  1. <cq:include script="test.jspx"/>

Load http://localhost:4502/content/geometrixx/en.html

You'll see the test text written to the page (and the sidekick).

 

Ok fair enough :-)

I guess it's to do with the surrounding HMTL markup. I assume that has to be well formed (xhtml) since jspx is essentially an xml vocabulary. One of the requirements of XML+namespace is that all prefixes must be bound correctly. So even when you are using cq:include the 'cq' prefix must be resolvable to a namespace URI, which of course it is, inside global.jsp. But now we have another potential ssue, because those declarations have a different format in JSPX (<jsp:declaration>).

Anyway, I guess what I am trying to do is mix together different styles, ... HTML markup (not encased in <jsp:text> tags and CDATA sections, standard EL/JSTL expressions, AEM vocabulary (cq:include) and JSPX notation. Perhaps thats the real problem, I dunno, maybe Mr MacDonald will shed some further light on it.

I'll try some more experiments again tommorrow (from your starting point) and see how that goes.

Watch this space

Cheers

Fraser.

Avatar

Former Community Member

Reporting back. As expected Justin's advice was solid. Both the example he sited and my own do work successfully with JSPX and it is possible to get Sidekick to appear. I can create circumstances when sidekick won't appear that I can't explain but as I'm pretty new to AEM it's probably more to do with me than the product itself.  For example, in my simple component which mostly contain HTML markup, if I just included the JSPX script, no sidekick. Adding parsys AFTER the JSPX cq:include launched sidekick, but if I change the order it doesn't. In another example the rendered page was XML rather than [x]HTML unless I added the XHTML namespace declaration to the root HTML element.

For the moment I'm happy that JSP document format works, but I remain interested in whether Adobe will publish any advice or best practice article and/or identify cases where it isn't supported or the behaviour changes or where a specific arrangement of components is required.

Regards

Fraser.