Search in sources :

Example 1 with ServoyForm

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

the class ServoySubmitPagingNavigationLink method getTriggerJavaScript.

/**
 * The javascript which trigges this link.
 *
 * TODO: This is a copy & paste from Button
 *
 * @return The javascript
 */
protected final String getTriggerJavaScript() {
    if (getForm() != null) {
        // find the root form - the one we are really going to submit
        ServoyForm root = (ServoyForm) getForm().getRootForm();
        StringBuffer sb = new StringBuffer(100);
        sb.append("var e=document.getElementById('");
        sb.append(root.getHiddenField());
        sb.append("'); e.name=\'");
        sb.append(getInputName());
        sb.append("'; e.value='x';");
        sb.append("var f=document.getElementById('");
        sb.append(root.getMarkupId());
        sb.append("');");
        if (true) {
            if (getForm() != root) {
                sb.append("var ff=document.getElementById('");
                sb.append(getForm().getMarkupId());
                sb.append("');");
            } else {
                sb.append("var ff=f;");
            }
            sb.append("if (ff.onsubmit != undefined) { if (ff.onsubmit()==false) return false; }");
        }
        sb.append("f.submit();e.value='';e.name='';return false;");
        return sb.toString();
    } else {
        return null;
    }
}
Also used : PrependingStringBuffer(org.apache.wicket.util.string.PrependingStringBuffer) ServoyForm(com.servoy.j2db.server.headlessclient.ServoyForm)

Example 2 with ServoyForm

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

the class ServoySubmitPagingNavigationIncrementLink method getTriggerJavaScript.

/**
 * The javascript which trigges this link.
 *
 * TODO: This is a copy & paste from Button
 *
 * @return The javascript
 */
protected final String getTriggerJavaScript() {
    if (getForm() != null) {
        // find the root form - the one we are really going to submit
        ServoyForm root = (ServoyForm) getForm().getRootForm();
        StringBuffer sb = new StringBuffer(100);
        sb.append("var e=document.getElementById('");
        sb.append(root.getHiddenField());
        sb.append("'); e.name=\'");
        sb.append(getInputName());
        sb.append("'; e.value='x';");
        sb.append("var f=document.getElementById('");
        sb.append(root.getMarkupId());
        sb.append("');");
        if (true) {
            if (getForm() != root) {
                sb.append("var ff=document.getElementById('");
                sb.append(getForm().getMarkupId());
                sb.append("');");
            } else {
                sb.append("var ff=f;");
            }
            sb.append("if (ff.onsubmit != undefined) { if (ff.onsubmit()==false) return false; }");
        }
        sb.append("f.submit();e.value='';e.name='';return false;");
        return sb.toString();
    } else {
        return null;
    }
}
Also used : PrependingStringBuffer(org.apache.wicket.util.string.PrependingStringBuffer) ServoyForm(com.servoy.j2db.server.headlessclient.ServoyForm)

Example 3 with ServoyForm

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

the class WebEventExecutor method onError.

public void onError(AjaxRequestTarget target, Component comp) {
    if (target == null) {
        return;
    }
    ServoyForm form = comp.findParent(ServoyForm.class);
    if (form == null) {
        return;
    }
    generateResponse(target, form.getPage());
}
Also used : ServoyForm(com.servoy.j2db.server.headlessclient.ServoyForm)

Example 4 with ServoyForm

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

the class WebEventExecutor method onEvent.

public void onEvent(final EventType type, final AjaxRequestTarget target, final Component comp, final int webModifiers, final Point mouseLocation, final Point absoluteMouseLocation) {
    ServoyForm form = comp.findParent(ServoyForm.class);
    if (form == null) {
        return;
    }
    // JS might change the page this form belongs to... so remember it now
    final Page page = form.getPage();
    IEventDispatcher<WicketEvent> eventDispatcher = WebClientSession.get().getWebClient().getEventDispatcher();
    if (eventDispatcher != null) {
        eventDispatcher.addEvent(new WicketEvent(WebClientSession.get().getWebClient(), new Runnable() {

            public void run() {
                handleEvent(type, target, comp, webModifiers, mouseLocation, absoluteMouseLocation, page);
            }
        }));
    } else {
        handleEvent(type, target, comp, webModifiers, mouseLocation, absoluteMouseLocation, page);
    }
    if (target != null) {
        generateResponse(target, page);
    }
}
Also used : WicketEvent(com.servoy.j2db.server.headlessclient.eventthread.WicketEvent) Page(org.apache.wicket.Page) MainPage(com.servoy.j2db.server.headlessclient.MainPage) ServoyForm(com.servoy.j2db.server.headlessclient.ServoyForm)

Example 5 with ServoyForm

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

the class StripHTMLTagsConverter method getTriggerJavaScript.

public static String getTriggerJavaScript(FormComponent<?> component, String value) {
    ServoyForm form = (ServoyForm) component.getForm();
    StringBuilder sb = new StringBuilder(100);
    // $NON-NLS-1$
    sb.append("javascript:document.getElementById('");
    sb.append(form.getHiddenField());
    // $NON-NLS-1$
    sb.append("').name=\'");
    sb.append(component.getInputName());
    // $NON-NLS-1$
    sb.append("';");
    // $NON-NLS-1$
    sb.append("document.getElementById('");
    sb.append(form.getHiddenField());
    // $NON-NLS-1$
    sb.append("').value=\'");
    // $NON-NLS-1$ //$NON-NLS-2$
    sb.append(Utils.stringReplace(value, "\'", "\\\'"));
    // $NON-NLS-1$
    sb.append("';");
    // $NON-NLS-1$
    sb.append("var f=document.getElementById('");
    sb.append(form.getJavascriptCssId());
    // $NON-NLS-1$
    sb.append("');");
    // $NON-NLS-1$
    sb.append("if (f.onsubmit != undefined) { if (f.onsubmit()==false) return false; }");
    // $NON-NLS-1$
    sb.append("f.submit();return false;");
    return sb.toString();
}
Also used : ServoyForm(com.servoy.j2db.server.headlessclient.ServoyForm)

Aggregations

ServoyForm (com.servoy.j2db.server.headlessclient.ServoyForm)6 PrependingStringBuffer (org.apache.wicket.util.string.PrependingStringBuffer)2 MainPage (com.servoy.j2db.server.headlessclient.MainPage)1 WicketEvent (com.servoy.j2db.server.headlessclient.eventthread.WicketEvent)1 Page (org.apache.wicket.Page)1