JSF2 – Load Properties File Dentro Bean

Legge un file di properties (configurationFBM) da dentro un Backing Bean:

package com;

import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;

import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;

@ManagedBean
@SessionScoped
public class GalleriaBean {

private ResourceBundle configurationFBM;
private String pathFileUser;

@PostConstruct
public void init() {
FacesContext context = FacesContext.getCurrentInstance();
configurationFBM = context.getApplication().getResourceBundle(context,
“configurationFBM”);
if (this.configurationFBM != null) {
this.pathFileUser = configurationFBM.getString(“pathFileUser”);
}

}

public String getPathFileUser() {
return pathFileUser;
}

public void setPathFileUser(String pathFileUser) {
this.pathFileUser = pathFileUser;
}

}

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *