Search in sources :

Example 1 with IRequestTarget

use of org.apache.wicket.IRequestTarget in project servoy-client by Servoy.

the class WebClientsApplication method newRequestCycleProcessor.

@Override
protected IRequestCycleProcessor newRequestCycleProcessor() {
    return new UrlCompressingWebRequestProcessor() {

        @Override
        public void respond(RequestCycle requestCycle) {
            // execute events from WebClient.invokeLater() before the respond (render) is started
            Session session = Session.get();
            if (session instanceof WebClientSession && ((WebClientSession) session).getWebClient() != null) {
                ((WebClientSession) session).getWebClient().executeEvents();
            }
            super.respond(requestCycle);
        }

        /**
         * @see wicket.protocol.http.WebRequestCycleProcessor#newRequestCodingStrategy()
         */
        @Override
        protected IRequestCodingStrategy newRequestCodingStrategy() {
            Settings settings = Settings.getInstance();
            if (// $NON-NLS-1$ //$NON-NLS-2$
            Utils.getAsBoolean(settings.getProperty("servoy.webclient.crypt-urls", "true"))) {
                return new ServoyCryptedUrlWebRequestCodingStrategy(new UrlCompressingWebCodingStrategy());
            } else {
                return new UrlCompressingWebCodingStrategy();
            }
        }

        @Override
        protected IRequestTarget resolveListenerInterfaceTarget(RequestCycle requestCycle, Page page, String componentPath, String interfaceName, RequestParameters requestParameters) {
            try {
                IRequestTarget requestTarget = super.resolveListenerInterfaceTarget(requestCycle, page, componentPath, interfaceName, requestParameters);
                if (requestTarget instanceof BehaviorRequestTarget) {
                    Component target = ((BehaviorRequestTarget) requestTarget).getTarget();
                    if (!(target instanceof Page)) {
                        boolean invalidPage = false;
                        Page page2 = null;
                        try {
                            // test if it has a page.
                            page2 = target.findParent(Page.class);
                        } catch (Exception e) {
                            Debug.trace(e);
                            invalidPage = true;
                        }
                        if (page2 == null || !page2.getId().equals(page.getId())) {
                            invalidPage = true;
                        }
                        if (invalidPage) {
                            // $NON-NLS-1$
                            Debug.log("Couldn't resolve the page of the component, component already gone from page? returning empty");
                            return EmptyRequestTarget.getInstance();
                        }
                    }
                }
                return requestTarget;
            } catch (Exception e) {
                // $NON-NLS-1$
                Debug.log("couldnt resolve interface, component page already gone from page? returning empty");
            }
            return EmptyRequestTarget.getInstance();
        }

        @Override
        public IRequestTarget resolve(final RequestCycle requestCycle, final RequestParameters requestParameters) {
            try {
                return super.resolve(requestCycle, requestParameters);
            } catch (PageExpiredException e) {
                // if there is a page expired exception
                // then ignore it if there is a current form.
                // $NON-NLS-1$
                Debug.trace("Page expired, checking for a current form");
                Request request = requestCycle.getRequest();
                if (request instanceof WebRequest && ((WebRequest) request).isAjax() && requestParameters.isOnlyProcessIfPathActive()) {
                    // $NON-NLS-1$
                    Debug.trace("Page expired, it is an ajan/process only if active request");
                    Session session = Session.get();
                    if (session instanceof WebClientSession && ((WebClientSession) session).getWebClient() != null) {
                        WebClient webClient = ((WebClientSession) session).getWebClient();
                        if (webClient.getFormManager().getCurrentForm() != null) {
                            // $NON-NLS-1$
                            Debug.trace("Page expired, there is a current form, ignore this ajax request");
                            return EmptyAjaxRequestTarget.getInstance();
                        }
                    }
                }
                throw e;
            }
        }
    };
}
Also used : RequestCycle(org.apache.wicket.RequestCycle) PageExpiredException(org.apache.wicket.protocol.http.PageExpiredException) WebRequest(org.apache.wicket.protocol.http.WebRequest) Request(org.apache.wicket.Request) Page(org.apache.wicket.Page) RestartResponseException(org.apache.wicket.RestartResponseException) AbstractRestartResponseException(org.apache.wicket.AbstractRestartResponseException) IOException(java.io.IOException) PageExpiredException(org.apache.wicket.protocol.http.PageExpiredException) RequestParameters(org.apache.wicket.request.RequestParameters) UrlCompressingWebCodingStrategy(org.apache.wicket.protocol.http.request.urlcompressing.UrlCompressingWebCodingStrategy) BehaviorRequestTarget(org.apache.wicket.request.target.component.listener.BehaviorRequestTarget) WebRequest(org.apache.wicket.protocol.http.WebRequest) IRequestTarget(org.apache.wicket.IRequestTarget) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) Settings(com.servoy.j2db.util.Settings) IWiQuerySettings(org.odlabs.wiquery.core.commons.IWiQuerySettings) IRequestCycleSettings(org.apache.wicket.settings.IRequestCycleSettings) WiQuerySettings(org.odlabs.wiquery.core.commons.WiQuerySettings) UrlCompressingWebRequestProcessor(org.apache.wicket.protocol.http.request.urlcompressing.UrlCompressingWebRequestProcessor) Session(org.apache.wicket.Session)

