Search in sources :

Example 1 with AbstractRuntimeRendersupportComponent

use of com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent in project servoy-client by Servoy.

the class WebCellAdapter method valueChanged.

public void valueChanged(ModificationEvent e) {
    MainPage mp = view.findParent(MainPage.class);
    if (mp != null)
        mp.touch();
    IRecord record = e.getRecord();
    Iterator iterator = ((MarkupContainer) view.getTable()).iterator();
    while (iterator.hasNext()) {
        Object next = iterator.next();
        if (next instanceof ListItem) {
            ListItem li = (ListItem) next;
            Object modelObject = li.getModelObject();
            if (record == null || modelObject == record) {
                boolean hasOnRender = false;
                Iterator iterator2 = li.iterator();
                while (iterator2.hasNext()) {
                    ArrayList<Object> cellDisplays = new ArrayList<Object>();
                    Object cell = iterator2.next();
                    cell = CellContainer.getContentsForCell((Component) cell);
                    if (cell instanceof WebCellBasedViewListViewItem) {
                        Iterator listItemIte = ((WebCellBasedViewListViewItem) cell).iterator();
                        while (listItemIte.hasNext()) {
                            Object listItemDisplay = listItemIte.next();
                            if (listItemDisplay instanceof WrapperContainer) {
                                listItemDisplay = ((WrapperContainer) listItemDisplay).getDelegate();
                            }
                            cellDisplays.add(listItemDisplay);
                        }
                    } else {
                        cellDisplays.add(cell);
                    }
                    for (Object cellDisplay : cellDisplays) {
                        if (cellDisplay instanceof IProviderStylePropertyChanges && cellDisplay instanceof IDisplayData && ((IDisplayData) cellDisplay).getDataProviderID() == dataprovider) {
                            // only test if it is not already changed
                            view.checkForValueChanges(cellDisplay);
                            // do fire on render on all components for record change
                            if (cellDisplay instanceof ISupportOnRender && cellDisplay instanceof IScriptableProvider) {
                                IScriptable so = ((IScriptableProvider) cellDisplay).getScriptObject();
                                if (so instanceof AbstractRuntimeRendersupportComponent && ((ISupportOnRenderCallback) so).getRenderEventExecutor().hasRenderCallback()) {
                                    String componentDataproviderID = ((AbstractRuntimeRendersupportComponent) so).getDataProviderID();
                                    if (record != null || (e.getName() != null && e.getName().equals(componentDataproviderID))) {
                                        ((ISupportOnRender) cellDisplay).fireOnRender(true);
                                        hasOnRender = true;
                                    }
                                }
                            }
                        }
                    }
                }
                if (record != null || (!hasOnRender && !canChangeValue(e)))
                    break;
            }
        }
    }
}
Also used : MarkupContainer(org.apache.wicket.MarkupContainer) ISupportOnRender(com.servoy.j2db.ui.ISupportOnRender) IRecord(com.servoy.j2db.dataprocessing.IRecord) ArrayList(java.util.ArrayList) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) WebCellBasedViewListViewItem(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.WebCellBasedViewListViewItem) IScriptable(com.servoy.j2db.scripting.IScriptable) WrapperContainer(com.servoy.j2db.server.headlessclient.WrapperContainer) Iterator(java.util.Iterator) IProviderStylePropertyChanges(com.servoy.j2db.ui.IProviderStylePropertyChanges) IDisplayData(com.servoy.j2db.dataprocessing.IDisplayData) ListItem(org.apache.wicket.markup.html.list.ListItem) Component(org.apache.wicket.Component) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 2 with AbstractRuntimeRendersupportComponent

use of com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent in project servoy-client by Servoy.

the class DisplaysAdapter method valueChanged.

/*
	 * _____________________________________________________________ JavaScriptModificationlistener
	 */
public void valueChanged(ModificationEvent e) {
    if (!adjusting) {
        try {
            adjusting = true;
            Object obj = null;
            boolean formVariable = false;
            if (dataProviderID != null) {
                if (dal.getFormScope().has(dataProviderID, dal.getFormScope())) {
                    formVariable = true;
                    obj = dal.getFormScope().get(dataProviderID);
                } else if (record != null) {
                    obj = record.getValue(dataProviderID);
                    if (obj == Scriptable.NOT_FOUND) {
                        obj = null;
                    }
                    // have to do this because for calcs in calcs. Better was to had a check for previous value.
                    fireModificationEvent(obj);
                }
            }
            // do not set value for form variable except when really changed
            if (!formVariable || dataProviderID == null || dataProviderID.equals(e.getName())) {
                setValueToDisplays(obj);
            }
        } finally {
            adjusting = false;
        }
    }
    // do fire on render on all components for record change
    for (IDisplayData displayData : displays) {
        if (displayData instanceof ISupportOnRender && displayData instanceof IScriptableProvider) {
            IScriptable so = ((IScriptableProvider) displayData).getScriptObject();
            if (so instanceof AbstractRuntimeRendersupportComponent && ((ISupportOnRenderCallback) so).getRenderEventExecutor().hasRenderCallback()) {
                String componentDataproviderID = ((AbstractRuntimeRendersupportComponent) so).getDataProviderID();
                if (e.getRecord() != null || (e.getName() != null && e.getName().equals(componentDataproviderID))) {
                    ((ISupportOnRender) displayData).fireOnRender(true);
                }
            }
        }
    }
}
Also used : ISupportOnRender(com.servoy.j2db.ui.ISupportOnRender) AbstractRuntimeRendersupportComponent(com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IScriptable(com.servoy.j2db.scripting.IScriptable)

Aggregations

IScriptable (com.servoy.j2db.scripting.IScriptable)2 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)2 ISupportOnRender (com.servoy.j2db.ui.ISupportOnRender)2 ISupportOnRenderCallback (com.servoy.j2db.ui.ISupportOnRenderCallback)2 AbstractRuntimeRendersupportComponent (com.servoy.j2db.ui.scripting.AbstractRuntimeRendersupportComponent)2 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)1 IRecord (com.servoy.j2db.dataprocessing.IRecord)1 MainPage (com.servoy.j2db.server.headlessclient.MainPage)1 WrapperContainer (com.servoy.j2db.server.headlessclient.WrapperContainer)1 WebCellBasedViewListViewItem (com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.WebCellBasedViewListViewItem)1 IProviderStylePropertyChanges (com.servoy.j2db.ui.IProviderStylePropertyChanges)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 Component (org.apache.wicket.Component)1 MarkupContainer (org.apache.wicket.MarkupContainer)1 ListItem (org.apache.wicket.markup.html.list.ListItem)1