A
Alexandre Jaquet
Hi,
I'm trying to write a generic method for the setter of my fields and I
doesn't know how to invoke the method
I've the following code
public void notifyPropertyChange(String name, String value) {
Class c = this.getClass();
String methodName = name.substring(0,1).toUpperCase() +
name.substring(1);
try {
Method method = c.getMethod("set" + methodName, new Class []
{String.class});
String [] args = new String[]{value};
try {
method.invoke(null, args);
}catch (IllegalAccessException ex) {
Logger.error("Error while invoking method : " + ex);
}catch (InvocationTargetException ex) {
Logger.error("Error while invoking method : " + ex);
}
}catch (NoSuchMethodException ex) {
Logger.error("Error while invoking method : " + ex);
}
but the method.invoke doesn't work.
Any idea on how to fix it ?
Thanks
Alexandre
I'm trying to write a generic method for the setter of my fields and I
doesn't know how to invoke the method
I've the following code
public void notifyPropertyChange(String name, String value) {
Class c = this.getClass();
String methodName = name.substring(0,1).toUpperCase() +
name.substring(1);
try {
Method method = c.getMethod("set" + methodName, new Class []
{String.class});
String [] args = new String[]{value};
try {
method.invoke(null, args);
}catch (IllegalAccessException ex) {
Logger.error("Error while invoking method : " + ex);
}catch (InvocationTargetException ex) {
Logger.error("Error while invoking method : " + ex);
}
}catch (NoSuchMethodException ex) {
Logger.error("Error while invoking method : " + ex);
}
but the method.invoke doesn't work.
Any idea on how to fix it ?
Thanks
Alexandre