Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
CAL-1345 : allow to define placeholder in WebUI forum input text comp…
Browse files Browse the repository at this point in the history
…onent (#193)

This change allows to define a placeholder in WebUI component for form input text.
  • Loading branch information
Thomas Delhoménie committed Sep 25, 2018
1 parent a1a827e commit 5500706
Showing 1 changed file with 26 additions and 0 deletions.
Expand Up @@ -21,6 +21,7 @@

import java.io.Writer;

import org.apache.commons.lang.StringUtils;
import org.exoplatform.commons.serialization.api.annotations.Serialized;
import org.exoplatform.commons.utils.HTMLEntityEncoder;
import org.exoplatform.webui.application.WebuiRequestContext;
Expand Down Expand Up @@ -52,9 +53,20 @@ public class UIFormStringInput extends UIFormInputBase<String> {
*/
private int maxLength = 0;

/**
* placeholder of the text field
*/
private String placeholder = "";

public UIFormStringInput() {
}

public UIFormStringInput(String name, String bindingExpression, String value, String placeholder) {
super(name, bindingExpression, String.class);
this.value_ = value;
this.placeholder = placeholder;
}

public UIFormStringInput(String name, String bindingExpression, String value) {
super(name, bindingExpression, String.class);
this.value_ = value;
Expand All @@ -78,6 +90,15 @@ public int getMaxLength() {
return maxLength;
}

public String getPlaceholder() {
return placeholder;
}

public UIFormStringInput setPlaceholder(String placeholder) {
this.placeholder = placeholder;
return this;
}

public void decode(Object input, WebuiRequestContext context) {
String val = (String) input;
if ((val == null || val.length() == 0) && type_ == PASSWORD_TYPE)
Expand All @@ -97,6 +118,11 @@ public void processRender(WebuiRequestContext context) throws Exception {
w.write(" type=\"password\"");
else
w.write(" type=\"text\"");
if(StringUtils.isNotEmpty(getPlaceholder())) {
w.write(" placeholder=\"");
w.write(getPlaceholder());
w.write("\"");
}
w.write(" id=\"");
w.write(getId());
w.write("\"");
Expand Down

0 comments on commit 5500706

Please sign in to comment.