Search in sources :

Example 1 with IAdditionalDataObject

use of org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalDataObject in project jaffa-framework by jaffa-projects.

the class CustomDataBeanFactory method getInstance.

public IDataBean getInstance() throws FrameworkException, ApplicationExceptions {
    // Construct the DataBean
    IDataBean dataBean = null;
    IAdditionalDataObject dataBean2 = null;
    try {
        log.debug("Created a Custom DataBean " + m_beanClass);
        dataBean = (IDataBean) m_beanClass.newInstance();
        if (m_beanClass.newInstance() instanceof IAdditionalDataObject) {
            if (dataBean != null) {
                dataBean2 = (IAdditionalDataObject) dataBean;
                dataBean2.setAdditionalDataObject(additionalDataObject);
            }
        }
    } catch (IllegalAccessException e) {
        log.error("Can't create data bean", e);
        throw new EngineProcessingException(e.getMessage(), e);
    } catch (InstantiationException e) {
        log.error("Can't create data bean", e);
        throw new EngineProcessingException(e.getMessage(), e);
    }
    if (dataBean == null)
        throw new EngineProcessingException("No CustomDataBean created");
    // Populate the keys
    if (m_keys != null) {
        for (String field : m_keys.keySet()) {
            String value = m_keys.get(field);
            try {
                BeanHelper.setField(dataBean, field, value);
            } catch (IntrospectionException e) {
                log.error("Can't set bean property " + field, e);
            } catch (IllegalAccessException e) {
                log.error("Can't set bean property " + field, e);
            } catch (InvocationTargetException e) {
                log.error("Can't set bean property " + field, e);
            }
        }
    }
    if (m_formName != null) {
        try {
            BeanHelper.setField(dataBean, "formName", m_formName);
        } catch (IntrospectionException e) {
            log.error("Can't set bean property formName. " + e);
        } catch (IllegalAccessException e) {
            log.error("Can't set bean property formName. " + e);
        } catch (InvocationTargetException e) {
            log.error("Can't set bean property formName. " + e);
        }
    }
    // Now make sure the bean has data in it
    dataBean.populate();
    return dataBean;
}
Also used : IAdditionalDataObject(org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalDataObject) IntrospectionException(java.beans.IntrospectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) EngineProcessingException(org.jaffa.modules.printing.services.exceptions.EngineProcessingException)

Example 2 with IAdditionalDataObject

use of org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalDataObject in project jaffa-framework by jaffa-projects.

the class FormSelectionMaintenanceComponent method doUpdateDetail.

/**
 * Show the AdditionalData Component.
 * Pass the Additional Data Object if there is one.
 */
public FormKey doUpdateDetail(GridModelRow selectedRow, String actionPath) throws ApplicationExceptions, FrameworkException {
    FormKey fk = null;
    String additionalComponent = null;
    try {
        final FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) selectedRow.get("object");
        additionalComponent = rowDto.getAdditionalDataComponent();
        Component comp = (Component) run(additionalComponent);
        BeanUtils.setProperty(comp, getKey1(), getValue1());
        if (getKey2() != null) {
            BeanUtils.setProperty(comp, getKey2(), getValue2());
        }
        if (getKey3() != null) {
            BeanUtils.setProperty(comp, getKey3(), getValue3());
        }
        if (getKey4() != null) {
            BeanUtils.setProperty(comp, getKey4(), getValue4());
        }
        if (getKey5() != null) {
            BeanUtils.setProperty(comp, getKey5(), getValue5());
        }
        if (getKey6() != null) {
            BeanUtils.setProperty(comp, getKey6(), getValue6());
        }
        // implements IAdditionalDataObject.
        if (comp instanceof IAdditionalDataObject) {
            ((IAdditionalDataObject) comp).setAdditionalDataObject(rowDto.getAdditionalDataObject());
            ((IUpdateComponent) comp).addUpdateListener(new IUpdateListener() {

                public void updateDone(EventObject source) {
                    try {
                        rowDto.setAdditionalDataObject(((IAdditionalDataObject) source.getSource()).getAdditionalDataObject());
                    } catch (Exception e) {
                        log.warn("Error setting the Additional Data Object after the Update", e);
                    }
                }
            });
        }
        comp.setReturnToFormKey(getResultsFormKey());
        // Populate info to allow Web 2.0 component to return to this component
        if (comp instanceof RiaWrapperComponent) {
            RiaWrapperComponent c = (RiaWrapperComponent) comp;
            c.getParameters().setProperty("returnToActionPath", actionPath);
            c.getParameters().setProperty("returnToFormKey_componentId", comp.getReturnToFormKey().getComponentId());
        }
        fk = comp.display();
    } catch (SecurityException se) {
        log.error("SecurityException Occurred ", se);
        throw new ApplicationExceptions(new FormSelectionException(FormSelectionException.SECURITY_EXCEPTION));
    } catch (IllegalAccessException e) {
        log.error("IllegalAccessException Occurred ", e);
    } catch (InvocationTargetException e) {
        log.error("InvocationTargetException Occurred ", e);
    } catch (IllegalArgumentException e) {
        log.error("IllegalArgumentException Occurred ", e);
    } catch (ApplicationExceptions applicationException) {
        throw applicationException;
    } catch (FrameworkException frameworkException) {
        throw frameworkException;
    }
    return fk;
}
Also used : FormSelectionException(org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) IAdditionalDataObject(org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalDataObject) RiaWrapperComponent(org.jaffa.presentation.portlet.component.RiaWrapperComponent) FormKey(org.jaffa.presentation.portlet.FormKey) FrameworkException(org.jaffa.exceptions.FrameworkException) FormSelectionException(org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException) ApplicationException(org.jaffa.exceptions.ApplicationException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) InvocationTargetException(java.lang.reflect.InvocationTargetException) FormSelectionMaintenanceOutRowDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto) Component(org.jaffa.presentation.portlet.component.Component) RiaWrapperComponent(org.jaffa.presentation.portlet.component.RiaWrapperComponent)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IAdditionalDataObject (org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalDataObject)2 IntrospectionException (java.beans.IntrospectionException)1 MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)1 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)1 EngineProcessingException (org.jaffa.modules.printing.services.exceptions.EngineProcessingException)1 FormKey (org.jaffa.presentation.portlet.FormKey)1 Component (org.jaffa.presentation.portlet.component.Component)1 RiaWrapperComponent (org.jaffa.presentation.portlet.component.RiaWrapperComponent)1