« Return to Thread: Sitemesh integration problem

Re: Sitemesh integration problem

by gregoryjoseph :: Rate this Message:

Reply to Author | View in Thread


Hi again,

Haaa this is getting frustrating, because I've been willing to  
integrate Sitemesh and Magnolia ever since I started working with the  
latter (and had to abandon previous projects using the former)

Hopefully helpful suggestions inline:

On Jun 19, 2009, at 1:41 PM, Gavin Donald wrote:

>
> Thanks for the additional ideas. I have tried them as far as I could  
> and
> could not get it to work.
>
> The use case is that the site has several web applications running  
> on it
> (Apache Roller , MVNForum, Magnolia as well as a custom core that
> provides site specific facilities). The public and admin sections of
> each of those application is SiteMesh decorated and so it would keep
> everything looking the same if the Magnolia AdminCentral was also
> decorated. The decorators also contain the shared navigation sections
> and so if a user enters AdminCentral they loose all the navigation
> elements that let them easily move between the different applications.

Makes a lot of sense.

>
> I added the following:
>
> Server/filters/bypasses
> Content-node: sitemesh-decorator
> data-node: class => info.magnploa.voting.voters.URIStartsWithVoter
> data-node: pattern: => /prosoc-view/decorator

Providing the typo was only in the email and not in your config, this  
looks correct.

> I have looked at the source in the browser and then called each of the
> JS files in turn. Non of them are decorated and all are present
> including the:
>
> /.magnolia/pages/javascript.js
>
> I mention that file specifically because when SiteMesh is active and I
> call /magnolia/trees/website.html I get an error in the JavaScript
> console saying that 'MgnlTextField' could not be found. This  
> JavaScript
> call is called from near the bottom of website.html and the function  
> is
> defined in javascript.js.

That could indicate what I was suspecting about Sitemesh rearranging  
the script tags in the <head> - see below.


> I have added:
>
> <excludes>
>    <pattern>*.js</pattern>
> </excludes>
>
> to the decorators.xml file.
>
> You mentioned:
>
> "Depending on your decorator/configuration, it might also be that
> Sitemesh tries to reorganize the script tags, for instance. If I
> remember  correctly from when I used it before, it's sort of its  
> default
> behaviour, because you'll usually want to insert stuff in the <head>
> tags. Can you disable that? Or bypass it altogether for the whole
> /.magnolia and /.resources, for instance ?"
>
> but I didn't really understand how to do that.

Well - I don't really know either, been quite a while since I used  
Sitemesh.
What I seem to remember is that you could feed it with a page that  
has, for instance, <script> and <style> tags lying around in the  
<body> tag, and Sitemesh would nicely rearrange them inside the <head>  
tag of the page.
If that happens, there might be a few bits and pieces that don't work  
anymore (typically, inline javascript within the page that would  
expect to have some methods or object available - if the order of the  
scripts is modified, things might start to get hairy)

Could you compare the results of an undecorated and  
decorated /.magnolia/trees/website.html with that in mind ?

> When I put the SiteMesh filter before the magnolia filter I  
> frequently get:
>
> MgnlContext is not set for this thread
<...>
To understand what goes wrong there, we'd need a few more lines of the  
exception - could you attach a sample to your email, or paste it on  
nopaste.org ? If your Magnolia instance runs fine on its own (without  
SM), I can't really see why this would happen with SM --- at least not  
without more details or trying out myself ...

> If you have any other ideas then I would be happy to try them but as I
> am out of things to try then I will probably leave AdminCentral
> undecorated for now. Thanks for your previous suggestions.

Is there a chance we could see your decorator.jsp; maybe it'd remind  
me a few other things I forgot about SM...

Cheers,

-g

Grégory Joseph wrote:

