ips1ap101.lib.core.jsf.component.AreaTexto.java Source code

Java tutorial

Introduction

Here is the source code for ips1ap101.lib.core.jsf.component.AreaTexto.java

Source

/*
 * Este programa es software libre; usted puede redistribuirlo y/o modificarlo bajo los terminos
 * de la licencia "GNU General Public License" publicada por la Fundacion "Free Software Foundation".
 * Este programa se distribuye con la esperanza de que pueda ser util, pero SIN NINGUNA GARANTIA;
 * vea la licencia "GNU General Public License" para obtener mas informacion.
 */
package ips1ap101.lib.core.jsf.component;

import com.sun.webui.jsf.component.TextArea;
import ips1ap101.lib.base.bundle.BundleParametros;
import ips1ap101.lib.core.jsf.JSF;
import org.apache.commons.lang.StringUtils;

/**
 * @author Jorge Campins
 */
public class AreaTexto extends TextArea {

    public AreaTexto() {
        super();
        setTabIndex(1);
    }

    private boolean unaware = true;

    private ComponenteAlternativo sibling = null;

    synchronized protected ComponenteAlternativo getSibling() {
        if (unaware && sibling == null && this.getId() != null) {
            unaware = false;
            sibling = JSF.getComponenteAlternativo(this);
        }
        return sibling;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean isRendered() {
        getSibling();
        return sibling == null ? super.isRendered() : super.isRendered() && !super.isReadOnly();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String getToolTip() {
        String superstr = super.getToolTip();
        if (StringUtils.isNotBlank(superstr) && getValueExpression("toolTip") == null) {
            if (superstr.startsWith("BundleParametros.")) {
                int i = superstr.indexOf('.');
                String key = superstr.substring(i + 1).trim();
                if (key.length() > 0) {
                    return BundleParametros.getToolTip(key);
                }
            }
        }
        return superstr;
    }

}