Hello,
I'm having a difficult problem for which I hope someone here can help me..
The short story: the parameters interceptor is unable to set a parameter.
These are the classes involved:

package model;
public class Language extends org.apache.commons.lang.enums.Enum {
        protected Language(String name) {
                super(name);
        }
}

public interface IPreference {
        public <T extends model.Language> T getLanguage();
}

package project.model;
public class Language extends model.Language {
        public static final Language ENGLISH = new Language("en");
        public static final Language RUSSIAN = new Language("ru");
}

public class Preference implements IPreference {
        public project.model.Language getLanguage() {
                return language;
        }

        public void setLanguage(project.model.Language language) {
                this.language = language;
        }
}

The choice of this hierarchy is to allow to have the first 2 classes
in separate, generic and reusable bundle and the next 2 classes
specific to a project.

In the interface I'm using <T extends model.Language> T in the
interface to avoid the need to cast the result of the method to a
specific implementation and let the compiler use type inference to do
it for me(and I think this is were the root of the problem is).

I'm trying to use Preference inside an action and allow a user to
choose the preferred language by sending a form parameter:
preference.language

The custom converter does it's job and converts 'en' to
project.model.Language.ENGLISH

The problem is that the parameters interceptor, through ognl, cannot
find the setter for the type project.model.Language
I've looked at the ognl sources and found that it is using
introspection to find the properties of Preference.
The introspector, trying to create a list of the properties, obtains a
list of all methods of the class that respect the JavaBeans spec.
The problem is that the compiler generates a second method inside Preference:
public volatile model.Language getLanguage() {
        return getLanguage();
}
The introspector sees first the method written by me in the source and
then the generated method, which overrides my method.
After that, it find the setter, but the setter doesn't match the type
returned by this second getter, so it ignores it.
Now ognl will throw an exception saying it cannot set the value on a
private field, because it doesn't find the setter.
I've tried adding a second setter for the base Language class, and
introspection finds it but now the converter isn't working because it
cannot work with the base Language class.

I've tried creating a PreferenceBeanInfo class, but it doesn't seem
right to *manually* create a list of property descriptors that can get
of of sync when Preference changes.

Any ideas on how to resolve this problem?
I know this is really an ognl problem, but ognl seems abandoned...

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to