Example usage for java.util ResourceBundle getBundle

List of usage examples for java.util ResourceBundle getBundle

Introduction

In this page you can find the example usage for java.util ResourceBundle getBundle.

Prototype

@CallerSensitive
public static ResourceBundle getBundle(String baseName, Module module) 

Source Link

Document

Gets a resource bundle using the specified base name and the default locale on behalf of the specified module.

Usage

From source file:com.inkubator.hrm.web.payroll.PayTempOvertimeFormController.java

public void handingFileUpload(FileUploadEvent fileUploadEvent) {
    Map<String, String> results = uploadFilesUtil.checkUploadFileSizeLimit(fileUploadEvent.getFile());
    if (StringUtils.equals(results.get("result"), "true")) {
        file = fileUploadEvent.getFile();
        fileName = file.getFileName();// w  ww  .jav a 2  s .c om
    } else {
        ResourceBundle messages = ResourceBundle.getBundle("Messages",
                new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));
        String errorMsg = messages.getString("global.file_size_should_not_bigger_than") + " "
                + results.get("sizeMax");
        MessagesResourceUtil.setMessagesFromException(FacesMessage.SEVERITY_ERROR, "global.error", errorMsg,
                FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString());
    }

}

From source file:it.cnr.icar.eric.server.util.ServerResourceBundle.java

protected ServerResourceBundle(Locale locale) {
    // Load the resource bundle of specified locale
    bundle = ResourceBundle.getBundle(BASE_NAME, locale);
}

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   ww w .  j  a v  a 2  s .  co  m*/
 * @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:net.nperkins.quizmaster3000.QuizMaster3000.java

/**
 * Set the locale to be used/*www  .ja v  a  2  s.c  om*/
 *
 * @param l a Locale
 */
private void setLocale(Locale l) {
    messages = ResourceBundle.getBundle("Messages", l); //NON-NLS
    if (!messages.getLocale().toString().isEmpty())
        getLogger().info(MessageFormat.format(messages.getString("plugin.localeloaded"), messages.getLocale()));
}

From source file:ldap.LdapClient.java

public LdapClient() throws Exception {
    try {//from ww  w. j  av a2s.  c o m
        resources = ResourceBundle.getBundle("ldap/LdapClient", SessionManager.getSession().getLocale());
    } catch (MissingResourceException e) {
        throw new ServletException("resource bundle not found", e);
    }

    frame = new SFrame("LDAP Client");

    SContainer contentPane = frame.getContentPane();
    tabbedPane = new STabbedPane();
    contentPane.setLayout(null);

    settingsForm = new SForm(new SGridLayout(2));
    tabbedPane.add(settingsForm, resources.getString("provider"));

    urlTextField = new STextField();
    urlTextField.setColumns(columns);
    urlTextField.setText((String) SessionManager.getSession().getProperty("java.naming.provider.url"));
    settingsForm.add(new SLabel(resources.getString("provider.url")));
    settingsForm.add(urlTextField);

    basednTextField = new STextField();
    basednTextField.setColumns(columns);
    basednTextField.setText((String) SessionManager.getSession().getProperty("java.naming.provider.basedn"));
    settingsForm.add(new SLabel(resources.getString("provider.basedn")));
    settingsForm.add(basednTextField);

    binddnTextField = new STextField();
    binddnTextField.setColumns(columns);
    binddnTextField.setText((String) SessionManager.getSession().getProperty("java.naming.security.principal"));
    settingsForm.add(new SLabel(resources.getString("provider.binddn")));
    settingsForm.add(binddnTextField);

    passwordTextField = new SPasswordField();
    passwordTextField.setColumns(columns);
    passwordTextField
            .setText((String) SessionManager.getSession().getProperty("java.naming.security.credentials"));
    settingsForm.add(new SLabel(resources.getString("provider.password")));
    settingsForm.add(passwordTextField);

    connectButton = new SButton(resources.getString("provider.connect"));
    disconnectButton = new SButton(resources.getString("provider.disconnect"));
    disconnectButton.setVisible(false);
    settingsForm.add(connectButton);
    settingsForm.add(disconnectButton);

    mainPanel = new SPanel();

    try {
        mainPanel.setLayout(new STemplateLayout(getClass().getResource("ldapclientlayout.html")));
    } catch (Exception e) {
        logger.warn("no template", e);
        mainPanel.setLayout(new SFlowLayout());
    }

    tabbedPane.add(mainPanel, resources.getString("browser"));

    createTreeModel(null);
    tree = new STree(treeModel);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(this);

    SessionManager.getSession().setProperty("tree", tree);

    editPanel = new EditObjectPanel();
    mainPanel.add(tree, "tree");
    mainPanel.add(editPanel, "editor");

    addPanel = new AddObjectPanel();
    tabbedPane.add(addPanel, resources.getString("add"));

    contentPane.add(tabbedPane);

    connectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            Session session = SessionManager.getSession();

            String url = urlTextField.getText();
            if (url != null && url.length() > 0)
                session.setProperty("java.naming.provider.url", url);

            String basedn = basednTextField.getText();
            if (basedn != null && basedn.length() > 0)
                session.setProperty("java.naming.provider.basedn", basedn);

            String binddn = binddnTextField.getText();
            if (binddn != null && binddn.length() > 0)
                session.setProperty("java.naming.security.principal", binddn);

            String password = passwordTextField.getText();
            if (password != null && password.length() > 0)
                session.setProperty("java.naming.security.credentials", password);

            try {
                context = new InitialDirContext(new Hashtable(session.getProperties()));
                createTreeModel(context);
                tree.setModel(treeModel);
                tabbedPane.setSelectedIndex(1);

                urlTextField.setVisible(true);
                basednTextField.setVisible(true);
                binddnTextField.setVisible(true);
                passwordTextField.setVisible(true);

                connectButton.setVisible(true);
                disconnectButton.setVisible(false);
                passwordTextField.setText(null);
            } catch (NamingException e) {
                passwordTextField.setText(null);
                logger.warn("no initial context", e);
            }
        }
    });

    disconnectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            createTreeModel(null);
            tree.setModel(treeModel);

            urlTextField.setVisible(false);
            basednTextField.setVisible(false);
            binddnTextField.setVisible(false);
            passwordTextField.setVisible(false);

            connectButton.setVisible(false);
            disconnectButton.setVisible(true);
            passwordTextField.setText(null);
        }
    });

    frame.show();
}

