Example usage for com.google.gwt.http.client URL encode

List of usage examples for com.google.gwt.http.client URL encode

Introduction

In this page you can find the example usage for com.google.gwt.http.client URL encode.

Prototype

public static String encode(String decodedURL) 

Source Link

Document

Returns a string where all characters that are not valid for a complete URL have been escaped.

Usage

From source file:org.opentaps.gwt.common.voip.client.RedirectToCallingParty.java

License:Open Source License

protected void init() {
    try {/*from   w  w w.j av  a2  s. com*/
        //add random number avoid cache page
        RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL
                .encode(GWT.getHostPageBaseURL() + checkFrequencySecondsUrl + "?now=" + new Date().getTime()));
        builder.sendRequest(null, new RequestCallback() {
            public void onError(Request request, Throwable exception) {
                // display error message
                UtilUi.errorMessage(exception.toString());
            }

            public void onResponseReceived(Request request, Response response) {
                if (response.getStatusCode() == Response.SC_OK) {
                    String returnText = response.getText();
                    if (!returnText.equals("")) {
                        setCheckInBoundTimer(Integer.parseInt(returnText));
                    }
                }
            }

        });
    } catch (RequestException e) {
        // display error message
        UtilUi.errorMessage(e.toString());
    }
}

From source file:org.opentaps.gwt.common.voip.client.RedirectToCallingParty.java

License:Open Source License

/**
 * Sets the check in-bound timer./*  w  ww . ja  v  a 2s  .co  m*/
 * @param seconds the number of seconds between checking in-bound calls
 */
private void setCheckInBoundTimer(int seconds) {
    Timer timer = new Timer() {
        @Override
        public void run() {
            try {
                //add random number avoid cache page
                RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
                        URL.encode(GWT.getHostPageBaseURL() + remoteUrl + "?now=" + new Date().getTime()));
                builder.sendRequest(null, new RequestCallback() {
                    public void onError(Request request, Throwable exception) {
                        // display error message
                        UtilUi.errorMessage(exception.toString());
                    }

                    public void onResponseReceived(Request request, Response response) {
                        // when get correct response, clear the div insideHeadertext and display call in link.
                        if (response.getStatusCode() == Response.SC_OK) {
                            String returnText = response.getText();
                            if (!returnText.equals("")) {
                                RootPanel.get(voipkNotificationDiv).clear();
                                OpentapsConfig config = new OpentapsConfig();
                                HTML callInTips = new HTML(UtilUi.MSG
                                        .callInDisplayMessage(config.getCallInEventIcon(), returnText));
                                RootPanel.get(voipkNotificationDiv).add(callInTips);
                            }
                        }
                    }
                });
            } catch (RequestException e) {
                // display error message
                UtilUi.errorMessage(e.toString());
            }
        }
    };
    // Schedule the timer for every second
    timer.scheduleRepeating(seconds * 1000);
}

From source file:org.openxdata.designer.client.controller.FormDesignerController.java

/**
 * Loads a form from the server./*w ww .  j  a  v a 2s.c o  m*/
 */
private void loadForm() {
    FormUtil.dlg.setText(messages.openingForm());
    FormUtil.dlg.center();

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            String url = FormUtil.getHostPageBaseURL();
            url += FormUtil.getFormDefDownloadUrlSuffix();
            url += FormUtil.getFormIdName() + "=" + formId;

            RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

            try {
                prepareFormForLoading(builder);
            } catch (RequestException ex) {
                FormUtil.displayException(ex);
            }

        }
    });
}

From source file:org.openxdata.designer.client.controller.FormDesignerController.java

