Hi, 
I need to intercept the urls that have been created in all pages that are based 
on the redirect template as I need to change the host name of all these urls 
before redirecting.

I have tried to create a custom groovy script to do this but am having trouble 
starting as the class isn't being instantiated. 

The code I am trying is

[code]package classes;

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.templates.pages.STKPage;
import info.magnolia.module.templatingkit.functions.STKTemplatingFunctions;
import info.magnolia.module.templatingkit.templates.AbstractSTKTemplateModel;
import info.magnolia.module.templatingkit.templates.RedirectTemplateModel;

public class EssexRedirectTemplateModel extends RedirectTemplateModel {
  
  @Inject
  public EssexRedirectTemplateModel(Node content, STKPage definition, 
RenderingModel<?> parent, STKTemplatingFunctions stkFunctions, 
TemplatingFunctions templatingFunctions) {
     super(content, definition, parent, stkFunctions, templatingFunctions);
  }

  @Override
  public String execute() {
    return super.execute();
  
  }
  
  public String getMyText() {
    return "this is my text";
  }
}[/code]

but I keep getting the error 
[code]Caused by: info.magnolia.rendering.engine.RenderException: Can't 
instantiate model: class classes.EssexRedirectTemplateModel
        at 
info.magnolia.rendering.renderer.AbstractRenderer.newModel(AbstractRenderer.java:222)
        at 
info.magnolia.rendering.renderer.AbstractRenderer.newModel(AbstractRenderer.java:176)
        at 
info.magnolia.rendering.renderer.AbstractRenderer.render(AbstractRenderer.java:117)
        at 
info.magnolia.module.templatingkit.renderers.STKRenderer.render(STKRenderer.java:77)
        ... 117 more
Caused by: info.magnolia.objectfactory.MgnlInstantiationException: 
java.lang.reflect.InvocationTargetException
        at 
info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:112)
        at 
info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:99)
        at 
info.magnolia.objectfactory.guice.GuiceComponentProvider.newInstanceWithParameterResolvers(GuiceComponentProvider.java:118)
        at 
info.magnolia.rendering.renderer.AbstractRenderer.newModel(AbstractRenderer.java:183)
        ... 120 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown 
Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at 
info.magnolia.objectfactory.ObjectManufacturer.newInstance(ObjectManufacturer.java:106)
        ... 123 more
Caused by: java.lang.NoSuchMethodError: 
info.magnolia.module.templatingkit.templates.RedirectTemplateModel: method 
<init>()V not found
        at 
classes.EssexRedirectTemplateModel.<init>(classes.EssexRedirectTemplateModel)
        ... 128 more
[/code]

Any suggestions would be welcome. I obviously haven't implemented the execute() 
method with my custom code yet as I need to get this working first.

Also, any other suggestions on how I could do this would be welcome i.e. a ton 
of pages based on redirect template that have incorrect external urls which I 
need to correct. i.e. a simple search and replace across all these pages.

-- 
Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=f7393fbb-485d-4e8b-8bfc-1a6d4a62817c


----------------------------------------------------------------
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]>
----------------------------------------------------------------

Reply via email to