File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes @ManagedProperty set in subclass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "@ManagedProperty set in subclass" Watch "@ManagedProperty set in subclass" New topic
Author

@ManagedProperty set in subclass

Jina Lu
Greenhorn

Joined: Jul 09, 2010
Posts: 26

Hy,
I want to change this faces-config.xml to annotations, but I do have problems with supperVariable as it's property is different for each sub class. How should @ManagedProperty be declared to achieve this (MyClass extends MyAbstract class which contains variable supperVariable instance of SupperVariableClass, SupperVariableChildClass extends SupperChildClass) :


Thanks in advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16160
    
  21

Annotations can be a problem when you subclass, since the annotation in question has to be instructed on whether or not it is inheritable. If it's not, the annotation will simply be ignored.

The primary purpose of annotations is to allow coding with default values and eliminating or reducing the need for an external configuration file. When you have 2 instances of an object (inherited or not) and you need 2 different values injected into it, the best you can do is set one of them via annotation and override the annotation for the other instance using external configuration (XML).

There's really no way an annotation could specify per-instance values without greatly complicating things and probably destroying the POJO characteristics of the object as well.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @ManagedProperty set in subclass