Search in sources :

Example 1 with HtmlInputTextarea

use of javax.faces.component.html.HtmlInputTextarea in project liferay-faces-alloy by liferay.

the class OutputRemainingChars method getMaxLength.

@Override
public Integer getMaxLength() {
    Integer maxLength = super.getMaxLength();
    // try to get the maxlength from the associated input component.
    if (maxLength == null) {
        String forComponent = getFor();
        if (forComponent == null) {
            logger.error("getMaxLength: Please specify a 'for' attribute for the outputRemainingChars component.");
        } else {
            UIComponent inputComponent = findComponent(forComponent);
            if (inputComponent != null) {
                if (inputComponent instanceof HtmlInputText) {
                    HtmlInputText htmlInputText = (HtmlInputText) inputComponent;
                    maxLength = htmlInputText.getMaxlength();
                } else if (inputComponent instanceof HtmlInputTextarea) {
                    HtmlInputTextarea htmlInputTextarea = (HtmlInputTextarea) inputComponent;
                    Object maxLengthObject = htmlInputTextarea.getAttributes().get("maxlength");
                    if (maxLengthObject != null) {
                        maxLength = Integer.parseInt(maxLengthObject.toString());
                    }
                }
            }
        }
    }
    return maxLength;
}
Also used : HtmlInputTextarea(javax.faces.component.html.HtmlInputTextarea) UIComponent(javax.faces.component.UIComponent) HtmlInputText(javax.faces.component.html.HtmlInputText)

Example 2 with HtmlInputTextarea

use of javax.faces.component.html.HtmlInputTextarea in project empire-db by apache.

the class TextAreaInputControl method createInputComponents.

@Override
protected void createInputComponents(UIComponent parent, InputInfo ii, FacesContext context, List<UIComponent> compList) {
    // check params
    if (!compList.isEmpty())
        throw new InvalidArgumentException("compList", compList);
    // create
    HtmlInputTextarea input = InputControlManager.createComponent(context, this.inputComponentClass);
    // once
    copyAttributes(parent, ii, input);
    // cols
    int cols = getFormatInteger(ii, FORMAT_COLS, FORMAT_COLS_ATTRIBUTE);
    if (cols > 0)
        input.setCols(cols);
    // rows
    int rows = getFormatInteger(ii, FORMAT_ROWS, FORMAT_ROWS_ATTRIBUTE);
    if (rows > 0)
        input.setRows(rows);
    // add
    compList.add(input);
    // update
    updateInputState(compList, ii, context, context.getCurrentPhaseId());
}
Also used : InvalidArgumentException(org.apache.empire.exceptions.InvalidArgumentException) HtmlInputTextarea(javax.faces.component.html.HtmlInputTextarea)

Example 3 with HtmlInputTextarea

use of javax.faces.component.html.HtmlInputTextarea in project empire-db by apache.

the class TextAreaInputControl method updateInputState.

@Override
protected void updateInputState(List<UIComponent> compList, InputInfo ii, FacesContext context, PhaseId phaseId) {
    UIComponent comp = compList.get(0);
    if (!(comp instanceof HtmlInputTextarea)) {
        throw new UnexpectedReturnValueException(comp.getClass().getName(), "compList.get(0)");
    }
    HtmlInputTextarea input = (HtmlInputTextarea) comp;
    // disabled
    DisabledType disabled = ii.getDisabled();
    if (disabled != null) {
        input.setReadonly((disabled == DisabledType.READONLY));
        input.setDisabled((disabled == DisabledType.DISABLED));
    }
    // Set Value
    if (phaseId == PhaseId.RENDER_RESPONSE) {
        // style
        addRemoveDisabledStyle(input, (disabled != null && disabled != DisabledType.NO));
        addRemoveInvalidStyle(input, ii.hasError());
        // set value
        setInputValue(input, ii);
    }
}
Also used : UnexpectedReturnValueException(org.apache.empire.exceptions.UnexpectedReturnValueException) HtmlInputTextarea(javax.faces.component.html.HtmlInputTextarea) UIComponent(javax.faces.component.UIComponent)

Aggregations

HtmlInputTextarea (javax.faces.component.html.HtmlInputTextarea)3 UIComponent (javax.faces.component.UIComponent)2 HtmlInputText (javax.faces.component.html.HtmlInputText)1 InvalidArgumentException (org.apache.empire.exceptions.InvalidArgumentException)1 UnexpectedReturnValueException (org.apache.empire.exceptions.UnexpectedReturnValueException)1