Skip to content
Snippets Groups Projects
Commit e5c26711 authored by srosse's avatar srosse
Browse files

OO-342: fix the tag (TextListCompenent) component which doesn't work with multipart/form

parent 689f59fc
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,9 @@ import org.olat.core.gui.UserRequest; ...@@ -28,7 +28,9 @@ import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.Component; import org.olat.core.gui.components.Component;
import org.olat.core.gui.components.form.flexible.elements.TextBoxListElement; import org.olat.core.gui.components.form.flexible.elements.TextBoxListElement;
import org.olat.core.gui.components.textboxlist.ResultMapProvider; import org.olat.core.gui.components.textboxlist.ResultMapProvider;
import org.olat.core.gui.components.textboxlist.TextBoxListComponent;
import org.olat.core.gui.translator.Translator; import org.olat.core.gui.translator.Translator;
import org.olat.core.util.StringHelper;
import org.olat.core.util.Util; import org.olat.core.util.Util;
/** /**
...@@ -63,7 +65,17 @@ public class TextBoxListElementImpl extends AbstractTextElement implements TextB ...@@ -63,7 +65,17 @@ public class TextBoxListElementImpl extends AbstractTextElement implements TextB
@Override @Override
public void evalFormRequest(UserRequest ureq) { public void evalFormRequest(UserRequest ureq) {
component.dispatchRequest(ureq); String inputId = TextBoxListComponent.INPUT_SUFFIX + getFormDispatchId();
String cmd = ureq.getParameter(inputId);
if(StringHelper.containsNonWhitespace(cmd)) {
component.dispatchRequest(ureq);
} else {
//this one handle multipart/form too
String submitValue = getRootForm().getRequestParameter(inputId);
if(StringHelper.containsNonWhitespace(submitValue)) {
((TextBoxListElementComponent)component).setCmd(ureq, submitValue);
}
}
} }
@Override @Override
......
...@@ -45,6 +45,7 @@ import org.olat.core.gui.translator.Translator; ...@@ -45,6 +45,7 @@ import org.olat.core.gui.translator.Translator;
import org.olat.core.logging.OLATRuntimeException; import org.olat.core.logging.OLATRuntimeException;
import org.olat.core.logging.OLog; import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing; import org.olat.core.logging.Tracing;
import org.olat.core.util.StringHelper;
/** /**
* Description:<br> * Description:<br>
...@@ -68,6 +69,7 @@ public abstract class TextBoxListComponent extends FormBaseComponentImpl { ...@@ -68,6 +69,7 @@ public abstract class TextBoxListComponent extends FormBaseComponentImpl {
// if changed, do so also in multiselect.js! // if changed, do so also in multiselect.js!
public static final String MORE_RESULTS_INDICATOR = "....."; public static final String MORE_RESULTS_INDICATOR = ".....";
public static final String INPUT_SUFFIX = "textboxlistinput";
private String inputHint; private String inputHint;
...@@ -147,14 +149,21 @@ public abstract class TextBoxListComponent extends FormBaseComponentImpl { ...@@ -147,14 +149,21 @@ public abstract class TextBoxListComponent extends FormBaseComponentImpl {
*/ */
@Override @Override
protected void doDispatchRequest(UserRequest ureq) { protected void doDispatchRequest(UserRequest ureq) {
String inputId = "textboxlistinput" + getFormDispatchId(); String inputId = "textboxlistinput" + getFormDispatchId();
String cmd = ureq.getParameter(inputId); String cmd = ureq.getParameter(inputId);
if(cmd == null){ if(cmd == null){
return; return;
} }
setCmd(ureq, cmd);
}
public void setCmd(UserRequest ureq, String cmd) {
if(!StringHelper.containsNonWhitespace(cmd)) {
return;
}
String[] splitted = cmd.split(","); String[] splitted = cmd.split(",");
ArrayList<String> cleanedItemValues = new ArrayList<String>(); List<String> cleanedItemValues = new ArrayList<String>();
for (String item : splitted) { for (String item : splitted) {
if (!StringUtils.isBlank(item)) if (!StringUtils.isBlank(item))
cleanedItemValues.add(item.trim()); cleanedItemValues.add(item.trim());
...@@ -176,7 +185,7 @@ public abstract class TextBoxListComponent extends FormBaseComponentImpl { ...@@ -176,7 +185,7 @@ public abstract class TextBoxListComponent extends FormBaseComponentImpl {
if (logger.isDebug()) if (logger.isDebug())
logger.debug("doDispatchRequest --> firing textBoxListEvent with current items: " + cleanedItemValues); logger.debug("doDispatchRequest --> firing textBoxListEvent with current items: " + cleanedItemValues);
fireEvent(ureq, new TextBoxListEvent(cleanedItemValues)); fireEvent(ureq, new TextBoxListEvent(cleanedItemValues));
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment