Example usage for org.apache.commons.validator GenericValidator isBlankOrNull

List of usage examples for org.apache.commons.validator GenericValidator isBlankOrNull

Introduction

In this page you can find the example usage for org.apache.commons.validator GenericValidator isBlankOrNull.

Prototype

public static boolean isBlankOrNull(String value) 

Source Link

Document

Checks if the field isn't null and length of the field is greater than zero not including whitespace.

Usage

From source file:org.squale.welcom.taglib.table.ColSelect.java

/**
 * @see org.squale.welcom.taglib.table.Col#getSpecialHeaderContent()
 *///from   ww  w .  j  a v a2s  .  c  o m
public String getSpecialHeaderContent() {
    final StringBuffer sb = new StringBuffer();
    String name = getCols().getTable().getName();
    if (!GenericValidator.isBlankOrNull(getCols().getTable().getProperty())) {
        name = getCols().getTable().getProperty();
    }
    sb.append("<input type=\"checkbox\" id=\"selectAllCHK\" class=\"normal\" onclick=\"selectAll('");
    sb.append(name);
    sb.append("',this)\"");
    sb.append(" title=\"");
    sb.append(specialHeaderTitle);
    sb.append("\">");

    return sb.toString();
}

From source file:org.squale.welcom.taglib.table.ColSelectTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from w  ww .j a  v a 2  s. c  o m*/
public int doEndTag() throws JspException {
    final String pageAccess = (String) pageContext.getAttribute("access");

    if ((pageAccess != null) && pageAccess.equals(Access.READONLY) && !forceReadWrite) {
        return SKIP_BODY;
    }

    // Recupere la locale de la page
    final Locale localeRequest = (Locale) pageContext.getSession().getAttribute(Globals.LOCALE_KEY);

    // Recuperer le fichier des Bundle
    final MessageResources resources = (MessageResources) pageContext.getServletContext()
            .getAttribute(Globals.MESSAGES_KEY);

    final ColSelect c = new ColSelect();

    if (key == null) {
        key = "selected";
    }

    c.setKey(key);
    c.setProperty(property);
    c.setWidth(width);
    c.setPageContext(pageContext);
    c.setEnableSingleSelect(enableSingleSelect);
    c.setWriteTD(false);
    c.setOnclick(onclick);
    c.setDisabledProperty(disabledProperty);
    c.setSpecialHeader(showSelectAllHeader);
    c.setSpecialHeaderTitle(resources.getMessage(localeRequest, "welcom.internal.selectAll.tootip"));
    c.setToolTip(resources.getMessage(localeRequest, toolTipKey));
    if (GenericValidator.isBlankOrNull(c.getToolTip())) {
        c.setToolTip(toolTipKey);
    }
    if (getBodyContent() != null) {
        c.setCurrentValue(getBodyContent().getString().trim());
    }

    colsTag.addCellule(c);

    return EVAL_PAGE;
}

From source file:org.squale.welcom.taglib.table.ColSingleSelect.java

/**
 * Retourne la valeur pour le champ input
 * /* w ww.j  a  v  a2 s .c o  m*/
 * @param bean le bean
 * @param idIndex l'index
 * @return si une propertyvalue est calcul alors on retoune cette valeur, sinon l'index
 */
private String getComputedInputValue(final Object bean, final int idIndex) {

    String comptedInputValue = Integer.toString(idIndex);

    if (GenericValidator.isBlankOrNull(value) && !GenericValidator.isBlankOrNull(propertyValue)) {
        try {
            comptedInputValue = BeanUtils.getProperty(bean, propertyValue);
        } catch (final IllegalAccessException e) {
            log.error(e, e);
        } catch (final InvocationTargetException e) {
            log.error(e, e);
        } catch (final NoSuchMethodException e) {
            log.error(e, e);
        }
    }

    return comptedInputValue;
}

From source file:org.squale.welcom.taglib.table.ColSingleSelect.java

