[MAGNOLIA-2182] Unable to get Magnolia context Created: 12/Jun/08  Updated: 12/Jun/08  Resolved: 12/Jun/08

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 3.5.8
Fix Version/s: None

Type: Bug Priority: Major
Reporter: aji Assignee: Magnolia International
Resolution: Not an issue Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

Hi All,

Currently we are working on magnolia integration with spring based web application.We are trying to render templates developed using magnolia in our application. Both magnolia and our application are running on the same tomcat server. The issue we are facing is getting MgnlContext from our application. Is there any document which explains clearly about basic integration steps?

I am using below code for getting the context. Please help me with this.

if (MgnlContext.getInstance() == null)

{ MgnlContext.setInstance(new WebContextImpl()); }


Content pageContent = MgnlContext.getActivePage();
Collection children = pageContent.getChildren();
Iterator it = children.iterator();
while(it.hasNext())

{ Content child = (Content) it.next(); %> <hr/> Handle: <%=child.getHandle()%> <br/> Name: <%=child.getName()%> <br/> Template: <%=child.getTemplate()%> <br/> UUDI: <%=child.getUUID()%> <br/> Title: <%=child.getTitle()%> <br/> Level: <%=child.getLevel()%> <br/> <%}

%>
Above code is from http://wiki.magnolia.info/display/WIKI/Access+content+through+the+API

Thanks,
Ajit



 Comments   
Comment by Magnolia International [ 12/Jun/08 ]

Please use either the mailing lists or the support channel if appropriate.
In the meantime, you might want to check the sources and realize that the threadlocal context (MgnlContext) is initialized by ContextFilter, and that the aggregationState is further filled in by subsequent filters, not by magic.

Generated at Mon Feb 12 03:34:13 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.