I can not figure out how to get data from the model to the GUI in the view.
If the user logs in successfully all the users personal data is stored into the bean
including the userUid. of the user.
also, if login is successful the app will build many panels depending on there profile.
after that I can not ever go back to the bean and use any data to populate components on
the GUI panels including any actionPerformed methods the user may choose.
Do I have to use reflection or do I have to copy the bean?
I am not sure how this is done. all I have is an idea to invoke methods at run time using
reflection or to try to get this class to work and see what possibilities it offers.
but it will not except the source param of my bean. The beans are just getters and setters with no constructor.
public static void copy(Object source, Object dest) {
try {
Class sourceClass = source.getClass();
Class destClass = dest.getClass();
BeanInfo info = Introspector.getBeanInfo(sourceClass);
PropertyDescriptor props[] = info.getPropertyDescriptors();
Object noParams[] = new Object[0];
Object oneParam[] = new Object[1];
for (int i = 0; i < props.length; i++) {
Method getter = props[i].getReadMethod();
if (getter == null) {
continue;
}
Object value = getter.invoke(source, noParams);
Method setter = props[i].getWriteMethod();
if (setter != null && sourceClass != destClass) {
try {
setter = destClass.getMethod(
setter.getName(),
setter.getParameterTypes());
} catch (NoSuchMethodException x) {
setter = null;
}
}
if (setter != null) {
oneParam[0] = value;
setter.invoke(dest, oneParam);
}
}
} catch (IntrospectionException x) {
log(x);
throw new InternalError(x.getMessage());
} catch (IllegalAccessException x) {
log(x);
throw new InternalError(x.getMessage());
} catch (IllegalArgumentException x) {
log(x);
throw new InternalError(x.getMessage());
} catch (SecurityException x) {
log(x);
throw new InternalError(x.getMessage());
} catch (InvocationTargetException x) {
log(x.getTargetException());
throw new InternalError(
x.getTargetException().getMessage());
}
}