Example 2 with IRequestTarget

use of org.apache.wicket.IRequestTarget in project servoy-client by Servoy.

the class WebDataLookupField method mapTrimmedToNotTrimmed.

/**
 * Maps a trimmed value entered by the user to a value stored in the value list. The value stored in the value list may contain some trailing spaces, while
 * the value entered by the user is trimmed.
 *
 * @param value
 * @return
 */
@SuppressWarnings("nls")
public String mapTrimmedToNotTrimmed(String value) {
    // Although the value entered by the user should be trimmed, make sure it is so.
    String trimmed = value.trim();
    try {
        // this is the &nbsp character we set for empty value
        if ("\u00A0".equals(trimmed) || trimmed.length() == 0)
            return trimmed;
        // Grab all values that start with the value entered by the user.
        String result = matchValueListValue(trimmed, false);
        if (result == null) {
            if (changeListener != null)
                dlm.getValueList().removeListDataListener(changeListener);
            try {
                dlm.fill(parentState, getDataProviderID(), trimmed, false);
                result = matchValueListValue(trimmed, false);
                if (result == null && list.hasRealValues()) {
                    dlm.fill(parentState, getDataProviderID(), null, false);
                    // if it doesn't have real values, just keep what is typed
                    // now just try to match it be start with matching instead of equals:
                    result = matchValueListValue(trimmed, true);
                    if (result == null && !getEventExecutor().getValidationEnabled()) {
                        result = trimmed;
                    } else {
                        // if this is found then it is a commit of data of a partial string, make sure that the field is updated with the complete value.
                        String displayValue = result == null ? "" : result;
                        if (displayValue != null && !displayValue.equals(trimmed) && RequestCycle.get() != null) {
                            IRequestTarget requestTarget = RequestCycle.get().getRequestTarget();
                            if (requestTarget instanceof AjaxRequestTarget) {
                                ((AjaxRequestTarget) requestTarget).appendJavascript("if (document.getElementById('" + getMarkupId() + "').value == '" + value + "') document.getElementById('" + getMarkupId() + "').value='" + displayValue + "'");
                            }
                        }
                    }
                }
            } finally {
                if (changeListener != null)
                    dlm.getValueList().addListDataListener(changeListener);
            }
        }
        // If no match was found then return back the value, otherwise return the found match.
        return result == null ? trimmed : result;
    } catch (Exception e) {
        Debug.error(e);
        return trimmed;
    }
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IRequestTarget(org.apache.wicket.IRequestTarget) DisplayString(com.servoy.j2db.dataprocessing.CustomValueList.DisplayString)

Example 3 with IRequestTarget

use of org.apache.wicket.IRequestTarget in project servoy-client by Servoy.

the class ScrollResponseHeaderContainer method renderHead.

/*
	 * (non-Javadoc)
	 *
	 * @see org.apache.wicket.Component#renderHead(org.apache.wicket.markup.html.internal.HtmlHeaderContainer)
	 */
@Override
public void renderHead(final HtmlHeaderContainer container) {
    super.renderHead(container);
    IRequestTarget requestTarget = RequestCycle.get().getRequestTarget();
    boolean isAjaxRequest = requestTarget instanceof AjaxRequestTarget;
    if ((!isAjaxRequest || !labelsCssRendered) && labelsCSSClasses.size() > 0) {
        boolean isStyleSheetLimitForIE = WebEventExecutor.isStyleSheetLimitForIE(getSession());
        StringBuilder classes = new StringBuilder();
        for (String cssClass : labelsCSSClasses) {
            // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            classes.append(".").append(getTableLabelCSSClass(cssClass)).append(" { visibility: hidden; }").append(isStyleSheetLimitForIE ? " " : "\n");
        }
        if (isStyleSheetLimitForIE) {
            container.getHeaderResponse().renderOnDomReadyJavascript(// $NON-NLS-1$ //$NON-NLS-2$
            "Servoy.Utils.appendToInlineStylesheetForIE('.servoydummy {}', '" + classes.toString() + "');");
        } else {
            // $NON-NLS-1$
            StringBuilder style = new StringBuilder("<style type=\"text/css\">\n");
            style.append(classes);
            // $NON-NLS-1$
            style.append("</style>");
            container.getHeaderResponse().renderString(style.toString());
        }
        labelsCssRendered = true;
    }
    String columnResizeScript = getColumnResizeScript();
    if (columnResizeScript != null)
        container.getHeaderResponse().renderOnDomReadyJavascript(columnResizeScript);
    // rerender the odd/even/selected style (with css transparency fallback color) upon creation of the table  (table is created via an ajax call).
    // It was introduced because renderering IRuntimeComponent does not support duplicate rules needed for fallback colors, it adds the javascript rowselectionscript to be executed
    // just after all the rows components is rendered.
    // @author Ovidiu
    String rowSelScritpt = getRowSelectionScript(true);
    if (rowSelScritpt != null)
        container.getHeaderResponse().renderOnDomReadyJavascript(rowSelScritpt);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IRequestTarget(org.apache.wicket.IRequestTarget)

Example 4 with IRequestTarget

use of org.apache.wicket.IRequestTarget in project servoy-client by Servoy.

the class WebSplitPane method setRuntimeDividerLocation.

public void setRuntimeDividerLocation(double locationPos) {
    if (locationPos < 0)
        return;
    setDividerLocationInternal(locationPos);
    IRequestTarget requestTarget = RequestCycle.get().getRequestTarget();
    MainPage page = (MainPage) findPage();
    if (requestTarget instanceof AjaxRequestTarget && page != null) {
        ((PageContributor) page.getPageContributor()).addSplitPaneToUpdatedDivider(this);
        if (// $NON-NLS-1$
        page.getController() != null && Utils.getAsBoolean(page.getController().getApplication().getRuntimeProperties().get("enableAnchors"))) {
            // $NON-NLS-1$
            ((AjaxRequestTarget) requestTarget).appendJavascript("layoutEntirePage();");
        }
        // $NON-NLS-1$
        ((AjaxRequestTarget) requestTarget).appendJavascript("Servoy.Resize.onWindowResize();");
    } else
        sizeChanged = true;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PageContributor(com.servoy.j2db.server.headlessclient.PageContributor) IRequestTarget(org.apache.wicket.IRequestTarget) MainPage(com.servoy.j2db.server.headlessclient.MainPage)

Example 5 with IRequestTarget

use of org.apache.wicket.IRequestTarget in project servoy-client by Servoy.

the class WebClientsApplication method init.

/**
 * @see wicket.protocol.http.WebApplication#init()
 */
@Override
protected void init() {
    // TODO this is a workaround to allow mobile test client that only starts Tomcat not to give exceptions (please remove if mobile test client initialises a full app. server in the future)
    if (ApplicationServerRegistry.get() == null)
        return;
    getResourceSettings().setResourceWatcher(new ServoyModificationWatcher(Duration.seconds(5)));
    // getResourceSettings().setResourcePollFrequency(Duration.seconds(5));
    getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);
    getResourceSettings().setDefaultCacheDuration((int) Duration.days(365).seconds());
    getMarkupSettings().setCompressWhitespace(true);
    getMarkupSettings().setMarkupCache(new ServoyMarkupCache(this));
    // getMarkupSettings().setStripWicketTags(true);
    getResourceSettings().setResourceStreamLocator(new ServoyResourceStreamLocator(this));
    getResourceSettings().setPackageResourceGuard(new ServoyPackageResourceGuard());
    // getResourceSettings().setResourceFinder(createResourceFinder());
    getResourceSettings().setThrowExceptionOnMissingResource(false);
    getApplicationSettings().setPageExpiredErrorPage(ServoyExpiredPage.class);
    getApplicationSettings().setClassResolver(new ServoyClassResolver());
    getSessionSettings().setMaxPageMaps(15);
    // getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
    getSecuritySettings().setCryptFactory(new CachingKeyInSessionSunJceCryptFactory());
    Settings settings = Settings.getInstance();
    // $NON-NLS-1$ //$NON-NLS-2$
    getDebugSettings().setOutputComponentPath(Utils.getAsBoolean(settings.getProperty("servoy.webclient.debug.wicketpath", "false")));
    if (// $NON-NLS-1$ //$NON-NLS-2$
    Utils.getAsBoolean(settings.getProperty("servoy.webclient.nice.urls", "false"))) {
        // $NON-NLS-1$
        mount(new HybridUrlCodingStrategy("/solutions", SolutionLoader.class));
        // $NON-NLS-1$
        mount(new HybridUrlCodingStrategy("/application", MainPage.class));
        mount(new // $NON-NLS-1$
        HybridUrlCodingStrategy(// $NON-NLS-1$
        "/ss", // $NON-NLS-1$
        SolutionLoader.class) {

            /**
             * @see wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy#matches(wicket.IRequestTarget)
             */
            @Override
            public boolean matches(IRequestTarget requestTarget) {
                return false;
            }
        });
    } else {
        // $NON-NLS-1$
        mountBookmarkablePage("/solutions", SolutionLoader.class);
        mount(new // $NON-NLS-1$
        BookmarkablePageRequestTargetUrlCodingStrategy(// $NON-NLS-1$
        "/ss", // $NON-NLS-1$
        SolutionLoader.class, // $NON-NLS-1$
        null) {

            /**
             * @see wicket.request.target.coding.BookmarkablePageRequestTargetUrlCodingStrategy#matches(wicket.IRequestTarget)
             */
            @Override
            public boolean matches(IRequestTarget requestTarget) {
                return false;
            }
        });
    }
    // $NON-NLS-1$ //$NON-NLS-2$
    long maxSize = Utils.getAsLong(settings.getProperty("servoy.webclient.maxuploadsize", "0"), false);
    if (maxSize > 0) {
        getApplicationSettings().setDefaultMaximumUploadSize(Bytes.kilobytes(maxSize));
    }
    // $NON-NLS-1$
    getSharedResources().putClassAlias(IApplication.class, "application");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(PageContributor.class, "pc");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(MaskBehavior.class, "mask");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(Application.class, "servoy");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(org.wicketstuff.calendar.markup.html.form.DatePicker.class, "datepicker");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(YUILoader.class, "yui");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(JQueryLoader.class, "jquery");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(TinyMCELoader.class, "tinymce");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(org.apache.wicket.markup.html.WicketEventReference.class, "wicketevent");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(org.apache.wicket.ajax.WicketAjaxReference.class, "wicketajax");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(MainPage.class, "servoyjs");
    // $NON-NLS-1$
    getSharedResources().putClassAlias(org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow.class, "modalwindow");
    // $NON-NLS-1$
    PackageResource.bind(this, IApplication.class, "images/open_project.gif");
    // $NON-NLS-1$
    PackageResource.bind(this, IApplication.class, "images/save.gif");
    // $NON-NLS-1$//$NON-NLS-2$
    mountSharedResource("/formcss", "servoy/formcss");
    sharedMediaResource = new SharedMediaResource();
    // $NON-NLS-1$
    getSharedResources().add("media", sharedMediaResource);
    mount(new // $NON-NLS-1$ //$NON-NLS-2$
    SharedResourceRequestTargetUrlCodingStrategy(// $NON-NLS-1$ //$NON-NLS-2$
    "mediafolder", // $NON-NLS-1$ //$NON-NLS-2$
    "servoy/media") {

        @Override
        protected void appendParameters(AppendingStringBuffer url, Map<String, ?> parameters) {
            if (parameters != null && parameters.size() > 0) {
                // $NON-NLS-1$
                Object solutionName = parameters.get("s");
                if (solutionName != null)
                    appendPathParameter(url, null, solutionName.toString());
                // $NON-NLS-1$
                Object resourceId = parameters.get("id");
                if (resourceId != null)
                    appendPathParameter(url, null, resourceId.toString());
                StringBuilder queryParams = new StringBuilder();
                for (Entry<?, ?> entry1 : parameters.entrySet()) {
                    Object value = ((Entry<?, ?>) entry1).getValue();
                    if (value != null) {
                        Object key = ((Entry<?, ?>) entry1).getKey();
                        if (// $NON-NLS-1$ //$NON-NLS-2$
                        !"s".equals(key) && !"id".equals(key)) {
                            if (value instanceof String[]) {
                                String[] values = (String[]) value;
                                for (String value1 : values) {
                                    // $NON-NLS-1$
                                    if (queryParams.length() > 0)
                                        queryParams.append("&");
                                    // $NON-NLS-1$
                                    queryParams.append(key).append("=").append(value1);
                                }
                            } else {
                                // $NON-NLS-1$
                                if (queryParams.length() > 0)
                                    queryParams.append("&");
                                // $NON-NLS-1$
                                queryParams.append(key).append("=").append(value);
                            }
                        }
                    }
                }
                if (queryParams.length() > 0) {
                    // $NON-NLS-1$
                    url.append("?").append(queryParams);
                }
            }
        }

        @Override
        protected void appendPathParameter(AppendingStringBuffer url, String key, String value) {
            String escapedValue = value;
            // $NON-NLS-1$
            String[] values = escapedValue.split("/");
            if (values.length > 1) {
                StringBuilder sb = new StringBuilder(escapedValue.length());
                for (String str : values) {
                    sb.append(urlEncodePathComponent(str));
                    sb.append('/');
                }
                sb.setLength(sb.length() - 1);
                escapedValue = sb.toString();
            } else {
                escapedValue = urlEncodePathComponent(escapedValue);
            }
            if (!Strings.isEmpty(escapedValue)) {
                if (// $NON-NLS-1$
                !url.endsWith("/")) {
                    // $NON-NLS-1$
                    url.append("/");
                }
                // $NON-NLS-1$
                if (key != null)
                    url.append(urlEncodePathComponent(key)).append("/");
                url.append(escapedValue);
            }
        }

        /*
			 * (non-Javadoc)
			 * 
			 * @see org.apache.wicket.request.target.coding.AbstractRequestTargetUrlCodingStrategy#decodeParameters(java.lang.String, java.util.Map)
			 */
        @Override
        protected ValueMap decodeParameters(String urlFragment, Map<String, ?> urlParameters) {
            ValueMap map = new ValueMap();
            // $NON-NLS-1$
            final String[] pairs = urlFragment.split("/");
            if (pairs.length > 1) {
                // $NON-NLS-1$
                map.add("s", pairs[1]);
                StringBuffer sb = new StringBuffer();
                for (int i = 2; i < pairs.length; i++) {
                    sb.append(pairs[i]);
                    // $NON-NLS-1$
                    sb.append("/");
                }
                sb.setLength(sb.length() - 1);
                // $NON-NLS-1$
                map.add("id", sb.toString());
            }
            if (urlParameters != null) {
                map.putAll(urlParameters);
            }
            return map;
        }
    });
    // $NON-NLS-1$
    getSharedResources().add("resources", new ServeResources());
    // $NON-NLS-1$
    getSharedResources().add("formcss", new FormCssResource(this));
    if (// $NON-NLS-1$
    settings.getProperty("servoy.webclient.error.page", null) != null) {
        getApplicationSettings().setInternalErrorPage(ServoyErrorPage.class);
    }
    if (// $NON-NLS-1$
    settings.getProperty("servoy.webclient.pageexpired.page", null) != null) {
        getApplicationSettings().setPageExpiredErrorPage(ServoyPageExpiredPage.class);
    }
    addPreComponentOnBeforeRenderListener(new IComponentOnBeforeRenderListener() {

        public void onBeforeRender(Component component) {
            if (component instanceof IServoyAwareBean) {
                IModel model = component.getInnermostModel();
                WebForm webForm = component.findParent(WebForm.class);
                if (model instanceof RecordItemModel && webForm != null) {
                    IRecord record = (IRecord) ((RecordItemModel) model).getObject();
                    FormScope fs = webForm.getController().getFormScope();
                    if (record != null && fs != null) {
                        ((IServoyAwareBean) component).setSelectedRecord(new ServoyBeanState(record, fs));
                    }
                }
            } else if (!(component.getParent() instanceof WebDataCompositeTextField)) {
                if (!component.isEnabled()) {
                    boolean hasOnRender = (component instanceof IFieldComponent && ((IFieldComponent) component).getScriptObject() instanceof ISupportOnRenderCallback && ((ISupportOnRenderCallback) ((IFieldComponent) component).getScriptObject()).getRenderEventExecutor().hasRenderCallback());
                    if (!hasOnRender) {
                        // onrender may change the enable state
                        return;
                    }
                }
                Component targetComponent = null;
                boolean hasFocus = false, hasBlur = false;
                if (component instanceof IFieldComponent && ((IFieldComponent) component).getEventExecutor() != null) {
                    if (component instanceof WebDataCompositeTextField && ((WebDataCompositeTextField) component).getDelegate() instanceof Component) {
                        targetComponent = (Component) ((WebDataCompositeTextField) component).getDelegate();
                    } else {
                        targetComponent = component;
                    }
                    if (component instanceof WebBaseSelectBox) {
                        Component[] cs = ((WebBaseSelectBox) component).getFocusChildren();
                        if (cs != null && cs.length == 1)
                            targetComponent = cs[0];
                    }
                    if (component instanceof WebDataHtmlArea)
                        hasFocus = true;
                    // always install a focus handler when in a table view to detect change of selectedIndex and test for record validation
                    if (((IFieldComponent) component).getEventExecutor().hasEnterCmds() || component.findParent(WebCellBasedView.class) != null || (((IFieldComponent) component).getScriptObject() instanceof ISupportOnRenderCallback && ((ISupportOnRenderCallback) ((IFieldComponent) component).getScriptObject()).getRenderEventExecutor().hasRenderCallback())) {
                        hasFocus = true;
                    }
                    // Always trigger event on focus lost:
                    // 1) check for new selected index, record validation may have failed preventing a index changed
                    // 2) prevent focus gained to be called when field validation failed
                    // 3) general ondata change
                    hasBlur = true;
                } else if (component instanceof WebBaseLabel) {
                    targetComponent = component;
                    hasFocus = true;
                }
                if (targetComponent != null) {
                    MainPage mainPage = targetComponent.findParent(MainPage.class);
                    if (mainPage.isUsingAjax()) {
                        AbstractAjaxBehavior eventCallback = mainPage.getPageContributor().getEventCallback();
                        if (eventCallback != null) {
                            String callback = eventCallback.getCallbackUrl().toString();
                            if (component instanceof WebDataRadioChoice || component instanceof WebDataCheckBoxChoice || component instanceof WebDataLookupField || component instanceof WebDataComboBox || component instanceof WebDataListBox || component instanceof WebDataHtmlArea || component instanceof WebDataCompositeTextField) {
                                // is updated via ServoyChoiceComponentUpdatingBehavior or ServoyFormComponentUpdatingBehavior, this is just for events
                                callback += "&nopostdata=true";
                            }
                            for (IBehavior behavior : targetComponent.getBehaviors()) {
                                if (behavior instanceof EventCallbackModifier) {
                                    targetComponent.remove(behavior);
                                }
                            }
                            if (hasFocus) {
                                StringBuilder js = new StringBuilder();
                                // $NON-NLS-1$ //$NON-NLS-2$
                                js.append("eventCallback(this,'focus','").append(callback).append("',event)");
                                // $NON-NLS-1$
                                targetComponent.add(new EventCallbackModifier("onfocus", true, new Model<String>(js.toString())));
                                // $NON-NLS-1$ //$NON-NLS-2$
                                targetComponent.add(new EventCallbackModifier("onmousedown", true, new Model<String>("focusMousedownCallback(event)")));
                            }
                            if (hasBlur) {
                                boolean blockRequest = false;
                                // if component has ondatachange, check for blockrequest
                                if (component instanceof ISupportEventExecutor && ((ISupportEventExecutor) component).getEventExecutor().hasChangeCmd()) {
                                    WebClientSession webClientSession = WebClientSession.get();
                                    blockRequest = webClientSession != null && webClientSession.blockRequest();
                                }
                                StringBuilder js = new StringBuilder();
                                // $NON-NLS-1$ //$NON-NLS-2$
                                js.append("postEventCallback(this,'blur','").append(callback).append("',event," + blockRequest + ")");
                                // $NON-NLS-1$
                                targetComponent.add(new EventCallbackModifier("onblur", true, new Model<String>(js.toString())));
                            }
                        }
                    }
                }
            }
        }
    });
}
Also used : ValueMap(org.apache.wicket.util.value.ValueMap) WebBaseSelectBox(com.servoy.j2db.server.headlessclient.dataui.WebBaseSelectBox) WebDataLookupField(com.servoy.j2db.server.headlessclient.dataui.WebDataLookupField) IRequestTarget(org.apache.wicket.IRequestTarget) Settings(com.servoy.j2db.util.Settings) IWiQuerySettings(org.odlabs.wiquery.core.commons.IWiQuerySettings) IRequestCycleSettings(org.apache.wicket.settings.IRequestCycleSettings) WiQuerySettings(org.odlabs.wiquery.core.commons.WiQuerySettings) WebDataCheckBoxChoice(com.servoy.j2db.server.headlessclient.dataui.WebDataCheckBoxChoice) WebBaseLabel(com.servoy.j2db.server.headlessclient.dataui.WebBaseLabel) WebDataCompositeTextField(com.servoy.j2db.server.headlessclient.dataui.WebDataCompositeTextField) IRecord(com.servoy.j2db.dataprocessing.IRecord) WebCellBasedView(com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView) WebDataRadioChoice(com.servoy.j2db.server.headlessclient.dataui.WebDataRadioChoice) RecordItemModel(com.servoy.j2db.server.headlessclient.dataui.RecordItemModel) HybridUrlCodingStrategy(org.apache.wicket.request.target.coding.HybridUrlCodingStrategy) ISupportOnRenderCallback(com.servoy.j2db.ui.ISupportOnRenderCallback) ISupportEventExecutor(com.servoy.j2db.ui.ISupportEventExecutor) FormScope(com.servoy.j2db.scripting.FormScope) IPageMapEntry(org.apache.wicket.session.pagemap.IPageMapEntry) Entry(java.util.Map.Entry) IServoyAwareBean(com.servoy.j2db.dataui.IServoyAwareBean) IBehavior(org.apache.wicket.behavior.IBehavior) WebDataComboBox(com.servoy.j2db.server.headlessclient.dataui.WebDataComboBox) IFieldComponent(com.servoy.j2db.ui.IFieldComponent) Component(org.apache.wicket.Component) AbstractAjaxBehavior(org.apache.wicket.behavior.AbstractAjaxBehavior) AppendingStringBuffer(org.apache.wicket.util.string.AppendingStringBuffer) IModel(org.apache.wicket.model.IModel) WebDataListBox(com.servoy.j2db.server.headlessclient.dataui.WebDataListBox) IComponentOnBeforeRenderListener(org.apache.wicket.application.IComponentOnBeforeRenderListener) AppendingStringBuffer(org.apache.wicket.util.string.AppendingStringBuffer) ServoyBeanState(com.servoy.j2db.component.ServoyBeanState) WebDataHtmlArea(com.servoy.j2db.server.headlessclient.dataui.WebDataHtmlArea) IModel(org.apache.wicket.model.IModel) RecordItemModel(com.servoy.j2db.server.headlessclient.dataui.RecordItemModel) Model(org.apache.wicket.model.Model) IFieldComponent(com.servoy.j2db.ui.IFieldComponent)

Aggregations

IRequestTarget (org.apache.wicket.IRequestTarget)5 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 IFieldComponent (com.servoy.j2db.ui.IFieldComponent)2 Settings (com.servoy.j2db.util.Settings)2 Component (org.apache.wicket.Component)2 IRequestCycleSettings (org.apache.wicket.settings.IRequestCycleSettings)2 IWiQuerySettings (org.odlabs.wiquery.core.commons.IWiQuerySettings)2 WiQuerySettings (org.odlabs.wiquery.core.commons.WiQuerySettings)2 ServoyBeanState (com.servoy.j2db.component.ServoyBeanState)1 DisplayString (com.servoy.j2db.dataprocessing.CustomValueList.DisplayString)1 IRecord (com.servoy.j2db.dataprocessing.IRecord)1 IServoyAwareBean (com.servoy.j2db.dataui.IServoyAwareBean)1 FormScope (com.servoy.j2db.scripting.FormScope)1 MainPage (com.servoy.j2db.server.headlessclient.MainPage)1 PageContributor (com.servoy.j2db.server.headlessclient.PageContributor)1 RecordItemModel (com.servoy.j2db.server.headlessclient.dataui.RecordItemModel)1 WebBaseLabel (com.servoy.j2db.server.headlessclient.dataui.WebBaseLabel)1 WebBaseSelectBox (com.servoy.j2db.server.headlessclient.dataui.WebBaseSelectBox)1 WebCellBasedView (com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView)1 WebDataCheckBoxChoice (com.servoy.j2db.server.headlessclient.dataui.WebDataCheckBoxChoice)1