From source file:org.keyboardplaying.xtt.ui.i18n.I18nHelper.java

protected void updateResourceBundle(Locale locale) {
    this.bundle = ResourceBundle.getBundle(BUNDLE_BASE_NAME, locale);
}

From source file:it.cnr.icar.eric.client.admin.AdminResourceBundle.java

protected AdminResourceBundle(Locale locale) {
    // Load the resource bundle of specified locale
    bundle = ResourceBundle.getBundle(BASE_NAME, locale);
}

From source file:ambroafb.general.GeneralConfig.java

private ResourceBundle loadBundle(Locale locale) {
    return ResourceBundle.getBundle(Names.BUNDLE_TITLES_NAME, locale);
}

From source file:es.pode.administracion.presentacion.planificador.informeTrabajo.InformeControllerImpl.java

public final void obtenerInformeTrabajo(ActionMapping mapping, ObtenerInformeTrabajoForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {

    try {//from  www .j  a va  2s .  c o m
        Long informe = null;

        ficheroRecursos = ResourceBundle.getBundle("application-resources", request.getLocale());

        if (form instanceof InformeFormImpl)
            informe = ((InformeFormImpl) form).getId();
        else
            informe = ((MostrarDescripcionVolverFormImpl) form).getId();

        RegistroTareaEjecutadaVO[] informeTrabajo = this.getSrvPlanificadorService()
                .obtenerInformeTrabajo(informe);

        RegistroTareaEjecutadaDate[] registroTareasDate = null;

        if (informeTrabajo != null) {
            registroTareasDate = cambiarFormatoRegistroTareas(informeTrabajo, informe);
            form.setInformeTrabajoAsArray(registroTareasDate);
        }

        /* Cabecera del informe */
        TareaEjecutadaVO cabecera = this.getSrvPlanificadorService().obtenerTrabajoEjecutado(informe);

        /**
            * Recortamos el nombre de la tarea quitandole lo agregado al
            * nombre original Lo agregado son dos # seguidas de la fecha en
            * la que se ejecuta la tarea La fecha se compone de
            * "ao+mes+dia+hora+minutos+segundos"
            */
        int posicion = cabecera.getTrabajo().indexOf("!!");

        if (posicion > 0)
            form.setTrabajo(cabecera.getTrabajo().substring(0, posicion));
        else
            form.setTrabajo(cabecera.getTrabajo());

        form.setDescripcion(cabecera.getDescripcion());

        SimpleDateFormat formato = new SimpleDateFormat("dd/MM/yyyy, HH:mm");

        if (log.isDebugEnabled())
            log.debug("cabecera.getFechaInicio()" + cabecera.getFechaInicio());
        String fechaInicio = formato.format(cabecera.getFechaInicio().getTime());
        form.setFechaInicio(fechaInicio);
        //log("fecha inicio despues del set" + form.getFechaInicio());

        if (cabecera.getFechaFin() != null)
            form.setFechaFin(formato.format(cabecera.getFechaFin().getTime()));

    } catch (Exception e) {
        log.error("Error: " + e);
        throw new ValidatorException("{tareas.error}");
    }
}

From source file:es.pode.modificador.presentacion.configurar.cambios.modificar.ModificarTerminoControllerImpl.java

/**
 * @see es.pode.modificador.presentacion.configurar.cambios.modificar.ModificarTerminoController#selectAction(org.apache.struts.action.ActionMapping, es.pode.modificador.presentacion.configurar.cambios.modificar.SelectActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//* ww w .j a  va 2 s. c  om*/
public final java.lang.String selectAction(ActionMapping mapping,
        es.pode.modificador.presentacion.configurar.cambios.modificar.SelectActionForm form,
        HttpServletRequest request, HttpServletResponse response) throws Exception {
    String origen = form.getAction();

    String result = "";
    java.util.Locale locale = (java.util.Locale) request.getSession()
            .getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);
    // Introduzco en el objeto de sesion la opcion elegida

    if (origen.equals(i18n.getString("modificarTermino.aceptar"))) {

        result = "Aceptar";

    } else if (origen.equals(i18n.getString("modificarTermino.volver"))) {
        result = "Volver";
    } else if (origen.equals(i18n.getString("modificarTermino.cancelar"))) {
        result = "Cancelar";
    }

    return result;
}