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;
}
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());
}
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());
}
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;
}
Aggregations