Search in sources :

Example 1 with TextBoxListElementImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl in project openolat by klemens.

the class FormUIFactory method addTextBoxListElement.

/**
 * adds a component to choose text elements with autocompletion
 * see also TextBoxListComponent
 * @param name
 * @param i18nLabel
 * @param inputHint if empty ("") a default will be used
 * @param initialItems
 * @param formLayout
 * @param translator
 * @return
 */
public TextBoxListElement addTextBoxListElement(String name, final String i18nLabel, String inputHint, Map<String, String> initialItems, FormItemContainer formLayout, Translator translator) {
    TextBoxListElement tbe = new TextBoxListElementImpl(name, inputHint, initialItems, translator);
    setLabelIfNotNull(i18nLabel, tbe);
    formLayout.add(tbe);
    return tbe;
}
Also used : TextBoxListElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl) TextBoxListElement(org.olat.core.gui.components.form.flexible.elements.TextBoxListElement)

Example 2 with TextBoxListElementImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl in project openolat by klemens.

the class TextBoxListRenderer method renderEnabledMode.

/**
 * renders the component in Enabled / editable mode
 *
 * @param tblComponent
 *            the component to render
 * @param sb
 *            the StringOutput
 * @param translator
 */
private void renderEnabledMode(TextBoxListComponent tblComponent, StringOutput sb, Translator translator) {
    TextBoxListElementImpl te = ((TextBoxListElementComponent) tblComponent).getTextElementImpl();
    Form rootForm = te.getRootForm();
    String dispatchId = tblComponent.getFormDispatchId();
    String initialValue = tblComponent.getItemsAsString();
    sb.append("<input type='text' id='textboxlistinput").append(dispatchId).append("'").append(" name='textboxlistinput").append(dispatchId).append("'");
    if (te.hasFocus()) {
        sb.append(" autofocus");
    }
    sb.append(" value='").append(initialValue).append("'");
    Translator myTrans = Util.createPackageTranslator(this.getClass(), translator.getLocale());
    sb.append(" placeholder='").append(Formatter.escapeDoubleQuotes(myTrans.translate("add.enter"))).append("' class='o_textbox'/>\n");
    String o_ffEvent = FormJSHelper.getJSFnCallFor(rootForm, dispatchId, 2);
    // generate the JS-code for the bootstrap tagsinput
    sb.append(FormJSHelper.getJSStart()).append("jQuery(function(){\n").append("  jQuery('#textboxlistinput").append(dispatchId).append("').tagsinput({\n");
    if (tblComponent.getProvider() != null) {
        sb.append("    typeahead: {\n").append("      source: function() {").append("      	return jQuery.getJSON('").append(tblComponent.getMapperUri()).append("');").append("      }").append("    }\n");
    }
    sb.append("  });\n").append("  jQuery('#textboxlistinput").append(dispatchId).append("').on('itemAdded itemRemoved',function(event) {\n").append(o_ffEvent).append(";\n").append("  });\n").append("});\n").append(FormJSHelper.getJSEnd());
}
Also used : TextBoxListElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl) Form(org.olat.core.gui.components.form.flexible.impl.Form) Translator(org.olat.core.gui.translator.Translator) TextBoxListElementComponent(org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementComponent)

Example 3 with TextBoxListElementImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl in project OpenOLAT by OpenOLAT.

the class TextBoxListRenderer method renderEnabledMode.

/**
 * renders the component in Enabled / editable mode
 *
 * @param tblComponent
 *            the component to render
 * @param sb
 *            the StringOutput
 * @param translator
 */
private void renderEnabledMode(TextBoxListComponent tblComponent, StringOutput sb, Translator translator) {
    TextBoxListElementImpl te = ((TextBoxListElementComponent) tblComponent).getTextElementImpl();
    Form rootForm = te.getRootForm();
    String dispatchId = tblComponent.getFormDispatchId();
    String initialValue = tblComponent.getItemsAsString();
    sb.append("<input type='text' id='textboxlistinput").append(dispatchId).append("'").append(" name='textboxlistinput").append(dispatchId).append("'");
    if (te.hasFocus()) {
        sb.append(" autofocus");
    }
    sb.append(" value='").append(initialValue).append("'");
    Translator myTrans = Util.createPackageTranslator(this.getClass(), translator.getLocale());
    sb.append(" placeholder='").append(Formatter.escapeDoubleQuotes(myTrans.translate("add.enter"))).append("' class='o_textbox'/>\n");
    String o_ffEvent = FormJSHelper.getJSFnCallFor(rootForm, dispatchId, 2);
    // generate the JS-code for the bootstrap tagsinput
    sb.append(FormJSHelper.getJSStart()).append("jQuery(function(){\n").append("  jQuery('#textboxlistinput").append(dispatchId).append("').tagsinput({\n");
    if (tblComponent.getProvider() != null) {
        sb.append("    typeahead: {\n").append("      source: function() {").append("      	return jQuery.getJSON('").append(tblComponent.getMapperUri()).append("');").append("      }").append("    }\n");
    }
    sb.append("  });\n").append("  jQuery('#textboxlistinput").append(dispatchId).append("').on('itemAdded itemRemoved',function(event) {\n").append(o_ffEvent).append(";\n").append("  });\n").append("});\n").append(FormJSHelper.getJSEnd());
}
Also used : TextBoxListElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl) Form(org.olat.core.gui.components.form.flexible.impl.Form) Translator(org.olat.core.gui.translator.Translator) TextBoxListElementComponent(org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementComponent)

Example 4 with TextBoxListElementImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl in project OpenOLAT by OpenOLAT.

the class FormUIFactory method addTextBoxListElement.

/**
 * adds a component to choose text elements with autocompletion
 * see also TextBoxListComponent
 * @param name
 * @param i18nLabel
 * @param inputHint if empty ("") a default will be used
 * @param initialItems
 * @param formLayout
 * @param translator
 * @return
 */
public TextBoxListElement addTextBoxListElement(String name, final String i18nLabel, String inputHint, Map<String, String> initialItems, FormItemContainer formLayout, Translator translator) {
    TextBoxListElement tbe = new TextBoxListElementImpl(name, inputHint, initialItems, translator);
    setLabelIfNotNull(i18nLabel, tbe);
    formLayout.add(tbe);
    return tbe;
}
Also used : TextBoxListElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl) TextBoxListElement(org.olat.core.gui.components.form.flexible.elements.TextBoxListElement)

Aggregations

TextBoxListElementImpl (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementImpl)4 TextBoxListElement (org.olat.core.gui.components.form.flexible.elements.TextBoxListElement)2 Form (org.olat.core.gui.components.form.flexible.impl.Form)2 TextBoxListElementComponent (org.olat.core.gui.components.form.flexible.impl.elements.TextBoxListElementComponent)2 Translator (org.olat.core.gui.translator.Translator)2