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) {
                Object value = getter.invoke(source, noParams);
                Method setter = props[i].getWriteMethod();
                if (setter != null && sourceClass != destClass) {
                    try {
                        setter = destClass.getMethod(
                    } catch (NoSuchMethodException x) {
                        setter = null;
                if (setter != null) {
                    oneParam[0] = value;
                    setter.invoke(dest, oneParam);
        } catch (IntrospectionException x) {
            throw new InternalError(x.getMessage());
        } catch (IllegalAccessException x) {
            throw new InternalError(x.getMessage());
        } catch (IllegalArgumentException x) {
            throw new InternalError(x.getMessage());
        } catch (SecurityException x) {
            throw new InternalError(x.getMessage());
        } catch (InvocationTargetException x) {
            throw new InternalError(
8 Years
Discussion Span
Last Post by ceyesuma

Uhm, is this a webapp? If so, simply save the bean to the session. If it is not a webapp, save the bean elsewhere (Preferences. maybe). Assuming this is simply a "user profile" bean and not actual "data", as that is more view related than data related.


Some good points. I do not believe I need to copy anything. It is already in the db.
Thus far I have relied on ModelResources to confirm profile and user to construct the GUI.
would it be possible to use the .put method for the viewResources =new Resources() and then the user and profile attributes would be accessible for the GUI panels to use the DAO to gather specific data?

On the point of reflection. Would it be possible to manipulate an array at run time to add and or remove tabs from an JTabbedPane?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.