public void saveForm(String xformXml, String layoutXml, String languageXml, String javaScriptSrc) {
    String url = FormUtil.getHostPageBaseURL();
    url += FormUtil.getFormDefUploadUrlSuffix();
    url += FormUtil.getFormIdName() + "=" + this.formId;

    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));

    try {// w w  w. j ava  2 s  .co m
        String xml = xformXml;
        if (layoutXml != null && layoutXml.trim().length() > 0)
            xml += OpenXdataConstants.OPENXDATA_FORMDEF_LAYOUT_XML_SEPARATOR + layoutXml;

        if (languageXml != null && languageXml.trim().length() > 0)
            xml += OpenXdataConstants.OPENXDATA_FORMDEF_LOCALE_XML_SEPARATOR + languageXml;

        if (javaScriptSrc != null && javaScriptSrc.trim().length() > 0)
            xml += OpenXdataConstants.OPENXDATA_FORMDEF_JAVASCRIPT_SRC_SEPARATOR + javaScriptSrc;

        builder.sendRequest(xml, new RequestCallback() {
            public void onResponseReceived(Request request, Response response) {

                if (response.getStatusCode() != Response.SC_OK) {
                    FormUtil.displayReponseError(response);
                    return;
                }

                FormUtil.dlg.hide();
                Window.alert(messages.formSaveSuccess());
            }

            public void onError(Request request, Throwable exception) {
                FormUtil.displayException(exception);
            }
        });
    } catch (RequestException ex) {
        FormUtil.displayException(ex);
    }
}

From source file:org.openxdata.designer.client.controller.FormDesignerController.java

public void saveLocaleText(String languageXml) {
    String url = FormUtil.getHostPageBaseURL();
    url += FormUtil.getFormDefUploadUrlSuffix();
    url += FormUtil.getFormIdName() + "=" + this.formId;
    url += "&localeXml=true";

    RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));

    try {//from w ww. j  a  va  2s  .c o  m
        builder.sendRequest(languageXml, new RequestCallback() {
            public void onResponseReceived(Request request, Response response) {

                if (response.getStatusCode() != Response.SC_OK) {
                    FormUtil.displayReponseError(response);
                    return;
                }

                FormUtil.dlg.hide();
                Window.alert(messages.formSaveSuccess());
            }

            public void onError(Request request, Throwable exception) {
                FormUtil.displayException(exception);
            }
        });
    } catch (RequestException ex) {
        FormUtil.displayException(ex);
    }
}

From source file:org.openxdata.designer.client.controller.FormDesignerController.java

private void refreshForm() {
    String url = FormUtil.getHostPageBaseURL();
    url += FormUtil.getFormDefRefreshUrlSuffix();
    url += FormUtil.getFormIdName() + "=" + this.formId;

    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

    try {//from www . ja  v  a 2  s. c om
        builder.sendRequest(null, new RequestCallback() {
            public void onResponseReceived(Request request, Response response) {

                if (response.getStatusCode() != Response.SC_OK) {
                    FormUtil.displayReponseError(response);
                    return;
                }

                String xml = response.getText();
                if (xml == null || xml.length() == 0) {
                    Window.alert(messages.noDataFound());
                    return;
                }

                centerPanel.setXformsSource(xml, false);
                refreshFormDeffered();
            }

            public void onError(Request request, Throwable exception) {
                FormUtil.displayException(exception);
            }
        });
    } catch (RequestException ex) {
        FormUtil.displayException(ex);
    }
}

From source file:org.openxdata.runner.client.controller.FormRunnerController.java

public void loadForm(int frmId, int entyId) {
    this.formId = frmId;
    this.entityId = entyId;

    FormUtil.dlg.setText(i18n.openingForm());
    FormUtil.dlg.center();/*from   w w w . jav a2 s .c om*/

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {

            String url = FormUtil.getHostPageBaseURL();
            url += FormUtil.getEntityFormDefDownloadUrlSuffix();
            url += FormUtil.getFormIdName() + "=" + formId;
            url += "&" + FormUtil.getEntityIdName() + "=" + entityId;

            RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

            try {
                builder.sendRequest(null, new RequestCallback() {
                    public void onResponseReceived(Request request, Response response) {

                        if (response.getStatusCode() != Response.SC_OK) {
                            FormUtil.displayReponseError(response);
                            return;
                        }

                        String xml = response.getText();
                        if (xml == null || xml.length() == 0) {
                            FormUtil.dlg.hide();
                            Window.alert(i18n.noDataFound());
                            return;
                        }

                        xformXml = null;
                        layoutXml = null;
                        javaScriptSrc = null;

                        int pos = xml.indexOf(OpenXdataConstants.OPENXDATA_FORMDEF_LAYOUT_XML_SEPARATOR);
                        int pos2 = xml.indexOf(OpenXdataConstants.OPENXDATA_FORMDEF_JAVASCRIPT_SRC_SEPARATOR);
                        if (pos > 0) {
                            xformXml = xml.substring(0, pos);
                            layoutXml = xml.substring(
                                    pos + OpenXdataConstants.OPENXDATA_FORMDEF_LAYOUT_XML_SEPARATOR.length(),
                                    pos2 > 0 ? pos2 : xml.length());

                            if (pos2 > 0)
                                javaScriptSrc = xml.substring(
                                        pos2 + OpenXdataConstants.OPENXDATA_FORMDEF_JAVASCRIPT_SRC_SEPARATOR
                                                .length(),
                                        xml.length());

                            openForm();
                        } else {
                            FormUtil.dlg.hide();
                            Window.alert(i18n.noFormLayout());
                        }
                    }

                    public void onError(Request request, Throwable exception) {
                        FormUtil.displayException(exception);
                    }
                });
            } catch (RequestException ex) {
                FormUtil.displayException(ex);
            }
        }
    });
}

