Skip to main content
gabrielav200407
Level 2
Oct 16, 2015 2:27 AM UTC
Solved

Same views, different slice models

Say I'm having a jsp script that uses a model Model1 which provides myMethod. Now, model Model2 has it's own implementation of myMethod.

Model1 is for component 1, Model2 is for component 2. I want to include the jsp script in both components, without the need to duplicate it, the only difference being the model instantiated.

 

Any ideas?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

You can write a factory class which initialize either model 1 or model 2 based on your condition and then use that factory class in your jsp script

2 replies

smacdonald2008
Level 10
Oct 16, 2015 2:27 AM UTC

Another way people work with models in AEM is to use the BackBone framework:

http://backbonejs.org/

Translate
Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
Oct 16, 2015 2:27 AM UTC

You can write a factory class which initialize either model 1 or model 2 based on your condition and then use that factory class in your jsp script

Translate