Search in sources :

Example 6 with MainPage

use of com.servoy.j2db.server.headlessclient.MainPage in project servoy-client by Servoy.

the class WebDataSubmitLink method renderHead.

/**
 * @see org.apache.wicket.markup.html.IHeaderContributor#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 */
public void renderHead(IHeaderResponse response) {
    List<CharSequence> lst = strippedText.getJavascriptUrls();
    for (int i = 0; i < lst.size(); i++) {
        response.renderJavascriptReference(lst.get(i).toString());
    }
    lst = strippedText.getJavascriptScripts();
    for (int i = 0; i < lst.size(); i++) {
        // $NON-NLS-1$
        response.renderJavascript(lst.get(i), "js_" + getMarkupId() + lst.get(i).hashCode());
    }
    lst = strippedText.getLinkTags();
    for (int i = 0; i < lst.size(); i++) {
        response.renderString(lst.get(i));
    }
    lst = strippedText.getStyles();
    for (CharSequence style : lst) {
        response.renderString(CSS_OPEN_TAG + style + CSS_CLOSE_TAG);
    }
    IValueMap map = strippedText.getBodyAttributes();
    if (map != null && map.size() > 0) {
        String onLoad = null;
        Iterator<String> iterator = map.keySet().iterator();
        while (iterator.hasNext()) {
            String attributeName = iterator.next();
            if (// $NON-NLS-1$
            attributeName.equalsIgnoreCase("onload")) {
                onLoad = map.getString(attributeName);
                iterator.remove();
                break;
            }
        }
        if (onLoad != null) {
            response.renderOnLoadJavascript(onLoad);
        }
        Page findPage = findPage();
        if (findPage instanceof MainPage) {
            ((MainPage) findPage).addBodyAttributes(map);
        }
    }
}
Also used : IValueMap(org.apache.wicket.util.value.IValueMap) Page(org.apache.wicket.Page) MainPage(com.servoy.j2db.server.headlessclient.MainPage) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 7 with MainPage

use of com.servoy.j2db.server.headlessclient.MainPage in project servoy-client by Servoy.

the class WebEventExecutor method handleEvent.

/**
 * @param type
 * @param target
 * @param comp
 * @param webModifiers
 * @param mouseLocation
 * @param page
 */
private void handleEvent(EventType type, AjaxRequestTarget target, Component comp, int webModifiers, Point mouseLocation, Point absoluteMouseLocation, Page page) {
    // process model changes from web components
    WebClientSession.get().getWebClient().executeEvents();
    Component renderScriptProvider = comp;
    ISupplyFocusChildren<?> componentWithChildren = renderScriptProvider.findParent(ISupplyFocusChildren.class);
    if (componentWithChildren != null)
        renderScriptProvider = (Component) componentWithChildren;
    if (renderScriptProvider instanceof WrapperContainer)
        renderScriptProvider = ((WrapperContainer) renderScriptProvider).getDelegate();
    RenderEventExecutor renderEventExecutor = null;
    if (renderScriptProvider instanceof IScriptableProvider) {
        IScriptable s = ((IScriptableProvider) renderScriptProvider).getScriptObject();
        if (s instanceof ISupportOnRenderCallback) {
            renderEventExecutor = ((ISupportOnRenderCallback) s).getRenderEventExecutor();
            if (!renderEventExecutor.hasRenderCallback())
                renderEventExecutor = null;
        }
    }
    if (type == EventType.focusGained || type == EventType.action || type == EventType.focusLost) {
        if (type == EventType.focusGained || type == EventType.action) {
            ((MainPage) page).setFocusedComponent(comp);
        } else {
            ((MainPage) page).setFocusedComponent(null);
        }
        if (renderEventExecutor != null) {
            renderEventExecutor.setRenderStateChanged();
            // if component's onRender did not change any properties, don't add it to the target
            if (renderScriptProvider instanceof ISupportOnRender && WebOnRenderHelper.doRender((ISupportOnRender) renderScriptProvider)) {
                target.addComponent(renderScriptProvider);
            }
        }
    }
    if (type == EventType.focusLost || setSelectedIndex(comp, target, convertModifiers(webModifiers), type == EventType.focusGained || type == EventType.action)) {
        if (skipFireFocusGainedCommand && type.equals(JSEvent.EventType.focusGained)) {
            skipFireFocusGainedCommand = false;
        } else {
            switch(type) {
                case action:
                    fireActionCommand(false, comp, convertModifiers(webModifiers), mouseLocation);
                    break;
                case focusGained:
                    fireEnterCommands(false, comp, convertModifiers(webModifiers));
                    break;
                case focusLost:
                    fireLeaveCommands(comp, false, convertModifiers(webModifiers));
                    break;
                case doubleClick:
                    fireDoubleclickCommand(false, comp, convertModifiers(webModifiers), mouseLocation);
                    break;
                case rightClick:
                    // if right click, mark the meta flag as it is on the smart client
                    fireRightclickCommand(false, comp, convertModifiers(webModifiers | 8), null, mouseLocation, absoluteMouseLocation);
                    break;
                case none:
                case dataChange:
                case form:
                case onDrag:
                case onDragOver:
                case onDrop:
            }
        }
    }
}
Also used : WrapperContainer(com.servoy.j2db.server.headlessclient.WrapperContainer) ISupportOnRender(com.servoy.j2db.ui.ISupportOnRender) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) RenderEventExecutor(com.servoy.j2db.ui.RenderEventExecutor) IComponent(com.servoy.j2db.ui.IComponent) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) IRuntimeComponent(com.servoy.j2db.ui.runtime.IRuntimeComponent) IScriptableProvider(com.servoy.j2db.scripting.IScriptableProvider) IScriptable(com.servoy.j2db.scripting.IScriptable) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 8 with MainPage

