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.field.BaseDateHeureTag.java
/** * Retourne si le check a etait mis en place le supprime la cas echeant * /*from w w w . j av a2s . co m*/ * @return si le check a etait mis en place */ private boolean isCheckEnabled() { if (checkEnabled == false && getOnchange() != null) { // String regExpFunctJS = "checkValue\\([\\w,\\s'\\)\\(]*\\);"; String regExpFunctJS = "checkValue\\([\\w\\s[\\'.\\'],\\.\\[\\]]*\\);"; String s = getOnchange().replaceAll(regExpFunctJS, ""); checkEnabled = !getOnchange().equals(s); if (GenericValidator.isBlankOrNull(s)) { setOnchange(null); } else { setOnchange(s); } } return checkEnabled; }
From source file:org.squale.welcom.taglib.field.BaseDateHeureTag.java
/** * Retourne l'id du calendrier// w w w .jav a2 s .co m * * @return retourne l'id du calendrier */ protected String getCalendarId() { if (!GenericValidator.isBlankOrNull(super.id)) { return super.id; } String temp = getParameterNameInRequest(TYPE_WDATE); String id = ""; for (int ind = 0; ind < temp.length(); ind++) { final char c = temp.charAt(ind); if ((c != '.') && (c != '[') && (c != ']')) { id = id + c; } } return id; }
From source file:org.squale.welcom.taglib.field.BaseDateHeureTag.java
/** * Affiche le calendrier// www .j a v a 2s . co m * * @param results buffer * @param id id du field */ protected void doRenderCalendar(final StringBuffer results, final String id) { results.append("<a href=\"#\""); if (WelcomConfigurator.getCharte() == Charte.V3_001) { results.append(" class=\"nobottom\""); } results.append(" id=\"ancreimagecalendrier\" onclick=\"this.blur()\">"); results.append("<img src=\""); results.append(WelcomConfigurator.getMessage(WelcomConfigurator.OPTIFLUX_COMPRESSION_PREFIX_IMG)); results.append(WelcomConfigurator.getMessageWithCfgChartePrefix(".calendrier.gif")); results.append("\" altKey=\"welcom.internal.tooltip.selDate\" border=\"0\" align=\"absmiddle\""); results.append(" onclick=\"javascript:afficherCalendrier('"); results.append(WelcomConfigurator.getMessage(WelcomConfigurator.OPTIFLUX_COMPRESSION_PREFIX_HTML)); results.append(WelcomConfigurator.getMessageWithCfgChartePrefix(".calendrier.html")); results.append("',document.getElementById('"); results.append(id); results.append("')"); final String beginYear = WelcomConfigurator.getMessage(WelcomConfigurator.CALENDAR_DEFAULT_BEGIN_YEAR); if ((calendarBeginYear == 0) && !GenericValidator.isBlankOrNull(beginYear)) { calendarBeginYear = Integer.parseInt(beginYear); } final String endYear = WelcomConfigurator.getMessage(WelcomConfigurator.CALENDAR_DEFAULT_END_YEAR); if ((calendarEndYear == 0) && !GenericValidator.isBlankOrNull(endYear)) { calendarEndYear = Integer.parseInt(endYear); } results.append(",null,null,"); if (calendarBeginYear > 0) { results.append(calendarBeginYear); results.append(","); } else { results.append("null,"); } if (calendarEndYear > 0) { results.append(calendarEndYear); } else { results.append("null"); } results.append(",'"); results.append(getDateOrHourPattern(TYPE_WDATE)); results.append("'"); if (!((Locale) pageContext.getSession().getAttribute(Globals.LOCALE_KEY)).getLanguage().equals("fr")) { results.append(",'en'"); } results.append(" );return false;\"></a>"); }
From source file:org.squale.welcom.taglib.field.BaseDateHeureTag.java
/** * Retrouve la valeur si elle viens suite a une soumission avec erreur * /*w w w .jav a 2s . c o m*/ * @param typeOfElement type TYPE_WDATE / TYPE_WHOUR * @return la valeur statock en requete */ private String doRenderValueFromError(int typeOfElement) { SimpleDateFormat sdf = getSimpleDateOrHourFormat(typeOfElement); String valString = pageContext.getRequest().getParameter(getParameterNameInRequest(typeOfElement)); if (!GenericValidator.isBlankOrNull(valString)) { try { sdf.setLenient(false); sdf.parse(valString); } catch (ParseException e) { return valString; } } return ""; }
From source file:org.squale.welcom.taglib.field.BaseDateHeureTag.java
/** * Met a jour le les simple date format pour l'heure * /*from ww w .j ava 2 s . c o m*/ * @param resources Resources * @param localeRequest locale * @param hashMap hashmap des formats de clefs ... */ protected void updateSimpleDateFormat(final int currentType, final MessageResources resources, final Locale localeRequest, HashMap hashMap) { String hourOrDateFormatTmp; if (!GenericValidator.isBlankOrNull(getFormatKeyDateOrHourFormat(currentType))) { hourOrDateFormatTmp = resources.getMessage(localeRequest, getFormatKeyDateOrHourFormat(currentType)); } else if (!GenericValidator.isBlankOrNull(getFormatDateOrHourFormat(currentType))) { hourOrDateFormatTmp = getFormatDateOrHourFormat(currentType); } else { hourOrDateFormatTmp = getDefaultFormatDateOrHour(currentType); } // Garde le mode de compatibilit // On ne renseign dans le dictionnaire pour conversion que // si le mode legacy est activ ou bien si on a spci un dateformatkey if (Util.isFalse(WelcomConfigurator.getMessage(WelcomConfigurator.DATE_USE_LEGACY)) || !GenericValidator.isBlankOrNull(getFormatKeyDateOrHourFormat(currentType))) { hashMap.put(getParameterNameInRequest(currentType), hourOrDateFormatTmp); } setDateOrHourPattern(currentType, hourOrDateFormatTmp); saveSimpleDateFormatsForDateOrHour(currentType, new java.text.SimpleDateFormat(hourOrDateFormatTmp)); }
From source file:org.squale.welcom.taglib.field.BaseFieldTag.java
/** * Append the title of the field to the buffer * /*w w w . ja v a 2 s .c om*/ * @param buffer le stringbuffer * @throws JspException exception pouvant etre levee */ protected void beginField(final StringBuffer buffer) throws JspException { doRenderLabel(buffer); if (writeTD) { buffer.append("<td"); if (!GenericValidator.isBlankOrNull(styleClass)) { buffer.append(" class=\"" + styleClass + "\""); } if (!GenericValidator.isBlankOrNull(colspan)) { buffer.append(" colspan=\"" + colspan + "\""); } if (!GenericValidator.isBlankOrNull(width)) { buffer.append(" width=\"" + width + "\""); } buffer.append(" valign=\"middle\">"); } }
From source file:org.squale.welcom.taglib.field.BaseFieldTag.java
/** * Gre le label/*from w w w.j av a 2s. co m*/ * * @param buffer le Stringbuffer * @throws JspException exception pouvant etre levee */ private void doRenderLabel(final StringBuffer buffer) throws JspException { if (hasLabel()) { if (writeTD) { buffer.append("<td"); /* * if (WelcomConfigurator.getCharte()==Charte.V3_001 && "td1".equals(styleClassLabel)) { * logger.info("Supprimer 'styleclass=td1' dans la page JSP"); styleClassLabel="right"; } */ if (GenericValidator.isBlankOrNull(styleClassLabel)) { if (WelcomConfigurator.getCharte() == Charte.V3_001) { styleClassLabel = "right"; } else if (WelcomConfigurator.getCharte() == Charte.V2_002) { styleClassLabel = "td1"; } else { styleClassLabel = "formtdr"; } } buffer.append(" class=\"" + styleClassLabel + "\""); if (!GenericValidator.isBlankOrNull(widthLabel)) { buffer.append(" width=\"" + widthLabel + "\""); } if (!GenericValidator.isBlankOrNull(colspanLabel)) { buffer.append(" colspan=\"" + colspanLabel + "\""); } buffer.append(">"); } // ecrit le libell writeLabel(buffer); // ecrit le td final if (writeTD) { buffer.append("</td>"); } } }
From source file:org.squale.welcom.taglib.field.DateHeureTag.java
/** * @param newDateFormat le dateFormat/* ww w .ja va2s.com*/ */ public void setDateFormat(final java.lang.String newDateFormat) { if (GenericValidator.isBlankOrNull(newDateFormat)) { dateFormat = getDefaultFormatDateOrHour(TYPE_WDATE); } else { dateFormat = newDateFormat; } }
From source file:org.squale.welcom.taglib.field.DateHeureTag.java
/** * @param newHourFormat le hourFormat// w w w .j a va2 s . c o m */ public void setHourFormat(final java.lang.String newHourFormat) { if (GenericValidator.isBlankOrNull(newHourFormat)) { hourFormat = getDefaultFormatDateOrHour(TYPE_WHOUR); } else { hourFormat = newHourFormat; } // simpleHourFormat = new java.text.SimpleDateFormat(hourFormat); }
From source file:org.squale.welcom.taglib.field.FieldTag.java
/** * @see javax.servlet.jsp.tagext.Tag#doStartTag() *///from w w w. j a va 2 s . com public int doStartTag() throws JspException { // Recupere le droit sur la page final String pageAccess = getPageAccess(); if (((pageAccess != null) && pageAccess.equals(READONLY) && (forceReadWrite == false)) || ((access != null) && access.equals("READONLY"))) { access = READONLY; if (GenericValidator.isBlankOrNull(styleClass)) { styleClass = "normalBold"; } } // Verifcation que le pres-requis d'inclusion dans une colonne est correct checkColInclusion(); // Check for WriteTD checkWriteTD(); final StringBuffer buffer = new StringBuffer(); // display the label beginField(buffer); // get the error if any and print the html tags error = retrieveError(); if ((error != null) && access.equals(READWRITE)) { buffer.append("<span class=\"redtextecourant\">"); } ResponseUtils.write(pageContext, buffer.toString()); buffer.setLength(0); if (Util.isTrue(WelcomConfigurator.getMessage(WelcomConfigurator.GENIAL_FIELD))) { fieldTag = createSpecificIntelligentField(); // initialize the tag LayoutUtils.copyProperties(fieldTag, this); fieldTag.doStartTag(); fieldTag.doEndTag(); } else { // create the corresponding tag // maybe having a pool of tags would be better if (access.equals(READSEND)) { type = "hidden"; } Object objvalue = writeOldField(buffer); // display an image if a value is needed if (objvalue == null) { objvalue = ""; } } // display the error if any if ((error != null) && access.equals(READWRITE)) { buffer.append(error); buffer.append("</span>"); } // ajoute l'toile en V2 buffer.append(addRequiredField()); ResponseUtils.write(pageContext, buffer.toString()); return EVAL_BODY_INCLUDE; }