All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.butterfaces.component.html.HtmlMarkdown Maven / Gradle / Ivy
package org.butterfaces.component.html;
import org.butterfaces.component.html.feature.*;
import org.butterfaces.component.html.feature.*;
import javax.el.ValueExpression;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
import javax.faces.component.FacesComponent;
import javax.faces.component.html.HtmlInputTextarea;
import java.util.Collections;
import java.util.List;
@ResourceDependencies({
@ResourceDependency(library = "butterfaces-dist-css", name = "butterfaces-default.css", target = "head"),
@ResourceDependency(library = "butterfaces-dist-css", name = "butterfaces-markdown.css", target = "head"),
@ResourceDependency(library = "butterfaces-dist-js", name = "butterfaces-util-string.js", target = "head"),
@ResourceDependency(library = "butterfaces-dist-js", name = "butterfaces-util-object.js", target = "head"),
@ResourceDependency(library = "butterfaces-dist-bundle-dev-js", name = "butterfaces-third-party-jquery.js", target = "head"),
@ResourceDependency(library = "butterfaces-dist-bundle-dev-js", name = "butterfaces-third-party.js", target = "head"),
@ResourceDependency(library = "butterfaces-dist-js", name = "butterfaces-maxlength.jquery.js", target = "head"),
@ResourceDependency(library = "butterfaces-dist-js", name = "butterfaces-multiline-placeholder.jquery.js", target = "head"),
@ResourceDependency(library = "butterfaces-js", name = "butterfaces-01-baseClass.js", target = "head"),
@ResourceDependency(library = "butterfaces-js", name = "butterfaces-markdown.jquery.js", target = "head")
})
@FacesComponent(HtmlMarkdown.COMPONENT_TYPE)
public class HtmlMarkdown extends HtmlInputTextarea implements HtmlInputComponent, Placeholder, AutoFocus, Tooltip, Label, Readonly, MaxLength {
public static final String COMPONENT_TYPE = "org.butterfaces.component.markdown";
public static final String COMPONENT_FAMILY = "org.butterfaces.component.family";
public static final String RENDERER_TYPE = "org.butterfaces.component.renderkit.html_basic.MarkdownRenderer";
protected static final String PROPERTY_HIDE_LABEL = "hideLabel";
protected static final String PROPERTY_MAXLENGTH = "maxLength";
protected static final String PROPERTY_PLACEHOLDER = "placeholder";
protected static final String PROPERTY_HTML5_AUTO_FOCUS = "autoFocus";
protected static final String PROPERTY_LANGUAGE = "language";
protected static final String PROPERTY_VALIDATION_ERROR_PLACEMENT = "validationErrorPlacement";
public HtmlMarkdown() {
super();
this.setRendererType(RENDERER_TYPE);
}
@Override
public List getSupportedFacets() {
return Collections.emptyList();
}
@Override
public String getFamily() {
return COMPONENT_FAMILY;
}
@Override
public boolean isAutoFocus() {
final Object eval = this.getStateHelper().eval(PROPERTY_HTML5_AUTO_FOCUS);
return eval == null ? false : (Boolean) eval;
}
@Override
public void setAutoFocus(final boolean autoFocus) {
this.updateStateHelper(PROPERTY_HTML5_AUTO_FOCUS, autoFocus);
}
@Override
public boolean isHideLabel() {
final Object eval = this.getStateHelper().eval(PROPERTY_HIDE_LABEL);
return eval == null ? false : (Boolean) eval;
}
public void setHideLabel(final boolean hideLabel) {
this.updateStateHelper(PROPERTY_HIDE_LABEL, hideLabel);
}
public String getPlaceholder() {
return (String) this.getStateHelper().eval(PROPERTY_PLACEHOLDER);
}
public void setPlaceholder(final String placeholder) {
this.updateStateHelper(PROPERTY_PLACEHOLDER, placeholder);
}
public Integer getMaxLength() {
return (Integer) this.getStateHelper().eval(PROPERTY_MAXLENGTH);
}
public void setMaxLength(final Integer maxLength) {
this.updateStateHelper(PROPERTY_MAXLENGTH, maxLength);
}
public String getLanguage() {
final Object eval = this.getStateHelper().eval(PROPERTY_LANGUAGE);
return eval == null ? "en" : (String) eval;
}
public void setLanguage(String language) {
this.updateStateHelper(PROPERTY_LANGUAGE, language);;
}
@Override
public String getValidationErrorPlacement() {
return (String) this.getStateHelper().eval(PROPERTY_VALIDATION_ERROR_PLACEMENT, "");
}
public void setValidationErrorPlacement(final String validationErrorPlacement) {
this.updateStateHelper(PROPERTY_VALIDATION_ERROR_PLACEMENT, validationErrorPlacement);
}
private void updateStateHelper(final String propertyName, final Object value) {
this.getStateHelper().put(propertyName, value);
final ValueExpression ve = this.getValueExpression(propertyName);
if (ve != null) {
ve.setValue(this.getFacesContext().getELContext(), value);
}
}
}