Thanks Stein,

I have created a ticket for this:
http://jira.magnolia-cms.com/browse/MAGNOLIA-3304

// Tobias

On Sep 22, 2010, at 3:38 PM, Stein Kvarud wrote:

> 
> Hi.
> 
> I discovered some sideeffects with the way magnolia does paragraph
> loading that to me seems like a bug.
> When including a paragraph the model reference are set to the model of
> the paragraph. Next when the rendering of the paragraph is done I
> expected the model reference to be set back to the template rendering
> model, but the reference stays at the model class of the final
> paragraph.
> This can cause some strange sideeffects because the reference to the
> model in the template are influenced by the paragraphs added to the
> page.
> 
> 
> I have created a small sample to illustrate the problem.
> 
> Creating two custom RenderingModels for a template and a paragraph
> 
> public class MyTemplateRenderingModel extends
> RenderingModelImpl<RenderableDefinition> {
> 
>    public MyTemplateRenderingModel(Content content,
> RenderableDefinition definition, RenderingModel<?> parent) {
>        super(content, definition, parent);
>    }
> 
>    public String getClassName(){
>        return this.getClass().getName();
>    }
> 
> }
> 
> public class MyParagraphRenderingModel extends
> RenderingModelImpl<RenderableDefinition> {
> 
>    public MyParagraphRenderingModel(Content content,
> RenderableDefinition definition, RenderingModel<?> parent) {
>        super(content, definition, parent);
>    }
> 
>    public String getClassName(){
>        return this.getClass().getName();
>    }
> 
> }
> 
> Then adding two smal jsp files
> 
> The template:
> 
> Model value before loading paragraphs = ${model.className}
> 
> <cms:contentNodeIterator contentNodeCollectionName="testCollection">
>       <cms:includeTemplate />
> </cms:contentNodeIterator>
> <cms:newBar contentNodeCollectionName="testCollection"
> paragraph="testParagraph" newLabel="New test paragraph" />
> 
> Model value after loading paragraphs = ${model.className}
> 
> The paragraph:
> 
> <p>
> Model class name inside paragraph = ${model.className}
> </p>
> 
> Then I add a modelClass for the paragraph and the template in the
> magnoli configuration.
> 
> Before adding any paragraphs to the template it displays
> 
> Model value before loading paragraphs = MyTemplateRenderingModel
> Model value after loading paragraphs = MyTemplateRenderingModel
> 
> I then add one (or more) paragraphs
> Model value before loading paragraphs = MyTemplateRenderingModel
> Model class name inside paragraph = MyParagraphRenderingModel
> Model value after loading paragraphs = MyParagraphRenderingModel
> 
> As the example illustrates the final output from model.className
> refers to the paragraph and not the template.
> 
> Do I need to add some tag to the jsp to avoid this sideeffect or is this a 
> bug?
> 
> Regards
> Stein
> 
> 
> -- 
> Stein Kvarud
> Solutions Engineer | +47 916 25 656
> Iterate AS | www.iterate.no
> The Lean Software Development Consultancy
> 
> 
> ----------------------------------------------------------------
> For list details see
> http://www.magnolia-cms.com/home/community/mailing-lists.html
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------



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

Reply via email to