/**
 * @param bean : Bean/*from  ww w.j  ava2  s  . c o m*/
 * @param position la position de la colonne
 * @param idIndex Index
 * @param style Style
 * @param styleSelect Style selectionne
 * @return le html gnr
 */
public String getSpecificContent(int position, Object bean, int idIndex, String style, String styleSelect,
        final int pageLength) {

    final StringBuffer sb = new StringBuffer();

    /** Calcule la value du tag */
    value = getComputedInputValue(bean, idIndex);

    String name = getCols().getTable().getName();
    String wdt = "";
    String st = style;

    if (isNeedWriteWidth(idIndex)) {
        wdt = " width=\"" + getWidth() + "\"";
    }
    if (WelcomConfigurator.getCharte() == Charte.V2_002) {
        st = "normal";
    }

    if (!GenericValidator.isBlankOrNull(getCols().getTable().getProperty())) {
        name = getCols().getTable().getProperty();
    }

    // Creation du TD
    sb.append("<td style=\"padding:0 0 0 0;\"");
    sb.append(wdt);
    sb.append(" classSelect=\"");
    sb.append(styleSelect);
    sb.append("\" classDefault=\"");
    sb.append(style);
    sb.append("\">");

    // Creation de la check box
    sb.append("<input class=\"");
    sb.append(st);
    sb.append("\" type=\"radio\" name=\"");
    sb.append(getProperty());
    sb.append("\" value=\"");
    sb.append(value);
    sb.append("\" ");
    sb.append(" id=\"");
    sb.append(getAutoID());
    sb.append("\" ");

    sb.append("onclick=\"checkRadioSingle(this);");

    if (!GenericValidator.isBlankOrNull(onclick)) {
        sb.append(onclick);
    }
    sb.append(";\"");

    // Si ce test venait  changer, mettre  jour la mthode getLineIsSelected
    // qui reprend le mme principe
    if (formbeanValue.equals(value)) {
        sb.append(" checked ");
    }

    sb.append("></td>");

    return sb.toString();
}

