Search in sources :

Example 1 with Component

use of org.jaffa.presentation.portlet.component.Component 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)

Example 2 with Component

use of org.jaffa.presentation.portlet.component.Component in project jaffa-framework by jaffa-projects.

the class FormTag method renderToken.

/**
 * This is the exact copy of the renderToken() method in Struts 1.1, except that it gets the token information from the component, as opposed to the session.
 * Generates a hidden input field with token information, if any.
 * @return A hidden input field containing the token.
 */
protected String renderToken() {
    StringBuffer results = new StringBuffer();
    FormKey fk = (FormKey) pageContext.getRequest().getAttribute(FormKey.class.getName());
    if (fk != null && fk.getComponentId() != null) {
        Component component = UserSession.getUserSession((HttpServletRequest) pageContext.getRequest()).getComponent(fk.getComponentId());
        if (component != null && component.getToken() != null) {
            results.append("<input type=\"hidden\" name=\"");
            results.append(Constants.TOKEN_KEY);
            results.append("\" value=\"");
            results.append(component.getToken());
            results.append("\" />");
        }
    }
    return results.toString();
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FormKey(org.jaffa.presentation.portlet.FormKey) Component(org.jaffa.presentation.portlet.component.Component)

Example 3 with Component

use of org.jaffa.presentation.portlet.component.Component in project jaffa-framework by jaffa-projects.

the class UserSession method showInfo.

/**
 * Display all internal Session Info in the System.out stream.
 */
public void showInfo() {
    PrintStream p = System.out;
    p.println("---User Info----");
    p.println("User Id: " + m_userId);
    p.println("Components...");
    for (Iterator i = m_components.keySet().iterator(); i.hasNext(); ) {
        String key = (String) i.next();
        Component c = (Component) m_components.get(key);
        p.println("   Id: " + c.getComponentId());
        p.println("   Name: " + c.getClass().getName());
        p.println("");
    }
}
Also used : Component(org.jaffa.presentation.portlet.component.Component)

Example 4 with Component

use of org.jaffa.presentation.portlet.component.Component in project jaffa-framework by jaffa-projects.

the class UserSession method killAllComponents.

/**
 * This function kills all related components.
 */
public void killAllComponents() {
    if (m_components != null) {
        // Create an array of componentIds
        String[] componentIds = new String[m_components.size()];
        Iterator itr = m_components.keySet().iterator();
        for (int i = 0; itr.hasNext(); i++) componentIds[i] = (String) itr.next();
        // Note: its quite possible that a component could have been killed by another !!!
        for (int i = 0; i < componentIds.length; i++) {
            Component c = (Component) m_components.get(componentIds[i]);
            if (c != null) {
                if (log.isDebugEnabled())
                    log.debug("Killing Component : " + c.getComponentId() + " - " + c.getComponentDefinition().getComponentName());
                c.quit();
            }
        }
    }
// Object[] components = m_components.values().toArray();
// for(int i = 0; i < components.length; i++) {
// Component c = (Component) components[i];
// if (log.isDebugEnabled())
// log.debug("Killing Component : " + c.getComponentId() + " - " + c.getComponentDefinition().getComponentName() );
// // Quit Component
// c.quit();
// }
}
Also used : Component(org.jaffa.presentation.portlet.component.Component)

Example 5 with Component

use of org.jaffa.presentation.portlet.component.Component in project jaffa-framework by jaffa-projects.

the class ActionBase method processContainerFormKey.

/**
 * Returns the ContainerFormKey, if the component specified by the input FormKey has one defined.
 * For such a component a FormKeyChangeEvent will be sent to the registered FormKeyChangeListeners.
 * @param fk The input FormKey.
 * @return The ContainerFormKey, if exists, or just the input FormKey.
 */
protected FormKey processContainerFormKey(FormKey fk) {
    // The following should probably be invoked recursively. Will do so if the need arises !!
    UserSession us = UserSession.getUserSession(request);
    Component component = us.getComponent(fk.getComponentId());
    if (component != null && component.getContainerFormKey() != null && component.replaceWithContainerFormKey(fk)) {
        FormKeyChangeListener[] listeners = component.getFormKeyChangeListeners();
        if (listeners != null && listeners.length > 0) {
            FormKeyChangeEvent e = new FormKeyChangeEvent(this, fk);
            for (int i = 0; i < listeners.length; i++) listeners[i].formKeyChanged(e);
        }
        fk = component.getContainerFormKey();
        if (log.isDebugEnabled())
            log.debug("The component in the received form key has a ContainerFormKey. Fired the FormKeyChangeListeners on the component and using the ContainerFormKey " + fk);
    }
    return fk;
}
Also used : UserSession(org.jaffa.presentation.portlet.session.UserSession) Component(org.jaffa.presentation.portlet.component.Component)

Aggregations

Component (org.jaffa.presentation.portlet.component.Component)10 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ApplicationException (org.jaffa.exceptions.ApplicationException)2 FrameworkException (org.jaffa.exceptions.FrameworkException)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)2 FormKey (org.jaffa.presentation.portlet.FormKey)2 RiaWrapperComponent (org.jaffa.presentation.portlet.component.RiaWrapperComponent)2 AccessControlException (java.security.AccessControlException)1 Iterator (java.util.Iterator)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 org.jaffa.components.maint (org.jaffa.components.maint)1 DateTime (org.jaffa.datatypes.DateTime)1 MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)1 IAdditionalData (org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalData)1 IAdditionalDataObject (org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalDataObject)1 UserSession (org.jaffa.presentation.portlet.session.UserSession)1 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)1 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)1