>>
>> Gavin,
>>
>> Something hit me: your decorator jsp itself might be going through  
>> the
>> Magnolia filters (by default, it's mapped to / and with dispatchers  
>> on
>> request, forward AND include) - maybe try adding a bypass for it in  
>> the
>> global bypasses at /server/filters/bypasses ?
>>
>> -g
>>
>> On Jun 16, 2009, at 9:55 PM, Gavin Donald wrote:
>>
>>>
>>> I had the SiteMesh filter after the Magnolia filter but if I move  
>>> it in
>>> front I get some partial success. The decorator is applied but  
>>> there is
>>> an error:
>>>
>>> java.lang.IllegalStateException: MgnlContext is not set for this  
>>> thread
>>>
>>> and the login screen loads with parts of the decorator applied but  
>>> most
>>> of it is missing. If I then login I get the following shown in  
>>> Firefox:
>>>
>>> Content Encoding Error
>>> The page you are trying to view cannot be shown because it uses an
>>> invalid or unsupported form of compression.
>>> The page you are trying to view cannot be shown because it uses an
>>> invalid or unsupported form of compression.
>>>
>>> I have not been successful in turning off compression in Magnolia  
>>> to see
>>> if that solves this second problem. I have tried to delete the gzip
>>> nodes from:
>>>
>>> Config => server => filters => gzip
>>>
>>> Config => server => filters => gzip => bypasses => contentAllowed =>
>>> allowed
>>>
>>> Config => modules => cache =>config => compression => voters
>>> =>contentType => allowed
>>>
>>> But the content still came out with gzip compression. The server  
>>> does
>>> not have compression enabled so I have no idea where it comes from.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> Grégory Joseph wrote:
>>>>
>>>> Is your sitemesh filter before or after Magnolia's? This might be  
>>>> due to
>>>> how requests that end up in the admincentral servlets treat the  
>>>> filter
>>>> chain - can you try to see if /.magnolia/trees/website.html gets
>>>> decorated, for example ? Or a simpler page such as
>>>> /.magnolia/pages/configuration.html ?
>>>>
>>>> The fact that the login form does not get decorated might be due  
>>>> to the
>>>> fact that sitemesh treats pages differently depending on the http
>>>> response code ? (i really don't know if it does, just wild  
>>>> guessing)
>>>>
>>>> -g
>>>>
>>>> On Jun 16, 2009, at 12:39 PM, Gavin Donald wrote:
>>>>
>>>>>
>>>>> Thanks for taking the time to reply.
>>>>>
>>>>> I am trying to get AdminCentral decorated with SiteMesh. Currently
>>>>> AdminCentral is not decorated at all. I took a look at the  
>>>>> source and
>>>>> see that past the login screen a single iframe is used. However,  
>>>>> the
>>>>> login screen does not seem to use frames and it still is not  
>>>>> decorated.
>>>>> I added the following to my sitemesh.xml file:
>>>>>
>>>>> <mapper
>>>>> class
>>>>> =
>>>>> "com.opensymphony.module.sitemesh.mapper.FrameSetDecoratorMapper">
>>>>>
>>>>>          <param name="decorator" value="prosoc-cms-admin" />
>>>>> </mapper>
>>>>>
>>>>> Where 'prosoc-cms-admin' is the name of the decorator in the
>>>>> decorator.xml file. My web.xml uses:
>>>>>
>>>>> <filter>
>>>>>      <filter-name>sitemesh</filter-name>
>>>>> <filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</
>>>>> filter-class>
>>>>>
>>>>>
>>>>> </filter>
>>>>>
>>>>> <filter-mapping>
>>>>>      <filter-name>sitemesh</filter-name>
>>>>>      <url-pattern>/*</url-pattern>
>>>>>      <dispatcher>REQUEST</dispatcher>
>>>>>      <dispatcher>FORWARD</dispatcher>
>>>>> </filter-mapping>
>>>>>
>>>>> I am not sure why AdminCentral does not get decorated. Any  
>>>>> suggestions
>>>>> are certainly welcome.
>>>>>
>>>>>
>>>>>
>>>>> Grégory Joseph wrote:
>>>>>>
>>>>>> Hi Gavin,
>>>>>>
>>>>>> Any specifics on what the problem(s) is/are ? What are you  
>>>>>> trying to
>>>>>> achieve specifically ? I suppose you've noticed the  
>>>>>> admincentral is
>>>>>> built with frames.. and I seem to remember Sitemesh had frame-
>>>>>> specific
>>>>>> features/configuration, did you check that ?
>>>>>>
>>>>>> -g
>>>>>>
>>>>>>
>>>>>> On Jun 14, 2009, at 4:56 PM, Gavin Donald wrote:
>>>>>>
>>>>>>>
>>>>>>> I have added magnolia onto an existing web app so that it can
>>>>>>> control a
>>>>>>> part of the site. The site contains other applications as well  
>>>>>>> (blog,
>>>>>>> forum etc) and so Sitemesh is used for decoration. I have added
>>>>>>> SiteMesh
>>>>>>> to the Magnolia instances and it works perfectly for the  
>>>>>>> 'create'
>>>>>>> pages
>>>>>>> in AdminCentral and also for the public instance. I have not  
>>>>>>> been
>>>>>>> successful in getting SiteMesh to decorate the actual  
>>>>>>> AdminCentral
>>>>>>> itself though (either public or author) and can't think of any  
>>>>>>> reason
>>>>>>> why. The SiteMesh decorator is simply:
>>>>>>>
>>>>>>> <decorator name="prosoc-cms" page="decorator-prosoc-cms.jsp">
>>>>>>> <pattern>/*</pattern>
>>>>>>> </decorator>
>>>>>>>
>>>>>>> Does anyone have any suggestions or has can say they have
>>>>>>> successfully
>>>>>>> managed to decorate AdminCentral?
>>>>>>>
>>>>>>>
>>>>>>> ----------------------------------------------------------------
>>>>>>> For list details see
>>>>>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>>>>>> To unsubscribe, E-mail to: <user-list-unsubscribe@...
>>>>>>> >
>>>>>>> ----------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>> ----------------------------------------------------------------
>>>>>> For list details see
>>>>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>>>>> To unsubscribe, E-mail to: <user-list-unsubscribe@...
>>>>>> >
>>>>>> ----------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ----------------------------------------------------------------
>>>>> For list details see
>>>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>>>> To unsubscribe, E-mail to: <user-list-unsubscribe@magnolia-
>>>>> cms.com>
>>>>> ----------------------------------------------------------------
>>>>
>>>>
>>>> ----------------------------------------------------------------
>>>> For list details see
>>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>>> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
>>>> ----------------------------------------------------------------
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> ----------------------------------------------------------------
>>> For list details see
>>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>>> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
>>> ----------------------------------------------------------------
>>
>>
>> ----------------------------------------------------------------
>> For list details see
>> http://www.magnolia-cms.com/home/community/mailing-lists.html
>> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
>> ----------------------------------------------------------------
>>
>>
>>
>
>
>
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <user-list-unsubscribe@...>
> ----------------------------------------------------------------


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <user-list-unsubscribe@...>
----------------------------------------------------------------

 « Return to Thread: Sitemesh integration problem