List of usage examples for java.util ResourceBundle getString
public final String getString(String key)
From source file:it.cilea.osd.common.validation.BaseValidator.java
protected String getValidationMessage(String errors) { String message = ""; if (errors != null && errors.length() != 0) { WebContext ctx = WebContextFactory.get(); MessageSource messageSource = WebApplicationContextUtils .getWebApplicationContext(ctx.getServletContext()); //il messaggio deve essere ripescato dal resource bundle ResourceBundle resourceBundle = ResourceBundle.getBundle(Constants.BUNDLE_KEY, ctx.getHttpServletRequest().getLocale()); message = resourceBundle.getString(errors); }//from w w w. j a v a2 s . c o m return message; }
From source file:it.cilea.osd.common.validation.BaseValidator.java
/** * Get the FieldError validation message from the underlying MessageSource for the given fieldName. * * @param errors The validation errors.//from w ww. j av a 2 s . c om * @param fieldName The fieldName to retrieve the error message from. * @return The validation message or an empty String. */ protected String getValidationMessage(Errors errors, String fieldName) { String message = ""; FieldError fieldError = errors.getFieldError(fieldName); if (fieldError != null) { WebContext ctx = WebContextFactory.get(); MessageSource messageSource = WebApplicationContextUtils .getWebApplicationContext(ctx.getServletContext()); String errore = fieldError.getCode(); //il messaggio deve essere ripescato dal resource bundle ResourceBundle resourceBundle = ResourceBundle.getBundle(Constants.BUNDLE_KEY, ctx.getHttpServletRequest().getLocale()); message = resourceBundle.getString(errore); } return message; }
From source file:org.codehaus.mojo.chronos.chart.SummaryThroughputChartSource.java
private XYPlot createThreadCountPlot(ResourceBundle bundle, ReportConfig config) { TimeSeriesCollection dataset2 = createThreadCountdataset(bundle, config); String label = bundle.getString("chronos.label.threadcount.y"); XYPlot threadCountPlot = ChartUtil.newPlot(dataset2, label, false); threadCountPlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); threadCountPlot.getRenderer().setSeriesPaint(0, Color.GRAY); return threadCountPlot; }
From source file:es.pode.empaquetador.presentacion.avanzado.recursos.importar.ImportarRecursosControllerImpl.java
public final void importarZIP(ActionMapping mapping, es.pode.empaquetador.presentacion.avanzado.recursos.importar.ImportarZIPForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE); ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale); String opcion = form.getAction(); if (opcion.equals(i18n.getString("portalempaquetado.avanzado.recursos.aceptar"))) { FormFile fichero = form.getFichero(); if (fichero.getFileName() == null || fichero.getFileName().equals("") || fichero.getFileSize() == 0) { throw new ValidatorException("{portalempaquetado.avanzado.recursos.importar.exception}"); //tratar exception }//from ww w. ja v a 2 s .c o m try { InternetHeaders ih = new InternetHeaders(); MimeBodyPart mbp = null; DataSource source = null; DataHandler dFichero = null; mbp = new MimeBodyPart(ih, fichero.getFileData()); source = new MimePartDataSource(mbp); dFichero = new DataHandler(source); EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request); List listSubmPath = sesEmpaq.getSubmanifestPath(); //cojo el primer elemento que dedberia ser el padre String identificador = sesEmpaq.getIdLocalizador(); if (listSubmPath.size() == 1) { this.getSrvGestorManifestService().importarRecursos(identificador, dFichero, null); } else if (listSubmPath.size() > 1) { OdeVO odeultim = (OdeVO) listSubmPath.get(listSubmPath.size() - 1); String submanifestId = odeultim.getIdentifier(); this.getSrvGestorManifestService().importarRecursos(identificador, dFichero, submanifestId); } } catch (Exception e) { throw new ValidatorException("{portalempaquetado.avanzado.recursos.importar.exception.validar}"); } } }
From source file:geotheme.servlet.wms.java
@Override public void init() throws ServletException { // TODO Auto-generated method stub super.init(); ResourceBundle rb = ResourceBundle.getBundle("properties.thematic"); String url = rb.getString("GEOSERVER.BASE.URL"); if (url.endsWith("/")) { url = url.substring(0, url.length() - 1); }/*from w w w . j a v a 2 s . c o m*/ this.geoserverURL = url + "/wms"; this.pdfURL = rb.getString("PDF.OSM.URL"); this.pdfLayers = rb.getString("PDF.OSM.LAYERS"); }
From source file:ips1ap101.lib.base.bundle.JRResourceBundleHandler.java
private String getString(ResourceBundle bundle, String key) { try {//w ww . j a v a2s.co m return bundle.getString(key); } catch (MissingResourceException e) { return null; } }
From source file:net.duckling.ddl.web.tag.VisitorTag.java
private String format(Date visitDate, Date now) { ResourceBundle bundle = vwbcontext.getBundle("CoreResources"); String formatPattern;/*from w w w .j a v a 2 s. c om*/ if (AoneTimeUtils.isSameDay(now, visitDate)) { formatPattern = bundle.getString("visitdate.pattern.today"); } else if (AoneTimeUtils.isSameYear(visitDate, now)) { formatPattern = bundle.getString("visitdate.pattern.thisyear"); } else { formatPattern = bundle.getString("visitdate.pattern.other"); } return DateFormatUtils.format(visitDate, formatPattern, pageContext.getRequest().getLocale()); }
From source file:org.shredzone.cilla.admin.ListBean.java
/** * Returns a list of available text format types. *//*from www . j a va2 s.c o m*/ public List<SelectItem> createTextFormatList() { ResourceBundle msg = getResourceBundle(); return Arrays.stream(TextFormat.values()).map(TextFormat::name).map(value -> { String label = msg.getString("select.textformat." + value.toLowerCase()); String description = msg.getString("select.textformat.tt." + value.toLowerCase()); return new SelectItem(value, label, description); }).collect(toList()); }
From source file:com.salesmanager.core.util.ShippingUtil.java
/** * Strip a map of configuration if built as <ID>|<SHIPPING * LABEL>;<ID>|<SHIPPING LABEL> * //from w w w . ja v a2 s . c o m * @param packageline * @return */ public static Map getConfigurationValuesMap(String packageline, String moduleid, Locale locale) { ResourceBundle bundle = ResourceBundle.getBundle(moduleid, locale); Map returnmap = new HashMap(); StringTokenizer st = new StringTokenizer(packageline, ";"); while (st.hasMoreTokens()) { String token = st.nextToken(); StringTokenizer stst = new StringTokenizer(token, "|"); int i = 0; String key = null; while (stst.hasMoreTokens()) { String ptoken = stst.nextToken(); if (i == 0) { key = ptoken; } // get value from bundle String value = bundle.getString("shipping.quote.services.label." + key); if (i == 1 && token.contains("|")) { returnmap.put(key, value); } else { returnmap.put(key, value); } i++; } } return returnmap; }