From source file:org.openxdata.runner.client.controller.FormRunnerController.java

public void onSubmit(String xml) {

    FormUtil.dlg.setText(i18n.submitting());
    FormUtil.dlg.center();//ww  w .  j a  v  a 2s.  c  o  m

    final String submitXml = xml;

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {
        public void execute() {
            String url = FormUtil.getHostPageBaseURL();
            url += FormUtil.getFormDataUploadUrlSuffix();

            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(url));

            try {
                builder.sendRequest(submitXml, new RequestCallback() {
                    public void onResponseReceived(Request request, Response response) {
                        FormUtil.dlg.hide();

                        if (response.getStatusCode() != Response.SC_OK) {
                            FormUtil.displayReponseError(response);
                            return;
                        }

                        if (response.getStatusCode() == Response.SC_OK) {
                            if (FormUtil.showSubmitSuccessMsg())
                                Window.alert(i18n.formSubmitSuccess());

                            String url = FormUtil.getHostPageBaseURL();
                            url += FormUtil.getAfterSubmitUrlSuffix();

                            if (FormUtil.appendEntityIdAfterSubmit()) {
                                url += FormUtil.getEntityIdName();
                                if (entityId > 0)
                                    url += "=" + entityId;
                                else if (entityId == 0 && response.getText().trim().length() > 0)
                                    url += "=" + response.getText();
                            }

                            Window.Location.replace(url);
                        } else
                            FormUtil.displayReponseError(response);
                    }

                    public void onError(Request request, Throwable exception) {
                        FormUtil.displayException(exception);
                    }
                });
            } catch (RequestException ex) {
                FormUtil.displayException(ex);
            }
        }
    });
}

From source file:org.openxdata.sharedlib.client.view.FormRunnerView.java

