private static String _getTrDateRestrictionValidator( FacesContext context, UIComponent component, String weekdaysValues, String monthValues, Map<String, String> messages) { StringBuilder outBuffer = new StringBuilder(31 + weekdaysValues.length() + monthValues.length()); outBuffer.append("new TrDateRestrictionValidator("); outBuffer.append(weekdaysValues); outBuffer.append(','); outBuffer.append(monthValues); outBuffer.append(','); if (messages == null) { outBuffer.append("null"); } else { try { JsonUtils.writeMap(outBuffer, messages, false); } catch (IOException e) { outBuffer.append("null"); } } outBuffer.append(')'); return outBuffer.toString(); }
private String _getTrNumberConverter( FacesContext context, UIComponent component, Map<?, ?> messages) { StringBuilder outBuffer = new StringBuilder(250); if (this.isIntegerOnly() && this.getPattern() == null && "number".equals(this.getType())) { outBuffer.append("new TrIntegerConverter("); outBuffer.append("null,null,0,"); outBuffer.append(IntegerUtils.getString(Integer.MAX_VALUE)); outBuffer.append(','); outBuffer.append(IntegerUtils.getString(Integer.MIN_VALUE)); outBuffer.append(")"); } else { Object[] params = _getClientConstructorParams(context, messages); outBuffer.append("new TrNumberConverter("); for (int i = 0; i < params.length; i++) { try { JsonUtils.writeObject(outBuffer, params[i], false); } catch (Exception e) { outBuffer.append("null"); } if (i < params.length - 1) outBuffer.append(','); } outBuffer.append(')'); } return outBuffer.toString(); }
/** * @todo this should have not_in_range messages, not just max and min! * @todo Format these numbers properly. */ public String getClientValidation(FacesContext context, UIComponent component) { String[] weekdaysValue = getInvalidDaysOfWeek(); String weekdaysValues = null; StringBuilder sb1 = new StringBuilder(); String[] monthValue = getInvalidMonths(); String monthValues = null; StringBuilder sb2 = new StringBuilder(); monthValues = sb2.toString(); try { JsonUtils.writeObject(sb1, weekdaysValue, false); weekdaysValues = sb1.toString(); JsonUtils.writeObject(sb2, monthValue, false); monthValues = sb2.toString(); } catch (IOException e) { weekdaysValues = "null"; monthValues = "null"; } String messageDetailDaysOfWeek = this.getMessageDetailInvalidDaysOfWeek(); String messageDetailMonth = this.getMessageDetailInvalidMonths(); String hintWeek = this.getHintInvalidDaysOfWeek(); String hintMonth = this.getHintInvalidMonths(); Map<String, String> cMessages = null; if (messageDetailDaysOfWeek != null || messageDetailMonth != null || hintWeek != null || hintMonth != null) { cMessages = new HashMap<String, String>(); cMessages.put("days", messageDetailDaysOfWeek); cMessages.put("month", messageDetailMonth); cMessages.put("hintWeek", hintWeek); cMessages.put("hintMonth", hintMonth); } return _getTrDateRestrictionValidator( context, component, weekdaysValues, monthValues, cMessages); }