My first guess would be that you are missing annotation in constructor
@Inject
so rendering engine is looking just for no-arg constructor and failing to find
it, it fails to instantiate the class. If you add the annotation, Guice should
take care of injecting params and initializing the class for renderer.
HTH,
Jan
On Aug 8, 2012, at 6:08 PM, Stano Marcinko (via Magnolia Forums) wrote:
> Hi,
>
> I'm trying to migrate our project to magnolia 4.5. As part of that I decided
> that I will rewrite/extend some of the component models to suite my needs
> (mainly use the criteria-like API for search purposes). I'm not a very good
> programmer so I browsed through the source codes of the original classes to
> make some sense. My first try looks something like this
> the file is placed in
> our/OurTeaserModel and it is enabled.
> [code]
> package our
>
> import javax.jcr.Node;
> import javax.inject.Inject;
> import info.magnolia.rendering.template.TemplateDefinition;
> import info.magnolia.templating.functions.TemplatingFunctions;
> import info.magnolia.rendering.model.RenderingModel;
> import info.magnolia.module.templatingkit.functions.STKTemplatingFunctions;
> import info.magnolia.module.templatingkit.templates.AbstractSTKTemplateModel;
>
> public class OurTeaserModel extends
> AbstractSTKTemplateModel<TemplateDefinition> {
>
>
> public OurTeaserModel(Node content, TemplateDefinition definition,
> RenderingModel< ? > parent, STKTemplatingFunctions stkFunctions,
> TemplatingFunctions templatingFunctions){
> super(content,definition, parent, stkFunctions, templatingFunctions);
> }
>
> public String getTestText(){
> return "Hello World!";
> }
> }
> [/code]
>
> I have my component configured correctly (I can reach the data in the
> definition through freemarker). But when I try to assign model.testText to a
> variable I get a series of error messages
>
> [code]Error while rendering
> [/DEV_PLAYGROUND/category_search/untitled0/content/0] with template
> [standard-templating-kit:components/our/stkOurTeaser]: RenderException:
> info.magnolia.rendering.engine.RenderException: Can't instantiate model:
> class our.OurTeaserModel
> info.magnolia.rendering.engine.RenderException:
> info.magnolia.rendering.engine.RenderException: Can't instantiate model:
> class our.OurTeaserModel[/code]
>
> I can provide the full stack trace if needed. Any Idea what I'm doing wrong?
> Ideally point me toward some documentation (my google-fu failed/found nothing
> regarding 4.5+). Thanks
>
> --
> Context is everything:
> http://forum.magnolia-cms.com/forum/thread.html?threadId=8e901b29-2014-4317-9852-9513275b980e
>
>
> ----------------------------------------------------------------
> For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
> Alternatively, use our forums: http://forum.magnolia-cms.com/
> To unsubscribe, E-mail to: <[email protected]>
> ----------------------------------------------------------------
----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------