protected int loadWidget(Element node, HashMap<Integer, RuntimeWidgetWrapper> widgets,
        List<RuntimeWidgetWrapper> externalSourceWidgets, List<QuestionDef> validationQtns,
        List<RuntimeWidgetWrapper> validationWidgets, HashMap<QuestionDef, RuntimeWidgetWrapper> qtnWidgetMap,
        HashMap<QuestionDef, List<QuestionDef>> calcQtnMappings) {
    RuntimeWidgetWrapper parentWrapper = null;

    String left = node.getAttribute(WidgetEx.WIDGET_PROPERTY_LEFT);
    String top = node.getAttribute(WidgetEx.WIDGET_PROPERTY_TOP);
    String s = node.getAttribute(WidgetEx.WIDGET_PROPERTY_WIDGETTYPE);
    int tabIndex = (node.getAttribute(WidgetEx.WIDGET_PROPERTY_TABINDEX) != null
            ? Integer.parseInt(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TABINDEX))
            : 0);/*from   w w  w  . jav  a  2 s  .co  m*/

    QuestionDef questionDef = null;
    String binding = node.getAttribute(WidgetEx.WIDGET_PROPERTY_BINDING);
    String parentBinding = node.getAttribute(WidgetEx.WIDGET_PROPERTY_PARENTBINDING);
    if (binding != null && binding.trim().length() > 0) {
        questionDef = formDef.getQuestion(binding);
        if (questionDef != null)
            questionDef.setAnswer(questionDef.getDefaultValue()); //Just incase we are refreshing and had already set the answer
    }

    RuntimeWidgetWrapper wrapper = null;
    boolean wrapperSet = false;
    Widget widget = null;
    if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_RADIOBUTTON)) {
        widget = new RadioButtonWidget(parentBinding, node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT));

        if (parentBindingWidgetMap.get(parentBinding) == null)
            wrapperSet = true;

        parentWrapper = getParentBindingWrapper(widget, parentBinding);
        ((RadioButton) widget).setTabIndex(tabIndex);

        if (wrapperSet) {
            wrapper = parentWrapper;
            questionDef = formDef.getQuestion(parentBinding);
        }
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_CHECKBOX)) {
        widget = new CheckBoxWidget(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT));
        if (parentBindingWidgetMap.get(parentBinding) == null)
            wrapperSet = true;

        parentWrapper = getParentBindingWrapper(widget, parentBinding);
        ((CheckBox) widget).setTabIndex(tabIndex);

        String defaultValue = parentWrapper.getQuestionDef().getDefaultValue();
        if (defaultValue != null && defaultValue.contains(binding))
            ((CheckBox) widget).setValue(true);

        if (wrapperSet) {
            wrapper = parentWrapper;
            questionDef = formDef.getQuestion(parentBinding);
        }

    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_BUTTON)) {
        widget = new Button(node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT));
        ((Button) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_LISTBOX)) {
        widget = new ListBoxWidget(false);
        ((ListBox) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_TEXTAREA)) {
        widget = new TextArea();
        ((TextArea) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_DATEPICKER)) {
        widget = new DatePickerWidget();
        ((DatePickerEx) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_DATETIME)) {
        widget = new DateTimeWidget();
        ((DateTimeWidget) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_TIME)) {
        widget = new TimeWidget();
        ((TimeWidget) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_TEXTBOX)) {
        widget = new TextBox();
        if (questionDef != null && (questionDef.getDataType() == QuestionType.NUMERIC
                || questionDef.getDataType() == QuestionType.DECIMAL))
            FormUtil.allowNumericOnly((TextBox) widget, questionDef.getDataType() == QuestionType.DECIMAL);
        ((TextBox) widget).setTabIndex(tabIndex);
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_LABEL)) {
        String text = node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT);
        widget = new Label(text);

        int pos1 = text.indexOf("${");
        int pos2 = text.indexOf("}$");
        if (pos1 > -1 && pos2 > -1 && (pos2 > pos1)) {
            String varname = text.substring(pos1 + 2, pos2);
            labelText.put((Label) widget, text);
            labelReplaceText.put((Label) widget, "${" + varname + "}$");

            ((Label) widget).setText(text.replace("${" + varname + "}$", ""));
            if (varname.startsWith("/" + formDef.getBinding() + "/"))
                varname = varname.substring(("/" + formDef.getBinding() + "/").length(), varname.length());

            QuestionDef qtnDef = formDef.getQuestion(varname);
            List<Label> labels = labelMap.get(qtnDef);
            if (labels == null) {
                labels = new ArrayList<Label>();
                labelMap.put(qtnDef, labels);
            }
            labels.add((Label) widget);
        }
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_GROUPBOX)
            || s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_REPEATSECTION)) {
        RepeatQtnsDef repeatQtnsDef = null;
        if (questionDef != null)
            repeatQtnsDef = questionDef.getRepeatQtnsDef();

        boolean repeated = false;
        String value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_REPEATED);
        if (value != null && value.trim().length() > 0)
            repeated = (value.equals(WidgetEx.REPEATED_TRUE_VALUE));

        widget = new RuntimeGroupWidget(images, formDef, repeatQtnsDef, this, repeated);
        ((RuntimeGroupWidget) widget).loadWidgets(formDef, node.getChildNodes(), externalSourceWidgets,
                calcQtnMappings, calcWidgetMap, filtDynOptWidgetMap);
        copyLabelMap(((RuntimeGroupWidget) widget).getLabelMap());
        copyLabelText(((RuntimeGroupWidget) widget).getLabelText());
        copyLabelReplaceText(((RuntimeGroupWidget) widget).getLabelReplaceText());
        copyCheckBoxGroupMap(((RuntimeGroupWidget) widget).getCheckBoxGroupMap());
        copyCalcWidgetMap(((RuntimeGroupWidget) widget).getCalcWidgetMap());
        copyFiltDynOptWidgetMap(((RuntimeGroupWidget) widget).getFiltDynOptWidgetMap());
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_IMAGE)) {
        widget = new Image();
        String xpath = binding;
        if (!xpath.startsWith(formDef.getBinding()))
            xpath = "/" + formDef.getBinding() + "/" + binding;
        ((Image) widget).setUrl(
                URL.encode(FormUtil.getMultimediaUrl() + "?formId=" + formDef.getId() + "&xpath=" + xpath));
    } else if (s.equalsIgnoreCase(WidgetEx.WIDGET_TYPE_VIDEO_AUDIO) && questionDef != null) {
        String answer = questionDef.getAnswer();
        if (answer != null && answer.trim().length() != 0) {
            widget = new HTML();
            if (binding != null && binding.trim().length() > 0) {
                String xpath = binding;
                if (!xpath.startsWith(formDef.getBinding()))
                    xpath = "/" + formDef.getBinding() + "/" + binding;

                String extension = "";
                String contentType = "&contentType=video/3gpp";
                if (questionDef.getDataType() == QuestionType.AUDIO)
                    contentType = "&contentType=audio/3gpp";

                contentType += "&name=" + questionDef.getBinding() + ".3gp";

                ((HTML) widget).setHTML("<a href="
                        + URL.encode(FormUtil.getMultimediaUrl() + extension + "?formId=" + formDef.getId()
                                + "&xpath=" + xpath + contentType)
                        + ">" + node.getAttribute(WidgetEx.WIDGET_PROPERTY_TEXT) + "</a>");
            }
        }
    } else
        return tabIndex;

    if (!wrapperSet) {
        wrapper = new RuntimeWidgetWrapper(widget, images.error(), this);

        if (parentWrapper != null) { //Check box or radio button
            if (!parentWrapper.getQuestionDef().isVisible())
                wrapper.setVisible(false);
            if (!parentWrapper.getQuestionDef().isEnabled())
                wrapper.setEnabled(false);
            if (parentWrapper.getQuestionDef().isLocked())
                wrapper.setLocked(true);
        }
    }

    boolean loadWidget = true;

    String value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_HELPTEXT);
    if (value != null && value.trim().length() > 0)
        wrapper.setTitle(value);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_WIDTH);
    if (value != null && value.trim().length() > 0)
        wrapper.setWidth(value);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_HEIGHT);
    if (value != null && value.trim().length() > 0)
        wrapper.setHeight(value);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_EXTERNALSOURCE);
    if (value != null && value.trim().length() > 0)
        wrapper.setExternalSource(value);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_DISPLAYFIELD);
    if (value != null && value.trim().length() > 0)
        wrapper.setDisplayField(value);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_FILTERFIELD);
    if (value != null && value.trim().length() > 0)
        wrapper.setFilterField(value);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_ID);
    if (value != null && value.trim().length() > 0)
        wrapper.setId(value);

    if (questionDef != null) {
        if (questionDef.getDataType() == QuestionType.LIST_EXCLUSIVE_DYNAMIC) {
            questionDef.setOptions(null); //may have been set by the preview
            if (wrapper.getFilterField() != null && wrapper.getFilterField().trim().length() > 0)
                filtDynOptWidgetMap.put(questionDef, wrapper);
        }

        wrapper.setQuestionDef(questionDef, false);
        ValidationRule validationRule = formDef.getValidationRule(questionDef);
        wrapper.setValidationRule(validationRule);
        if (validationRule != null && questionDef.getDataType() == QuestionType.REPEAT)
            questionDef.setAnswer("0");

        if (validationQtns.contains(questionDef) && isValidationWidget(wrapper)) {
            validationWidgetsMap.put(wrapper, new ArrayList<RuntimeWidgetWrapper>());
            qtnWidgetMap.put(questionDef, wrapper);
        }

        if (validationRule != null && isValidationWidget(wrapper))
            validationWidgets.add(wrapper);
    }

    if (parentBinding != null)
        wrapper.setParentBinding(parentBinding);

    if (binding != null)
        wrapper.setBinding(binding);

    if (parentWrapper != null)
        parentWrapper.addChildWidget(wrapper);

    value = node.getAttribute(WidgetEx.WIDGET_PROPERTY_VALUEFIELD);
    if (value != null && value.trim().length() > 0) {
        wrapper.setValueField(value);

        if (externalSourceWidgets != null && wrapper.getExternalSource() != null
                && wrapper.getDisplayField() != null && (wrapper.getWrappedWidget() instanceof TextBox
                        || wrapper.getWrappedWidget() instanceof ListBox)
                && questionDef != null) {

            if (!(questionDef.getDataType() == QuestionType.LIST_EXCLUSIVE
                    || questionDef.getDataType() == QuestionType.LIST_MULTIPLE)) {
                questionDef.setDataType(QuestionType.LIST_EXCLUSIVE);
            }

            externalSourceWidgets.add(wrapper);
            loadWidget = false;

            wrapper.addSuggestBoxChangeEvent();
        }
    }

    if (loadWidget)
        wrapper.loadQuestion();

    wrapper.setExternalSourceDisplayValue();

    WidgetEx.loadLabelProperties(node, wrapper);

    wrapper.setTabIndex(tabIndex);

    if (tabIndex > 0)
        widgets.put(new Integer(tabIndex), wrapper);
    else
        selectedPanel.add(wrapper);

    FormUtil.setWidgetPosition(wrapper, left, top);

    if (widget instanceof Button && binding != null) {
        if (binding.equals("submit")) {
            ((Button) widget).addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    submit();
                }
            });
        } else if (binding.equals("cancel")) {
            ((Button) widget).addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent event) {
                    onCancel();
                }
            });
        }
    }

    if (wrapper.isEditable() && questionDef != null)
        updateCalcWidgetMapping(wrapper, calcQtnMappings, calcWidgetMap);

    return tabIndex;
}

