In your project you can mix STK and Blossom, on the same page you can have some
components implemented using STK and some using Blossom.
Extending an STK template using Blossom is not easily done because they use
different programming models. The RenderingModel implementation used by STK
cannot be used as a Spring MVC controller. So you can't simply extend it and
add functionality written in Spring MVC style.
It's probably possible to instantiate the RenderingModel in your controller,
execute it, then populating the model with all properties it exposes and hand
over to the view. I suspect however that you'll see problems during rendering
because its not rendered by the STKRenderer, Blossom has it's own renderer that
bridges into Spring MVC.
If what you're after is to have dependency injection of spring components in
your class extending an STK RenderingModel then there's an easier way to
achieve this. Spring supports doing autowiring on any bean instance, even beans
that are not managed in its container. To use this feature you would do
something like this:
{code}
public class MyRenderingModel extends RenderingModelImpl<TemplateDefinition> {
@Autowired
private MyService service;
public MyRenderingModel(ServletContext servletContext, Node content,
TemplateDefinition definition, RenderingModel<?> parent) {
super(content, definition, parent);
WebApplicationContext wac =
WebApplicationContextUtils.getWebApplicationContext(servletContext);
AutowireCapableBeanFactory beanFactory =
wac.getAutowireCapableBeanFactory();
beanFactory.autowireBean(this);
}
{code}
As of Blossom 3.0 we're providing a support class,
AbstractAutowiredRenderingModel, that does this for you. Although, when
extending STK rendering models you can't also extend from this one. But any
how, might come in handy later on.
Could you elaborate on your use case? I might be able to come up with a better
idea if II know more. Which STK component is it that you want to extend? What
functionality are you adding?
// Tobias
--
Context is everything:
http://forum.magnolia-cms.com/forum/thread.html?threadId=3f466009-9d53-4b7d-96cf-e3ecad87be97
----------------------------------------------------------------
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]>
----------------------------------------------------------------