Hi, Markus Pallo wrote: > Hi, > > i am posting this message again, because first posting was included in > another thread and not a new one .... And i am still waiting for answer :-) > > > As described we are using sling with an object mapper. > > ------------------------------------------------ > wall (sling:resourceType = "wall") > | > |--> brickgroup1 (sling:resourceType = "brickgroup") > | | > | |--> brick11 (sling:resourceType = "statichtmlbrick") > | |--> brick12 (sling:resourceType = "contentbrick") > | |--> brick13 (sling:resourceType = "contentbrick") > | > |--> brickgroup2 (sling:resourceType = "brickgroup") > | > |--> brick21 (sling:resourceType = "contentbrick") > |--> brick22 (sling:resourceType = "contentbrick") > |--> brick23 (sling:resourceType = "statichtmlbrick") > ------------------------------------------------ > > If we include other scripts to a script, we always use > ---- > sling.include(brickgroup.getPath()); > ---- > > inside the script, we adapt resource to our class with an AdapterFactory. > > > This means, the node has always to be retrieved and mapped again by the > OR mapper. So, if I understand you correctly, you request the wall resource and inside the script for the wall resource you already have the brickgroup object. Then you do an include with the path of the brickgroup object which finally invokes a script for the brickgroup. But this script only gets the Resource object which you have to adapt to Brickgroup again. And you want to avoid the second adaption as this already happend in the wall script? (or has been part of some action in that script)
I'm not 100% sure, but maybe the SlingHttpServletRequest#getRequestDispatch(Resource, RequestDispatcherOptions) does already what you need? Carsten > > > So i am wondering if it could be useful to have a new include method on > SlingHelper to handle > > public void include(Resource resource, RequestDispatcherOptions options) { > // doing similar than other includes, but with resource > } > > > And than i could create a PojoSyntheticResource and include directly in > the script. Benefit its already resolved and mapped.... > example: > > sling.include(new PojoSyntheticResource(brickgroup)); > > ------------------------- > public class PojoSyntheticResource extends SyntheticResource { > > > Base base; > > public PojoSyntheticResource(ResourceResolver resourceResolver, Base > base) { > this(resourceResolver, base.getPath(), base.getResourceType()); > this.base = base; > } > > /** > * Creates a synthetic resource with the given <code>path</code> and > * <code>resourceType</code>. > */ > protected PojoSyntheticResource(ResourceResolver resourceResolver, > String path, String resourceType) { > super(resourceResolver, path, resourceType); > } > > @Override > public <Type> Type adaptTo(Class<Type> type) { > if (Base.class.isAssignableFrom(type)) { > return (Type) base; > } > return null; > } > } > > ------------------------------------- > > > Do you like to have an scriptHelper method like this ? than i would open > an jira issue. Or do you any other suggestions ? > > > > Markus > -- Carsten Ziegeler cziege...@apache.org