From source file:org.squale.welcom.taglib.table.ColSingleSelectTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from w w  w  .j a v a 2s .  co m*/
public int doEndTag() throws JspException {
    final String pageAccess = (String) pageContext.getAttribute("access");

    if ((pageAccess != null) && pageAccess.equals(Access.READONLY) && !forceReadWrite) {
        return SKIP_BODY;
    }

    // Recupere la locale de la page
    final Locale localeRequest = (Locale) pageContext.getSession().getAttribute(Globals.LOCALE_KEY);

    // Recuperer le fichier des Bundle
    final MessageResources resources = (MessageResources) pageContext.getServletContext()
            .getAttribute(Globals.MESSAGES_KEY);

    final ColSingleSelect c = new ColSingleSelect();

    if (key == null) {
        key = "selected";
    }

    c.setKey(key);
    c.setPropertyValue(propertyValue);
    c.setWidth(width);
    c.setPageContext(pageContext);
    c.setWriteTD(false);
    c.setOnclick(onclick);
    c.setValue(value);
    c.setDisabledProperty(disabledProperty);
    String val = (String) RequestUtils.lookup(super.pageContext, name, property, null);
    if (val != null) {
        c.setFormbeanValue(val);
    }
    c.setProperty(property);
    c.setSpecialHeaderTitle(resources.getMessage(localeRequest, "welcom.internal.selectAll.tootip"));
    c.setToolTip(resources.getMessage(localeRequest, toolTipKey));
    if (GenericValidator.isBlankOrNull(c.getToolTip())) {
        c.setToolTip(toolTipKey);
    }
    if (getBodyContent() != null) {
        c.setCurrentValue(getBodyContent().getString().trim());
    }

    colsTag.addCellule(c);

    return EVAL_PAGE;
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*w  w  w  .  j a  v  a2s . c  om*/
public int doEndTag() throws JspException {
    final TrimStringBuffer sb = new TrimStringBuffer();

    if (!(collectionForDisplay.isEmpty())
            || (collectionForDisplay.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) {
        sb.append(getBodyContent().getString().trim());
        sb.append(render.drawTableEnd());
        ResponseUtils.write(pageContext, sb.toString());
    }

    if (tableTag.getScrollHeight() != 0) {
        if (!(collectionForDisplay.isEmpty())
                || (collectionForDisplay.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) {
            ResponseUtils.write(pageContext, "</div>");
        }
    }
    release();
    return EVAL_PAGE;
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doStartTag()
 *///from   ww  w .  j ava2s.co m
public int doStartTag() throws JspException {
    // Recherche si un parent est du bon type
    Tag curParent = null;

    for (curParent = getParent(); (curParent != null) && !(curParent instanceof TableTag);) {
        curParent = curParent.getParent();
    }

    tableTag = (TableTag) curParent;

    if (tableTag == null) {
        throw new JspException("ColsTag  must be used between Table Tag.");
    }

    collectionForDisplay = tableTag.getCollectionForDisplay();
    collectionForMemory = tableTag.getCollection();
    keySort = tableTag.getListColumnSort();
    resources = tableTag.getResources();
    localeRequest = tableTag.getLocaleRequest();
    name = tableTag.getName();
    emptyKey = tableTag.getEmptyKey();

    if (!(collectionForDisplay.isEmpty()) || !GenericValidator.isBlankOrNull(emptyKey)) {
        tableTag.writePixGris();

        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @see javax.servlet.jsp.tagext.BodyTagSupport#doInitBody()
 *//* w w w  .j a  va2s .co  m*/
public void doInitBody() throws JspException {
    final TrimStringBuffer sb = new TrimStringBuffer();

    String nom = tableTag.getName();

    if (!GenericValidator.isBlankOrNull(tableTag.getProperty())) {
        nom += ("." + tableTag.getProperty());
    }

    if (tableTag.getScrollHeight() != 0) {
        sb.append(render.drawTableStart(null, tableTag.getWidth()));
    } else {
        sb.append(render.drawTableStart(getTableName(), tableTag.getWidth()));
    }

    ResponseUtils.write(pageContext, sb.toString());

    if (!(collectionForMemory instanceof HTMLTable)) {
        idCount = 0;
    } else {
        idCount = ((HTMLTable) collectionForMemory).getFrom();
    }

    // Charge le tableau associatif des Object d'afficagae avec les object Memoire
    initRelationDisplayIdMemory();

    Object o = null;

    // Si la collection n'est pas vide alors passes l'object sinon il est null
    if (!collectionForDisplay.isEmpty()) {
        o = collectionForDisplay.elementAt(idCount);
        pageContext.setAttribute(getId(), o, PageContext.PAGE_SCOPE);
        pageContext.setAttribute(getIdIndex(), (Integer) relationDisplayIdMemory.get(o),
                PageContext.PAGE_SCOPE);
    }
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @return Rcuperation du nom de la table
 *//*from w w w  .  j  a v  a2  s  .co  m*/
private String getTableName() {
    // Rcuperation du nom de la table
    String tableName = tableTag.getName();

    if (!GenericValidator.isBlankOrNull(tableTag.getProperty())) {
        tableName = tableName + "." + tableTag.getProperty();
    }

    return tableName;
}

From source file:org.squale.welcom.taglib.table.ColsTag.java

/**
 * @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody()
 *///from  w w  w.j  a v  a2s  . com
public int doAfterBody() throws JspException {
    boolean autoDescription = false;

    // Blindage
    if (currentLine == null) {
        // Vide les colonnes car le retourve a chaque fois
        currentLine = new Cols();
    }

    // Genere tout les columns
    if (currentLine.isEmpty()) {
        currentLine.genAllCols(collectionForDisplay.elementAt(0).getClass());
        autoDescription = true;
    }

    if (firstIterate) {
        if (((collectionForMemory != null) && !collectionForMemory.isEmpty()) || ((collectionForMemory != null)
                && collectionForMemory.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) {
            if (tableTag.isDisplayHeader()) {
                ResponseUtils.write(pageContext, tableTitre());
            }

            // Cherche pour l'inclusion de table
            if (tableTag.getScrollHeight() != 0) {
                if (!(collectionForDisplay.isEmpty())
                        || (collectionForDisplay.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey))) {
                    ResponseUtils.write(pageContext, "</table>");
                    ResponseUtils.write(pageContext,
                            "<div style=\"height:" + tableTag.getScrollHeight() + "px;overflow:auto;\">");

                    ResponseUtils.write(pageContext,
                            render.drawTableStart(getTableName(), tableTag.getWidth()));

                    tableTag.setDisplayHeader(false);
                }
            }

            if (autoDescription) {
                idCount = 0;
                // Vide les colonnes car le retourve a chaque fois
                currentLine = new Cols();
                initCurrentLine();
                firstIterate = false;

                return EVAL_BODY_AGAIN;
            }
        }

        firstIterate = false;
    }

    final TrimStringBuffer sb = new TrimStringBuffer();

    // Si la table est vide affiche la ligne et part
    if (collectionForMemory.isEmpty() && !GenericValidator.isBlankOrNull(emptyKey)) {
        final String myClassLignePaire = WelcomConfigurator
                .getMessage(WelcomConfigurator.getCharte().getWelcomConfigFullPrefix() + ".cols.even");
        sb.append("<tr class=\"" + myClassLignePaire + "\">");

        if ((isSelectTr() || isSelectCheckBox())) {
            sb.append("<td></td>");
        }

        sb.append("<td colspan=\"" + currentLine.size() + "\">");

        final String emptyMessage = resources.getMessage(localeRequest, emptyKey);

        if (emptyMessage != null) {
            sb.append(ResponseUtils.filter(emptyMessage));
        } else {
            sb.append(ResponseUtils.filter(emptyKey));
        }

        sb.append("</tr>");
        ResponseUtils.write(pageContext, sb.toString());

        return EVAL_PAGE;
    }

    initCurrentLine();
    sb.append(currentLine.tabletrCorps(idCount, collectionForDisplay.elementAt(idCount),
            (Integer) relationDisplayIdMemory.get(collectionForDisplay.elementAt(idCount))));
    ResponseUtils.write(pageContext, sb.toString());

    // Suppresion de l'aobjet courant
    pageContext.removeAttribute(getId());
    pageContext.removeAttribute(getIdIndex());
    currentLine = new Cols(); // Vide les colonnes car le retourve a chaque fois

    idCount++;

    if (!(collectionForMemory instanceof HTMLTable)) {
        if (collectionForDisplay.size() > idCount) {
            final Object o = collectionForDisplay.elementAt(idCount);
            pageContext.setAttribute(getId(), o, PageContext.PAGE_SCOPE);
            pageContext.setAttribute(getIdIndex(), (Integer) relationDisplayIdMemory.get(o),
                    PageContext.PAGE_SCOPE);

            return EVAL_BODY_AGAIN;
        }
    } else {
        if ((collectionForDisplay.size() > idCount) && (idCount < (((HTMLTable) collectionForMemory).getLength()
                + ((HTMLTable) collectionForMemory).getFrom()))) {
            final Object o = collectionForDisplay.elementAt(idCount);
            pageContext.setAttribute(getId(), o, PageContext.PAGE_SCOPE);
            pageContext.setAttribute(getIdIndex(), (Integer) relationDisplayIdMemory.get(o),
                    PageContext.PAGE_SCOPE);

            return EVAL_BODY_AGAIN;
        }
    }

    return EVAL_PAGE;

    // ResponseUtils.write(pageContext,sb.toString());
}