List of usage examples for org.apache.commons.validator GenericValidator isBlankOrNull
public static boolean isBlankOrNull(String value)
Checks if the field isn't null and length of the field is greater than zero not including whitespace.
From source file:org.squale.welcom.taglib.onglet.JSOngletItemTag.java
/** * @return print apres le body/*from w w w. jav a2 s . c o m*/ * @throws JspException exception pouvant etre levee */ private int doPrintAfterBody() throws JspException { final JSOngletItem onglet = new JSOngletItem(); // Transformation de la key en message String message = WRequestUtils.message(super.pageContext, key); if (GenericValidator.isBlankOrNull(message)) { message = key; } onglet.setTitre(message); // Recherche si un parent est du bon type Tag curParent = findAncestorWithClass(this, JSOngletTag.class); if (curParent == null) { throw new JspException("JSOngletItem Tag must be have parents JSOnglet."); } onglet.setParentName(((JSOngletTag) curParent).getName()); if (!((JSOngletTag) curParent).isFirstOngletSelected() && Util.isTrue(isTabSelected)) { onglet.setIsOnglet(isTabSelected); ((JSOngletTag) curParent).setFirstOngletSelected(true); } else { onglet.setIsOnglet("false"); } onglet.setName(name); onglet.setLazyLoading(isLazyLoading()); onglet.setPageInclude(pageInclude); onglet.setPageContext(pageContext); onglet.setOnClickAfterShow(onAfterShow); ((JSOngletTag) curParent).addOnglet(onglet); // Recupere le body evalu final BodyContent bodyContent = getBodyContent(); if (bodyContent != null) { final String value = bodyContent.getString().trim(); bodyContent.clearBody(); if (value.length() > 0) { onglet.setCorps(value); } } // Continue processing this page release(); return (EVAL_PAGE); }
From source file:org.squale.welcom.taglib.onglet.JSOngletItemTag.java
/** * @see javax.servlet.jsp.tagext.Tag#doEndTag() *//*from w w w . ja va 2s. c o m*/ public int doEndTag() throws JspException { final HttpSession session = super.pageContext.getSession(); if (session != null) { final Object logonBean = session.getAttribute(nameLogonBean); if (logonBean != null) { try { String haveAccess = "true"; if (!GenericValidator.isBlankOrNull(accessKey)) { final String pageAccess = Access.getMultipleSecurityPage((WILogonBeanSecurity) logonBean, accessKey); haveAccess = new Boolean(Access.checkAccessDroit(pageAccess)).toString(); } if (Util.isTrue(haveAccess)) { return doPrintAfterBody(); } } catch (final Exception _ex) { new JspException( "Manque m\351thode getVectorProfil() ou getIdIncident() sur bean WConstants.USER_KEY"); } } else { return doPrintAfterBody(); } } release(); return EVAL_PAGE; }
From source file:org.squale.welcom.taglib.optimization.ScriptTag.java
/** * @see javax.servlet.jsp.tagext.TagSupport#doEndTag() */// www. jav a 2 s . co m public int doEndTag() throws JspException { final JspWriter writer = pageContext.getOut(); try { writer.print("<script type=\"text/JavaScript\" src=\""); writer.print(src + "\""); if (!GenericValidator.isBlankOrNull(charset)) { writer.print(" charset=\"" + charset + "\""); } writer.print(">"); writer.print("</script>"); } catch (final IOException e) { throw new JspException(e.getMessage()); } return EVAL_PAGE; }
From source file:org.squale.welcom.taglib.progressbar.ProgressBarTag.java
public int doStartTag() throws JspException { JspWriter out = this.pageContext.getOut(); try {//from w w w.ja v a2s .c o m // Inclusion de la librairie JS CanvasUtil.addJs( WelcomConfigurator.getMessage(WelcomConfigurator.HEADER_LOCALJS_PATH_KEY) + "progressbar.js", this, pageContext); boolean isIE = false; boolean isSafari = false; boolean isOpera = false; String userAgent = ((HttpServletRequest) pageContext.getRequest()).getHeader("User-Agent"); if (userAgent != null) { if (userAgent.indexOf("MSIE") != -1) { isIE = true; } else { if (userAgent.indexOf("Safari") != -1) { isSafari = true; } else { if (userAgent.indexOf("Opera") != -1) { isOpera = true; } } } } String pbProperties = " wRefreshRate='" + refreshRate + "'"; if (!GenericValidator.isBlankOrNull(onChangeHook)) { pbProperties += " wOnChangeHook='" + onChangeHook + "'"; } if (!GenericValidator.isBlankOrNull(onCompleteHook)) { pbProperties += " wOnCompleteHook='" + onCompleteHook + "'"; } pbProperties += " wIsFullScreen='" + isFullScreen + "'"; out.println("<input type='hidden' id='wWatchedTaskId' name='wWatchedTaskId'>"); out.println("<DIV id='" + id + "' " + pbProperties + ">"); if (isFullScreen) { // Cration de variable pour viter de passer ces infos dans l'appel // JS if (isIE) { out.println("<IFRAME frameborder=0 id=wDivProgressBarBG style=\"background-color:#ffffff;"); out.println("filter:alpha(opacity=60);"); out.println("visibility: hidden;"); out.println( "position:absolute; top:0px; left:0px; width:1400px; height:909px; z-index:123; padding:0; border-width:0; border-style:none, margin:0;\">"); out.println("</IFRAME>"); } else { out.println("<div id=wDivProgressBarBG style=\"background-color:#ffffff;"); out.print("-moz-opacity:0.6;"); out.print("opacity: 0.6;"); out.print("visibility: hidden;"); out.print( "position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:123; margin:0;\">"); out.println("</div>"); } out.println("<div id=wDivProgressBar style=\"background-color:#FFFFFF;"); out.print("position:absolute;"); out.print("left:50%;"); out.print("top:50%;"); out.print("visibility: hidden;"); out.print("margin-left:-50px;"); out.print("margin-top:-50px; "); out.print("z-index:124;"); out.print("border:1px solid #888\">"); } // Fin IF isFullScreen // Cration de la zone d'affichage String tdStatus; if (showStatusText) { tdStatus = "<span style=\"color:#000\" id='" + getId() + "_status'>-</span>"; } else { tdStatus = ""; } String tdPct; if (showPctText) { tdPct = "<span style=\"color:#000\" id=\"" + getId() + "_pctText\">0%</span>"; } else { tdPct = ""; } boolean leftExists = false; boolean topExists = false; boolean rightExists = false; boolean bottomExists = false; boolean progressSolo = true; if (showPctText || showStatusText) { if ((pctTextPosition.equals(POS_LEFT)) || (statusTextPosition.equals(POS_LEFT))) { leftExists = true; progressSolo = false; } if ((pctTextPosition.equals(POS_TOP)) || (statusTextPosition.equals(POS_TOP))) { topExists = true; progressSolo = false; } if ((pctTextPosition.equals(POS_RIGHT)) || (statusTextPosition.equals(POS_RIGHT))) { rightExists = true; progressSolo = false; } if ((pctTextPosition.equals(POS_BOTTOM)) || (statusTextPosition.equals(POS_BOTTOM))) { bottomExists = true; progressSolo = false; } } if (isSafari) { progressSolo = true; bottomExists = false; topExists = false; leftExists = false; rightExists = false; } if (isFullScreen()) { out.println( "<div style=\"background-image:url(theme/charte_v03_001/img/lignage/lignage_trans.gif);background-position:left bottom;background-repeat:repeat-x;height:32px;width:" + width + "px;\" class=\"bg_theme\"><div style=\"margin: 0pt; padding: 0px 5px; font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; font-size: 10px; color: rgb(255, 255, 255); background-color: rgb(5, 16, 57); cursor: default; height: 16px; float: left;\">Execution</div></div>"); } // out.println("<div>"); out.println("<table border=\"0\" cellspacing=\"2px\" style=\"0px 3px 3px 3px\" width=\"" + width + "px\" >"); // Formattage out.print("<tr>"); if (leftExists) { out.print("<th style='width: 15%'></th>"); } if (!progressSolo) { if (leftExists && rightExists) { out.print("<th style='width: 70%'></th>"); } else { if (leftExists || rightExists) { out.print("<th style='width: 85%'></th>"); } else { out.print("<th style='width: 100%'></th>"); } } } if (rightExists) { out.print("<th style='width: 15%'></th>"); } out.println("</tr>"); // ############### // LIGNE du haut // ############### if (topExists) { out.println("<tr>"); // ------------ if (leftExists || rightExists) { out.println("<td " + STYLE_TD_NOBORDER_PADDING + " colspan=2>"); } else { out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >"); } if (pctTextPosition.equals(POS_TOP)) { out.println(tdPct); } if (statusTextPosition.equals(POS_TOP)) { out.println(tdStatus); } out.println("</td>"); // ------------ out.println("</tr>"); } // ############### // LIGNE du milieu // ############### // ------------ out.println("<tr>"); if (leftExists) { out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >"); if (pctTextPosition.equals(POS_LEFT)) { out.println(tdPct); } if (statusTextPosition.equals(POS_LEFT)) { out.println(tdStatus); } out.println("</td>"); } // ------------ out.print(" <td " + STYLE_TD_NOBORDER_PADDING + ">"); // ----- PROGRESS BAR ----- if (isSafari) { out.print(render.drawAnimatedProgressBar()); } else { out.print(render.drawRealProgressBar(getId())); } // ----- PROGRESS BAR ----- out.println(" </td>"); // ------------ if (rightExists) { out.println("<td " + STYLE_TD_NOBORDER + " >"); if (pctTextPosition.equals(POS_RIGHT)) { out.println(tdPct); } if (statusTextPosition.equals(POS_RIGHT)) { out.println(tdStatus); } out.println("</td>"); } out.println("</tr>"); // ------------ // ############### // LIGNE du bas // ############### if (bottomExists) { out.println("<tr>"); // ------------ if (leftExists || rightExists) { out.println("<td " + STYLE_TD_NOBORDER_PADDING + " colspan=2>"); } else { out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >"); } if (pctTextPosition.equals(POS_BOTTOM)) { out.println(tdPct); } if (statusTextPosition.equals(POS_BOTTOM)) { out.println(tdStatus); } out.println("</td>"); // ------------ out.println("</tr>"); } out.println("</table>"); // out.println("</div>"); if (isFullScreen) { out.println( "<div style=\"background-image:url(theme/charte_v03_001/img/lignage/footer_trans.gif);background-position:left bottom;clear:both;height:20px;width:" + width + "px;\" class=\"bg_theme\"></div>"); out.println("</div>"); } out.println("</div>"); } catch (IOException e) { try { out.println("unable to render tag due to " + e.getClass().getName() + ":" + e.getMessage()); } catch (IOException e1) { // On fait rien car l'exception doit tre la mme que celle du // bloc catch englobant } e.printStackTrace(); } // Continue processing this page release(); return (EVAL_PAGE); }
From source file:org.squale.welcom.taglib.table.Col.java
/** * @return le href construit// w w w. ja v a 2 s . com */ public String getHref() { String linkParams = ""; if (GenericValidator.isBlankOrNull(link)) { return null; } if (GenericValidator.isBlankOrNull(paramName)) { return link; } try { final Object tmpLinkParams = LayoutUtils.getBeanFromPageContext(pageContext, paramName, paramProperty); if (tmpLinkParams.getClass() == String.class) { // Retour d'un string: on caste sans problme linkParams = (String) tmpLinkParams; } else { // Retour d'un pas string: en gnral un nombre (id) linkParams += tmpLinkParams; } } catch (final JspException e) { log.error(e, e); return link; } String carsup = ""; if (!GenericValidator.isBlankOrNull(link)) { if ((link.indexOf("?") > -1) && !GenericValidator.isBlankOrNull(linkParams)) { carsup = "&"; } else if (!GenericValidator.isBlankOrNull(linkParams)) { carsup = "?"; } } return link + carsup + Util.encode(paramId) + "=" + Util.encode(linkParams); }
From source file:org.squale.welcom.taglib.table.ColEdit.java
/** * @see org.squale.welcom.taglib.table.ICol#getCurrentValue(int, java.lang.Object, int, java.lang.String, * java.lang.String)//from ww w. ja v a 2 s . c o m */ public String getSpecificContent(final int position, final Object bean, final int idIndex, final String style, final String styleSelect, final int pageLength) throws JspException { final StringBuffer s = new StringBuffer(); final String formName = getCols().getTable().getFormName(); if (GenericValidator.isBlankOrNull(formName)) { throw new JspException("ColEditTag must be used inside a form tag."); } if (bean instanceof WIEditable) { if ((!getProperty().equals("")) && (!getProperty().equals("edited"))) { return ("Attention, le bean '" + bean.getClass() + "' implmente dj WIEditable, on ne tient donc pas compte de la property '" + getProperty() + "'"); } setProperty("edited"); } else if (GenericValidator.isBlankOrNull(getProperty())) { return ("le bean '" + bean.getClass() + "' doit implmenter WIEditable, ou l'attribut property du tag <ColEdit> doit tre renseigner"); } String result = ""; try { result = BeanUtils.getProperty(bean, getProperty()); } catch (final IllegalAccessException e) { log.error(e, e); } catch (final InvocationTargetException e) { log.error(e, e); } catch (final NoSuchMethodException e) { log.error(e, e); } s.append("<a href=\""); if (Util.isTrue(result)) { s.append("javascript:tableForward('" + formName + "','" + getHref("false", idIndex, pageLength) + "')\">"); s.append("<img src=\""); s.append(WelcomConfigurator.getMessageWithCfgChartePrefix(".htmltable.images.coledit.cancel")); s.append("\""); if (!GenericValidator.isBlankOrNull(titleCancel)) { s.append(" title=\""); s.append(titleCancel); s.append("\""); } } else { s.append("javascript:tableForward('" + formName + "','" + getHref("true", idIndex, pageLength) + "')\">"); s.append("<img src=\""); s.append(WelcomConfigurator.getMessageWithCfgChartePrefix(".htmltable.images.coledit.edit")); s.append("\""); if (!GenericValidator.isBlankOrNull(titleEdit)) { s.append(" title=\""); s.append(titleEdit); s.append("\""); } } s.append(" border=0>"); s.append("</a>"); return s.toString(); }
From source file:org.squale.welcom.taglib.table.ColEditTag.java
/** * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag() *///from w w w .ja va 2 s . c om public int doStartTag() throws JspException { final String pageAccess = (String) pageContext.getAttribute("access"); if ((pageAccess != null) && pageAccess.equals(Access.READONLY) && !forceReadWrite) { return SKIP_BODY; } // Recherche si un parent est du bon type Tag curParent = null; for (curParent = getParent(); (curParent != null) && !(curParent instanceof ColsTag);) { curParent = curParent.getParent(); } if (curParent == null) { throw new JspException("ColTag must be used between Cols Tag."); } colsTag = (ColsTag) curParent; if (!GenericValidator.isBlankOrNull(colsTag.getEmptyKey()) && (pageContext.getAttribute(colsTag.getId()) == null)) { return SKIP_BODY; } else { return EVAL_PAGE; } }
From source file:org.squale.welcom.taglib.table.ColEditTag.java
/** * @see javax.servlet.jsp.tagext.Tag#doEndTag() *///from w w w. jav a2 s . c om 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 ColEdit c = new ColEdit(); if (key == null) { if (key != null) { key = property; } else { key = "edited"; } } c.setKey(key); c.setProperty(property); if (pageContext.getRequest().getParameter("from") != null) { c.setFrom(pageContext.getRequest().getParameter("from")); } c.setBaseURL(((HttpServletRequest) pageContext.getRequest()).getContextPath()); c.setWidth(width); c.setPageContext(pageContext); c.setRequestURI(((HttpServletRequest) pageContext.getRequest()).getRequestURI()); c.setDisabledProperty(disabledProperty); if (!GenericValidator.isBlankOrNull(toolTipKeyEdit)) { c.setTitleEdit(resources.getMessage(localeRequest, toolTipKeyEdit)); if (GenericValidator.isBlankOrNull(c.getTitleEdit())) { c.setTitleEdit(toolTipKeyEdit); } } if (!GenericValidator.isBlankOrNull(toolTipKeyCancel)) { c.setTitleCancel(resources.getMessage(localeRequest, toolTipKeyCancel)); if (GenericValidator.isBlankOrNull(c.getTitleCancel())) { c.setTitleCancel(toolTipKeyCancel); } } if (getBodyContent() != null) { c.setCurrentValue(getBodyContent().getString().trim()); } colsTag.addCellule(c); return EVAL_PAGE; }
From source file:org.squale.welcom.taglib.table.ColHeader.java
/** * Retourne l'url pour le trie//from w w w.ja v a 2s .c o m * * @param servletName nom de la servlet * @param tableTag nom du tag de la table * @param from pour quel indice de la table ? * @return l'url pour le trie */ public String getSortUrl(TableTag tableTag, String servletName, int from) { String frwd = null; if (!GenericValidator.isBlankOrNull(tableTag.getPageForward())) { frwd = "&wforward=" + tableTag.getPageForward(); } else { frwd = "&requestURI=" + tableTag.getRequestURI(); } final StringBuffer sbUrl = new StringBuffer(); sbUrl.append(servletName + "from=" + from + frwd + "&colonne=" + col.getProperty()); sbUrl.append("&table=" + ListColumnSort.getCle(tableTag.getName(), tableTag.getProperty())); sbUrl.append("&sens=" + SortOrder.next(colSort.getSort()) + ""); if (!GenericValidator.isBlankOrNull(col.getType())) { sbUrl.append("&type=" + col.getType() + ""); } if (!GenericValidator.isBlankOrNull(col.getDateFormatKey())) { final String format = resources.getMessage(localeRequest, col.getDateFormatKey()); sbUrl.append("&dateformat=" + format + ""); } else if (!GenericValidator.isBlankOrNull(col.getDateFormat())) { sbUrl.append("&dateformat=" + col.getDateFormat() + ""); } return sbUrl.toString(); }
From source file:org.squale.welcom.taglib.table.ColOrder.java
/** * @see org.squale.welcom.taglib.table.ICol#getCurrentValue(int, java.lang.Object, int, java.lang.String, * java.lang.String)//ww w. j a v a 2s.c om */ public String getCurrentValue(final int position, final Object bean, final int idIndex, final String style, final String styleSelect, final int pageLength) { final StringBuffer s = new StringBuffer(); final String formName = getCols().getTable().getFormName(); if (position != Cols.FIRST) { s.append("<div style=\"position:relative;left:0;top:1\"><a href=\"javascript:tableForward('"); s.append(formName); s.append("','"); s.append(getHrefUp(idIndex)); s.append("')\""); if (!GenericValidator.isBlankOrNull(titleUp)) { s.append(" title=\""); s.append(titleUp); s.append("\" "); } s.append(">"); s.append("<img border=\"0\" src=\""); s.append(WelcomConfigurator.getMessageWithCfgChartePrefix(".htmltable.images.order.up")); s.append("\">"); s.append("</a></div>"); } if (position != Cols.LAST) { s.append("<div style=\"position:relative;left:0;top:-1\"><a href=\"javascript:tableForward('"); s.append(formName); s.append("','"); s.append(getHrefDown(idIndex)); s.append("')\""); if (!GenericValidator.isBlankOrNull(titleDown)) { s.append(" title=\""); s.append(titleDown); s.append("\" "); } s.append(">"); s.append("<img border=\"0\" src=\""); s.append(WelcomConfigurator.getMessageWithCfgChartePrefix(".htmltable.images.order.down")); s.append("\">"); s.append("</a></div>"); } return s.toString(); }