Search in sources :

Example 1 with InputSourceCode

use of com.liferay.faces.alloy.component.inputsourcecode.InputSourceCode in project liferay-faces-alloy by liferay.

the class InputSourceCodeRenderer method encodeJavaScriptCustom.

@Override
public void encodeJavaScriptCustom(FacesContext facesContext, UIComponent uiComponent) throws IOException {
    ResponseWriter responseWriter = facesContext.getResponseWriter();
    InputSourceCode inputSourceCode = (InputSourceCode) uiComponent;
    Boolean readOnly = inputSourceCode.getReadOnly();
    ClientComponent clientComponent = (ClientComponent) uiComponent;
    String clientVarName = getClientVarName(facesContext, clientComponent);
    String clientKey = clientComponent.getClientKey();
    if (clientKey == null) {
        clientKey = clientVarName;
    }
    encodeLiferayComponentVar(responseWriter, clientVarName, clientKey);
    if ((readOnly == null) || (!readOnly)) {
        String hiddenInputClientId = getHiddenInputClientId(facesContext, uiComponent);
        String escapedHiddenInputClientId = "#" + ComponentUtil.escapeClientId(hiddenInputClientId);
        responseWriter.write(clientVarName);
        responseWriter.write(".getSession().on('change', function() {A.one('");
        responseWriter.write(escapedHiddenInputClientId);
        responseWriter.write("').set('value',");
        responseWriter.write(clientVarName);
        responseWriter.write(".getSession().getValue())});");
    }
    responseWriter.write(clientVarName);
    responseWriter.write(".editor.setOptions({ minLines: ");
    responseWriter.write(inputSourceCode.getMinLines().toString());
    responseWriter.write("});");
    responseWriter.write(clientVarName);
    responseWriter.write(".editor.setOptions({ maxLines: ");
    responseWriter.write(inputSourceCode.getMaxLines().toString());
    responseWriter.write("});");
}
Also used : HiddenTextResponseWriter(com.liferay.faces.util.render.HiddenTextResponseWriter) ResponseWriter(javax.faces.context.ResponseWriter) ClientComponent(com.liferay.faces.util.component.ClientComponent) InputSourceCode(com.liferay.faces.alloy.component.inputsourcecode.InputSourceCode)

Example 2 with InputSourceCode

use of com.liferay.faces.alloy.component.inputsourcecode.InputSourceCode in project liferay-faces-alloy by liferay.

the class InputSourceCodeRendererBase method encodeAlloyAttributes.

@Override
public void encodeAlloyAttributes(FacesContext facesContext, ResponseWriter responseWriter, UIComponent uiComponent) throws IOException {
    InputSourceCode inputSourceCode = (InputSourceCode) uiComponent;
    boolean first = true;
    String height = inputSourceCode.getHeight();
    if (height != null) {
        encodeHeight(responseWriter, inputSourceCode, height, first);
        first = false;
    }
    Boolean highlightActiveLine = inputSourceCode.getHighlightActiveLine();
    if (highlightActiveLine != null) {
        encodeHighlightActiveLine(responseWriter, inputSourceCode, highlightActiveLine, first);
        first = false;
    }
    String locale = inputSourceCode.getLocale();
    if (locale != null) {
        encodeLocale(responseWriter, inputSourceCode, locale, first);
        first = false;
    }
    String mode = inputSourceCode.getMode();
    if (mode != null) {
        encodeMode(responseWriter, inputSourceCode, mode, first);
        first = false;
    }
    Boolean readOnly = inputSourceCode.getReadOnly();
    if (readOnly != null) {
        encodeReadOnly(responseWriter, inputSourceCode, readOnly, first);
        first = false;
    }
    Boolean showPrintMargin = inputSourceCode.getShowPrintMargin();
    if (showPrintMargin != null) {
        encodeShowPrintMargin(responseWriter, inputSourceCode, showPrintMargin, first);
        first = false;
    }
    String tabSize = inputSourceCode.getTabSize();
    if (tabSize != null) {
        encodeTabSize(responseWriter, inputSourceCode, tabSize, first);
        first = false;
    }
    Boolean useSoftTabs = inputSourceCode.getUseSoftTabs();
    if (useSoftTabs != null) {
        encodeUseSoftTabs(responseWriter, inputSourceCode, useSoftTabs, first);
        first = false;
    }
    Boolean useWrapMode = inputSourceCode.getUseWrapMode();
    if (useWrapMode != null) {
        encodeUseWrapMode(responseWriter, inputSourceCode, useWrapMode, first);
        first = false;
    }
    Object value = inputSourceCode.getValue();
    if (value != null) {
        encodeValue(responseWriter, inputSourceCode, value, first);
        first = false;
    }
    String width = inputSourceCode.getWidth();
    if (width != null) {
        encodeWidth(responseWriter, inputSourceCode, width, first);
        first = false;
    }
    encodeHiddenAttributes(facesContext, responseWriter, inputSourceCode, first);
}
Also used : InputSourceCode(com.liferay.faces.alloy.component.inputsourcecode.InputSourceCode)

Aggregations

InputSourceCode (com.liferay.faces.alloy.component.inputsourcecode.InputSourceCode)2 ClientComponent (com.liferay.faces.util.component.ClientComponent)1 HiddenTextResponseWriter (com.liferay.faces.util.render.HiddenTextResponseWriter)1 ResponseWriter (javax.faces.context.ResponseWriter)1