1

I am getting the above mentioned error when i try to use the GenericService.resolveName(java.lang.String pName) The similer error for session scope as well. If i change the scope to 'global', things are working as expected. But I need to have my component in prototype scope. So what can i do..?

  • Which version of ATG are you using? In your comment below you reference ATG 2007.3 documentation. Prototype scope was only introduced in ATG10.1.1 to cope with Endeca Cartridge Handlers. Can you give us an extract of the code where you say it doesn't work (and the error) so that we can help you track it down. – radimpe Sep 03 '13 at 08:15

2 Answers2

1

Please validate your requirements to ensure that you actually have to use prototype scope.

As we don't know your requirements we cannot validate if what you are trying to achieve is a good practice or not, but my 2 cents to overcome your technical problem is to resolve that component starting at the request level.

If you have access to the current request, do something like:

request.resolveName(componentName);

Otherwise, do something like:

ServletUtil.getCurrentRequest().resolveName(componentName);

resolveName is a computationally expensive operation, so it should only be used when you don't have any other option (for example in a request servlet pipeline, to refer to a request or session component), but if you have to, it will solve your problem.

0

You might not be able to resolve lower scope component from higher scope object.

If you are calling resolveComponent from global scope component will might not be able to resolve it.

A component’s properties should always point to objects whose scope is equal to or greater than its own. Thus, global-scope component properties should only point to objects that also have global scope; session-scope component properties should only point to objects that have global or session scope; while request-scope component properties can point to objects of any scope, including request.

Please read the ATG documentation below

http://docs.oracle.com/cd/E35318_02/Platform.10-1-1/ATGPlatformProgGuide/html/s0205componentscopes01.html

Mouli
  • 194
  • 7
  • What you have referred from the documentation is true for component's properties (if we are going to specify them in the .properties file and inject with setter method). But I believe that we should be able to resolve even lower scope components with 'GenericService.resolveName()' – Janaka Priyadarshana Sep 01 '13 at 13:35
  • I checked the API documentation, it does not specify such limitation for run time component resolve. http://docs.oracle.com/cd/E23507_01/Platform.20073/apidoc/atg/nucleus/GenericService.html#resolveName(java.lang.String) – Janaka Priyadarshana Sep 01 '13 at 15:28
  • Another way is to use atg.servlet.ServletUtil.getCurrentRequest().resolveName("yyx") which will resolve to request scope components associated to current thread. But as per document "prototype" is exception and can be resolved at any level and once resolved it will hold the local scope. (if global component resolved prototype scope the component moves up to global scope). – Mouli Sep 01 '13 at 16:53