use of com.servoy.j2db.server.headlessclient.MainPage in project servoy-client by Servoy.

the class WebDataField method fireOnRender.

public void fireOnRender(boolean force) {
    if (!isIgnoreOnRender && scriptable != null) {
        boolean isFocused = false;
        IMainContainer currentContainer = ((FormManager) application.getFormManager()).getCurrentContainer();
        if (currentContainer instanceof MainPage) {
            isFocused = this.equals(((MainPage) currentContainer).getFocusedComponent());
        }
        if (force)
            scriptable.getRenderEventExecutor().setRenderStateChanged();
        scriptable.getRenderEventExecutor().fireOnRender(isFocused);
    }
}
Also used : FormManager(com.servoy.j2db.FormManager) IMainContainer(com.servoy.j2db.IMainContainer) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 9 with MainPage

use of com.servoy.j2db.server.headlessclient.MainPage in project servoy-client by Servoy.

the class WebDataHtmlArea method fireOnRender.

public void fireOnRender(boolean force) {
    if (scriptable != null) {
        boolean isFocused = false;
        IMainContainer currentContainer = ((FormManager) application.getFormManager()).getCurrentContainer();
        if (currentContainer instanceof MainPage) {
            isFocused = this.equals(((MainPage) currentContainer).getFocusedComponent());
        }
        if (force)
            scriptable.getRenderEventExecutor().setRenderStateChanged();
        scriptable.getRenderEventExecutor().fireOnRender(isFocused);
    }
}
Also used : FormManager(com.servoy.j2db.FormManager) IMainContainer(com.servoy.j2db.IMainContainer) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 10 with MainPage

use of com.servoy.j2db.server.headlessclient.MainPage in project servoy-client by Servoy.

the class WebDataListBox method fireOnRender.

public void fireOnRender(boolean force) {
    if (scriptable != null) {
        boolean isFocused = false;
        IMainContainer currentContainer = ((FormManager) application.getFormManager()).getCurrentContainer();
        if (currentContainer instanceof MainPage) {
            isFocused = this.equals(((MainPage) currentContainer).getFocusedComponent());
        }
        if (force)
            scriptable.getRenderEventExecutor().setRenderStateChanged();
        scriptable.getRenderEventExecutor().fireOnRender(isFocused);
    }
}
Also used : FormManager(com.servoy.j2db.FormManager) IMainContainer(com.servoy.j2db.IMainContainer) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Aggregations

MainPage (com.servoy.j2db.server.headlessclient.MainPage)21 FormManager (com.servoy.j2db.FormManager)13 IMainContainer (com.servoy.j2db.IMainContainer)13 Component (org.apache.wicket.Component)5 IComponent (com.servoy.j2db.ui.IComponent)4 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)4 ISupportOnRenderCallback (com.servoy.j2db.ui.ISupportOnRenderCallback)4 IRuntimeComponent (com.servoy.j2db.ui.runtime.IRuntimeComponent)4 IDisplayData (com.servoy.j2db.dataprocessing.IDisplayData)3 WrapperContainer (com.servoy.j2db.server.headlessclient.WrapperContainer)3 IProviderStylePropertyChanges (com.servoy.j2db.ui.IProviderStylePropertyChanges)3 ListItem (org.apache.wicket.markup.html.list.ListItem)3 BaseComponent (com.servoy.j2db.persistence.BaseComponent)2 GraphicalComponent (com.servoy.j2db.persistence.GraphicalComponent)2 IScriptable (com.servoy.j2db.scripting.IScriptable)2 IScriptableProvider (com.servoy.j2db.scripting.IScriptableProvider)2 ILabel (com.servoy.j2db.ui.ILabel)2 IPortalComponent (com.servoy.j2db.ui.IPortalComponent)2 ISupportOnRender (com.servoy.j2db.ui.ISupportOnRender)2 AbstractRuntimeBaseComponent (com.servoy.j2db.ui.scripting.AbstractRuntimeBaseComponent)2