From source file:org.openxdata.sharedlib.client.view.FormRunnerView.java

/**
 * Fills a widget with a list of possible values/answers from a source 
 * external to the xform. e.g database,web services, etc.
 * // ww w.ja  v a 2  s . c o m
 * @param widget the widget whose possible answers to fill.
 * @param filterValue the filter value for those that are filtered.
 */
private void fillExternalSourceWidget(final RuntimeWidgetWrapper widget, final String filterValue) {

    String url = FormUtil.getHostPageBaseURL();
    url += FormUtil.getExternalSourceUrlSuffix();
    url += WidgetEx.WIDGET_PROPERTY_EXTERNALSOURCE + "=" + widget.getExternalSource();
    url += "&" + WidgetEx.WIDGET_PROPERTY_DISPLAYFIELD + "=" + widget.getDisplayField();
    url += "&" + WidgetEx.WIDGET_PROPERTY_VALUEFIELD + "=" + widget.getValueField();

    String filterField = widget.getFilterField();
    if (filterField != null && filterField.trim().length() > 0) {

        if (filtDynOptWidgetMap.get(widget.getQuestionDef()) != null
                && (filterValue == null || filterValue.trim().length() == 0)) {
            fillNextExternalSourceWidget();
            return;
        }

        url += "&FilterField=" + filterField + "&FilterValue=";

        if (filterValue == null)
            url += "IS NULL";
        else
            url += filterValue;
    }

    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));

    try {
        builder.sendRequest(null, new RequestCallback() {
            public void onResponseReceived(Request request, Response response) {
                String text = response.getText();
                if (filterValue == null) {
                    //loading for the first time
                    fillWidgetValues(text);
                    fillNextExternalSourceWidget();
                } else {
                    //loading later after filter.
                    fillWidgetValues(text, widget);
                    onValueChanged(widget.getQuestionDef());
                }
            }

            public void onError(Request request, Throwable exception) {
                FormUtil.displayException(exception);

                if (filterValue == null)
                    fillNextExternalSourceWidget();
                else
                    onValueChanged(widget.getQuestionDef());
            }
        });
    } catch (RequestException ex) {
        FormUtil.displayException(ex);

        if (filterValue == null)
            fillNextExternalSourceWidget();
        else
            onValueChanged(widget.getQuestionDef());
    }
}