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.htmlarea.CustomToolTag.java
/** * @throws JspException exception pouvant etre levee *//*from ww w. jav a 2s. co m*/ private void registerButton() throws JspException { final TrimStringBuffer sb = new TrimStringBuffer(); sb.append(edName + ".config.registerButton({\n"); sb.append("id : '" + id + "',\n"); if (!GenericValidator.isBlankOrNull(tooltip)) { String mess = null; mess = resources.getMessage(localeRequest, tooltip); if (GenericValidator.isBlankOrNull(mess)) { mess = tooltip; } sb.append("tooltip : '" + mess + "',\n"); } if (!GenericValidator.isBlankOrNull(image)) { sb.append("image : '" + image + "',\n"); } sb.append("textMode : '" + textMode + "',\n"); sb.append("action : " + action); sb.append("\n});\n"); ResponseUtils.write(pageContext, sb.toString()); }
From source file:org.squale.welcom.taglib.htmlarea.HtmlAreaTag.java
/** * Ouverture du tag// w w w. j a v a2 s . c o m * * @throws JspException jsp exception * @return constante */ public int doStartTag() throws JspException { // Recupere le droit sur la page final String pageAccess = (String) pageContext.getAttribute("access"); if (!(((pageAccess != null) && pageAccess.equals(Access.READONLY) && (forceReadWrite == false)))) { resources = (MessageResources) pageContext.getServletContext().getAttribute(Globals.MESSAGES_KEY); tagname = name; if (!GenericValidator.isBlankOrNull(property)) { if (property.lastIndexOf(".") >= 0) { tagname = property.substring(property.lastIndexOf(".") + 1); } else { tagname = property; } } edName = "ed_" + tagname; TrimStringBuffer.setTrim(false); initHtmlArea(); initToolBar(); initEditor(); } return EVAL_PAGE; }
From source file:org.squale.welcom.taglib.htmlarea.HtmlAreaTag.java
/** * init//from ww w . j ava2s. c o m * * @throws JspException jsp exception */ private void initHtmlArea() throws JspException { final TrimStringBuffer sb = new TrimStringBuffer(); // Recupere la locale de la page localeRequest = (Locale) pageContext.getSession().getAttribute(Globals.LOCALE_KEY); if (pageContext.getRequest().getAttribute(KEY) == null) { sb.append(OPEN_SCRIPT); sb.append("_editor_url = \"" + path + "\";\n"); sb.append("_editor_lang = \"" + localeRequest.getLanguage() + "\";\n"); sb.append(CLOSE_SCRIPT); sb.append("<script type=\"text/javascript\" src=\"" + prefix + path + "htmlarea.js\"></script>\n"); sb.append("<script type=\"text/javascript\" src=\"" + prefix + path + "lang/" + localeRequest.getLanguage() + ".js\"></script>\n"); } if (!GenericValidator.isBlankOrNull(callbacksfile)) { sb.append("<script type=\"text/javascript\" src=\"js.do?value=" + callbacksfile + "\"></script>\n"); } ResponseUtils.write(pageContext, sb.toString()); }
From source file:org.squale.welcom.taglib.htmlarea.HtmlAreaTag.java
/** * Init de la barre d'outils// ww w .jav a2s. c om * * @throws JspException jsp Exception */ private void initToolBar() throws JspException { String bar = null; if (!GenericValidator.isBlankOrNull(toolbarkey)) { bar = WelcomConfigurator.getMessage(toolbarkey); } if (GenericValidator.isBlankOrNull(bar)) { bar = WelcomConfigurator.getMessage("htmlarea.default.toolbar." + editorType.toLowerCase()); } final StringTokenizer st = new StringTokenizer(bar, "|"); toolbar = new Hashtable(); int i = 0; while (st.hasMoreTokens()) { final String subbar = st.nextToken(); final StringTokenizer st2 = new StringTokenizer(subbar, ","); final Vector v = new Vector(); while (st2.hasMoreTokens()) { v.add(st2.nextToken()); } toolbar.put("bar" + i, v); i++; } }
From source file:org.squale.welcom.taglib.htmlarea.HtmlAreaTag.java
/** * init plugin//from w w w . j a v a 2 s . c o m * * @param sb string buffer * @throws JspException jsp exception */ private void initPlugins(final TrimStringBuffer sb) throws JspException { // Logger log.debug("Type d'diteur : " + editorType); // So on HTML, on charge le plugin CSS if (editorType.equalsIgnoreCase(HTML_EDITOR)) { // ajout un plugin CSS et du ; if (GenericValidator.isBlankOrNull(plugin)) { plugin = "CSS"; } else { plugin += ";CSS"; } } else if (editorType.equalsIgnoreCase(TEXT_EDITOR)) { // A supprimer plus tard, quand on aura webdav if (GenericValidator.isBlankOrNull(plugin)) { plugin = "ContextMenu;DocumentEditor"; } else if (plugin.indexOf("DocumentEditor") < 0) { plugin += ";ContextMenu;DocumentEditor"; } } // charge les plugins // supplementaires if (!GenericValidator.isBlankOrNull(plugin)) { pluginList = new Vector(); // Retrouve la liste des plugins par seperation ; final StringTokenizer st = new StringTokenizer(plugin, ";"); // Insere dans la liste de plugin while (st.hasMoreTokens()) { pluginList.add(st.nextToken()); } // Ecrit la ligne de chargement de plugin dans la page for (final Iterator iter = pluginList.iterator(); iter.hasNext();) { final String plg = (String) iter.next(); sb.append("HTMLArea.loadPlugin(\"" + plg + "\");\n"); } } }
From source file:org.squale.welcom.taglib.htmlarea.HtmlAreaTag.java
/** * @throws JspException jsp exception//from w w w . jav a 2 s . com */ private void writeTextArea() throws JspException { final TrimStringBuffer sb = new TrimStringBuffer(); sb.append("<textarea htmlarea=\"true\" id=\"" + tagname + "\" name=\"" + tagname + "\" rows=\"" + rows + "\""); if (!GenericValidator.isBlankOrNull(width)) { sb.append(" style=\"width:" + formatPx(width) + "\""); } else { sb.append(" cols=\"" + cols + "\""); } sb.append(">\n"); final Object o = RequestUtils.lookup(super.pageContext, name, property, scope); if (o == null) { final JspException e = new JspException("Objet " + name + ", " + property + " introuvable dans le scope : " + scope + " ou n'a pas t initialis"); RequestUtils.saveException(super.pageContext, e); throw e; } if (!(o instanceof String)) { throw new JspException("Le bean doit tre de type String"); } sb.append((String) o); sb.append("</textarea>\n"); ResponseUtils.write(pageContext, sb.toString()); }
From source file:org.squale.welcom.taglib.htmlarea.HtmlAreaTag.java
/** * @throws JspException jsp exception/*w w w .j a va 2 s. c o m*/ */ private void writeContent() throws JspException { final TrimStringBuffer sb = new TrimStringBuffer(); sb.append("<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\""); if (!GenericValidator.isBlankOrNull(width)) { sb.append(" width=\"" + width + "\""); } sb.append("<tr><td>\n"); final Object o = RequestUtils.lookup(super.pageContext, name, property, scope); if (o == null) { final JspException e = new JspException( "Objet " + name + "," + property + " introuvable dans le scope : " + scope); RequestUtils.saveException(super.pageContext, e); throw e; } if (!(o instanceof String)) { throw new JspException("Le bean doit tre de type String"); } sb.append((String) o); sb.append("</td></tr>\n</table>\n"); ResponseUtils.write(pageContext, sb.toString()); }
From source file:org.squale.welcom.taglib.menu.impl.MenuSkinLight.java
/** * @see org.squale.welcom.taglib.menu.IMenuRender#doPrintBase(org.squale.welcom.taglib.menu.JSMenu, int) *//*from w ww . ja va 2 s. co m*/ public String doPrintBase(final JSMenu menu, int level) { String menuId; final StringBuffer buf = new StringBuffer(); boolean horizontal = menu.getOrientation().equals("0"); if (horizontal) { // menu horizontal buf.append("<div id=\"navigationP\"><div id=\"menuH\">"); menuId = getProfondeur(level) + "menuH"; } else { // menu vertical buf.append("<div id=\"menuV\">"); menuId = "smenuV"; } buf.append("<ul><div id=\""); buf.append(menuId); buf.append("\">"); final Iterator iter = menu.itemsIterator(); while (iter.hasNext()) { final JSMenuItem element = (JSMenuItem) iter.next(); level++; if (element.getAction() != null) { buf.append("<li><a href=\""); buf.append(element.getAction()); buf.append("\">"); buf.append(element.getLibelle()); buf.append("</a></li>"); } else { if (element.hasChild()) { buf.append("<li onmouseover=\"montrer('"); buf.append(menuId); buf.append(level); buf.append("');\" onmouseout=\"cacher('"); buf.append(menuId); buf.append(level); buf.append("');\"><a href=\"#\">"); buf.append(element.getLibelle()); if (!horizontal) { buf.append("<div> </div>"); } buf.append("</a>"); buf.append("<ul id=\""); buf.append(menuId); buf.append(level); buf.append("\">"); buf.append((element.doPrint(menu, menu.getName(), level * RECUSIVE_MAGIC_NUMBER, 1))); buf.append("</ul>"); buf.append("</li>"); } else { // N'affiche pas le menu s'il n'y a pas d'action. if (!GenericValidator.isBlankOrNull(element.getAction())) { buf.append("<li><a href=\""); buf.append(element.getAction()); buf.append("\">"); buf.append(element.getLibelle()); buf.append("</a></li>"); } } } } buf.append("</div></ul></div>"); if (menu.getOrientation().equals("0")) { // menu horizontal buf.append("</div>"); } return buf.toString(); }
From source file:org.squale.welcom.taglib.menu.impl.MenuSkinLight.java
/** * @see org.squale.welcom.taglib.menu.IMenuRender#doPrint(org.squale.welcom.taglib.menu.JSMenuItem, * org.squale.welcom.taglib.menu.JSMenuBase, java.lang.String, int, int) */// w ww.j ava 2 s . c o m public String doPrint(final JSMenuItem menuItem, final JSMenuBase parent, final String menuName, int level, int tab) { String menuId; boolean horizontal = ((JSMenu) parent).getOrientation().equals("0"); if (horizontal) { // menu horizontal menuId = getProfondeur(level) + "menuH"; } else { // menu vertical menuId = "menuV"; } final StringBuffer buf = new StringBuffer(); final Iterator iter = menuItem.itemsIterator(); // Affiche pas de menu si ne contient pas d'element if (menuItem.hasChild()) { while (iter.hasNext()) { final JSMenuItem element = (JSMenuItem) iter.next(); level++; if (element.hasChild() && !element.isLast()) { buf.append("<li onmouseover=\"montrer('"); buf.append(menuId); buf.append((level + tab)); buf.append("');\" onmouseout=\"cacher('"); buf.append(menuId); buf.append((level + tab)); buf.append("');\"><a href=\"#\">"); if (horizontal) { buf.append("<span> </span>"); } buf.append(element.getLibelle()); if (!horizontal) { buf.append("<div> </div>"); } buf.append("</a>"); if (horizontal) { buf.append("<div id=\""); buf.append(menuId); buf.append("\">"); } buf.append("<ul id=\""); buf.append(menuId); buf.append((level + tab)); buf.append("\">"); buf.append((element.doPrint(parent, menuName, level * RECUSIVE_MAGIC_NUMBER, tab++))); buf.append("</ul>"); if (horizontal) { buf.append("</div>"); } buf.append("</li>"); } else { // N'affiche pas le menu s'il n'y a pas d'action. if (!GenericValidator.isBlankOrNull(element.getAction())) { buf.append("<li><a href=\""); buf.append(element.getAction()); buf.append("\">"); if (horizontal) { buf.append("<span> </span>"); } buf.append(element.getLibelle()); buf.append("</a></li>"); } } } } return buf.toString(); }
From source file:org.squale.welcom.taglib.menu.impl.MenuSkinV2.java
/** * @see org.squale.welcom.taglib.menu.IMenuRender#doPrintBase(org.squale.welcom.taglib.menu.JSMenu, int) *///from w ww .j a v a2 s . com public String doPrintBase(final JSMenu menu, int level) { menu.setId(level); final Iterator iter = menu.itemsIterator(); final StringBuffer buf = new StringBuffer(); // Vector temporisation = new Vector(); buf.append(menu.getName() + " = new comMenuAF_v2(" + menu.getOrientation() + " , \"t" + menu.getName() + "-" + level + "\");\n"); while (iter.hasNext()) { final JSMenuItem element = (JSMenuItem) iter.next(); if (element.getAction() != null) { buf.append(menu.getName() + ".ajouterElement("); buf.append("\"t" + menu.getName() + "-" + menu.getId()); buf.append("\",\""); buf.append(element.getLibelle()); buf.append("\",\""); buf.append(element.getColor().getId()); buf.append("\",\""); buf.append(element.getAction()); buf.append("\","); buf.append("null"); buf.append(");\n"); } else { if (element.hasChild()) { level++; buf.append(menu.getName() + ".ajouterElement("); buf.append("\"t" + menu.getName() + "-" + menu.getId()); buf.append("\",\""); buf.append(element.getLibelle()); buf.append("\",\""); buf.append(element.getColor().getId()); buf.append("\","); buf.append("null"); buf.append(",\""); buf.append("t" + menu.getName() + "-" + (level * RECUSIVE_MAGIC_NUMBER)); buf.append("\");\n"); buf.append((element.doPrint(menu, menu.getName(), level * RECUSIVE_MAGIC_NUMBER, 1))); } else { // N'affiche pas le menu s'il n'y a pas d'action. if (!GenericValidator.isBlankOrNull(element.getAction())) { buf.append(menu.getName() + ".ajouterElement("); buf.append("\"t" + menu.getName() + "-" + menu.getId()); buf.append("\",\""); buf.append(element.getLibelle()); buf.append("\",\""); buf.append(element.getColor().getId()); buf.append("\",\""); buf.append(element.getAction()); buf.append("\","); buf.append("null"); buf.append(");\n"); } } } } buf.append(menu.getName() + ".construire();\n"); return buf.toString(); }