Example usage for com.liferay.portal.kernel.util TextFormatter K

List of usage examples for com.liferay.portal.kernel.util TextFormatter K

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util TextFormatter K.

Prototype

int K

To view the source code for com.liferay.portal.kernel.util TextFormatter K.

Click Source Link

Usage

From source file:com.liferay.taglib.aui.FieldWrapperTag.java

License:Open Source License

@Override
protected void setAttributes(HttpServletRequest request) {
    super.setAttributes(request);

    String label = getLabel();//from   w w w  . j a v  a2s . c om

    if (label == null) {
        label = TextFormatter.format(getName(), TextFormatter.K);
    }

    setNamespacedAttribute(request, "label", label);
}

From source file:com.liferay.taglib.aui.InputTag.java

License:Open Source License

@Override
protected void setAttributes(HttpServletRequest request) {
    super.setAttributes(request);

    Object bean = getBean();/*from ww  w. jav a2s . c  o m*/

    if (bean == null) {
        bean = pageContext.getAttribute("aui:model-context:bean");
    }

    String defaultLanguageId = getDefaultLanguageId();

    if (Validator.isNull(defaultLanguageId)) {
        defaultLanguageId = (String) pageContext.getAttribute("aui:model-context:defaultLanguageId");
    }

    if (Validator.isNull(defaultLanguageId)) {
        Locale defaultLocale = LocaleUtil.getDefault();

        defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
    }

    String name = getName();

    int pos = name.indexOf(StringPool.DOUBLE_DASH);

    if (pos != -1) {
        name = name.substring(pos + 2, name.length() - 2);
    }

    String field = getField();

    if (Validator.isNull(field)) {
        field = getName();
    }

    String formName = getFormName();

    if (formName == null) {
        FormTag formTag = (FormTag) findAncestorWithClass(this, FormTag.class);

        if (formTag != null) {
            formName = formTag.getName();
        }
    }

    String id = getId();
    String type = getType();

    if (Validator.isNull(id)) {
        if (!Validator.equals(type, "assetTags") && !Validator.equals(type, "radio")) {

            id = name;
        } else {
            id = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
        }
    }

    String label = getLabel();

    if (label == null) {
        label = TextFormatter.format(name, TextFormatter.K);
    }

    Class<?> model = getModel();

    if (model == null) {
        model = (Class<?>) pageContext.getAttribute("aui:model-context:model");
    }

    _forLabel = id;
    _inputName = getName();

    String baseType = null;

    if ((model != null) && Validator.isNull(type)) {
        baseType = ModelHintsUtil.getType(model.getName(), field);

        String fieldParam = getFieldParam();

        if (Validator.isNotNull(fieldParam)) {
            _forLabel = fieldParam;
            _inputName = fieldParam;
        }

        if (ModelHintsUtil.isLocalized(model.getName(), field)) {
            _forLabel += StringPool.UNDERLINE + defaultLanguageId;
            _inputName += StringPool.UNDERLINE + defaultLanguageId;
        }
    } else if (Validator.isNotNull(type)) {
        if (Validator.equals(type, "checkbox") || Validator.equals(type, "radio")) {

            baseType = type;
        }
    }

    if (Validator.isNull(baseType)) {
        baseType = "text";
    }

    setNamespacedAttribute(request, "baseType", baseType);
    setNamespacedAttribute(request, "bean", bean);
    setNamespacedAttribute(request, "defaultLanguageId", defaultLanguageId);
    setNamespacedAttribute(request, "field", field);
    setNamespacedAttribute(request, "forLabel", _forLabel);
    setNamespacedAttribute(request, "formName", formName);
    setNamespacedAttribute(request, "id", id);
    setNamespacedAttribute(request, "label", label);
    setNamespacedAttribute(request, "model", model);

    request.setAttribute(getAttributeNamespace() + "value", getValue());
}

From source file:com.liferay.taglib.aui.SelectTag.java

License:Open Source License

@Override
protected void setAttributes(HttpServletRequest request) {
    super.setAttributes(request);

    Object bean = getBean();/*  w w  w . ja  v  a  2 s . c  o  m*/

    if (bean == null) {
        bean = pageContext.getAttribute("aui:model-context:bean");
    }

    String name = getName();

    int pos = name.indexOf(StringPool.DOUBLE_DASH);

    if (pos != -1) {
        name = name.substring(pos + 2, name.length() - 2);
    }

    String id = getId();

    if (Validator.isNull(id)) {
        id = name;
    }

    String label = getLabel();

    if (label == null) {
        label = TextFormatter.format(name, TextFormatter.K);
    }

    String listType = getListType();
    String listTypeFieldName = getListTypeFieldName();

    if (Validator.isNotNull(listType) && Validator.isNull(listTypeFieldName)) {

        listTypeFieldName = "typeId";
    }

    String value = StringPool.BLANK;

    if (Validator.isNull(listType)) {
        if (bean != null) {
            value = BeanPropertiesUtil.getStringSilent(bean, name, value);
        }

        if (!getIgnoreRequestValue()) {
            value = ParamUtil.getString(request, name, value);
        }
    }

    setNamespacedAttribute(request, "bean", bean);
    setNamespacedAttribute(request, "id", id);
    setNamespacedAttribute(request, "label", label);
    setNamespacedAttribute(request, "listTypeFieldName", listTypeFieldName);
    setNamespacedAttribute(request, "value", value);
}

From source file:com.liferay.util.xml.BeanToXMLUtil.java

License:Open Source License

public static void addFields(Object obj, Element parentEl) {
    Method[] methods = obj.getClass().getMethods();

    for (int i = 0; i < methods.length; i++) {
        Method method = methods[i];

        if (method.getName().startsWith("get") && !method.getName().equals("getClass")) {

            String memberName = StringUtil.replace(method.getName(), "get", StringPool.BLANK);

            memberName = TextFormatter.format(memberName, TextFormatter.I);
            memberName = TextFormatter.format(memberName, TextFormatter.K);

            try {
                Object returnValue = method.invoke(obj, new Object[] {});

                if (returnValue instanceof List<?>) {
                    List<Object> list = (List<Object>) returnValue;

                    Element listEl = parentEl.addElement(memberName);

                    for (int j = 0; j < list.size(); j++) {
                        addBean(list.get(j), listEl);
                    }//from  w  w w  . j a va2s .com
                } else {
                    DocUtil.add(parentEl, memberName, returnValue.toString());
                }
            } catch (Exception e) {
                if (_log.isWarnEnabled()) {
                    _log.warn(e.getMessage());
                }
            }
        }
    }
}

From source file:com.liferay.util.xml.BeanToXMLUtil.java

License:Open Source License

public static String getClassNameWithoutPackage(String className) {
    String[] classNameArray = StringUtil.split(className, CharPool.PERIOD);

    String classNameWithoutPackage = classNameArray[classNameArray.length - 1];

    classNameWithoutPackage = TextFormatter.format(classNameWithoutPackage, TextFormatter.I);
    classNameWithoutPackage = TextFormatter.format(classNameWithoutPackage, TextFormatter.K);

    return classNameWithoutPackage;
}