Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package be.fgov.minfin.webForm.backing; import be.fgov.minfin.ccff.fwk.logging.api.Logger; import be.fgov.minfin.ccff.fwk.logging.api.LoggerFactory; import java.util.ResourceBundle; import javax.annotation.PostConstruct; import javax.faces.application.Application; import javax.faces.application.FacesMessage; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.ViewScoped; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.validator.ValidatorException; import org.apache.commons.validator.routines.checkdigit.IBANCheckDigit; /** * * @author gbeurnea */ @ManagedBean(name = "masterCdcBean") @ViewScoped public class MasterCdcbean { private String nomCompte; private String numCompte; private String site; private boolean moduleCompte = false; private boolean moduleMontant = false; @ManagedProperty(value = "#{authentificationCdcBean}") private AuthentificationCdcBean authentificationCdcBean; @PostConstruct public void init() { site = authentificationCdcBean.getSite(); if (site.equals("cantonnement")) { moduleCompte = true; } if (site.equals("test")) { moduleCompte = true; moduleMontant = true; } } /* Vrifie si le comte bancaire est correcte */ public void checkDigit(FacesContext context, UIComponent component, Object value) throws ValidatorException { Application app = FacesContext.getCurrentInstance().getApplication(); ResourceBundle bundle = app.getResourceBundle(FacesContext.getCurrentInstance(), "CdcMessages"); IBANCheckDigit ibancheck = new IBANCheckDigit(); String numComptAValider1 = (String) value; String numComptAValider = numComptAValider1.replaceAll(" ", "").trim(); if (ibancheck.isValid(numComptAValider) == false) { throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, bundle.getString("liquiacte.numcompte.error"), "")); } } public AuthentificationCdcBean getAuthentificationCdcBean() { return authentificationCdcBean; } public void setAuthentificationCdcBean(AuthentificationCdcBean authentificationCdcBean) { this.authentificationCdcBean = authentificationCdcBean; } public String getNomCompte() { return nomCompte; } public void setNomCompte(String nomCompte) { this.nomCompte = nomCompte; } public String getNumCompte() { return numCompte; } public void setNumCompte(String numCompte) { this.numCompte = numCompte; } public boolean isModuleCompte() { return moduleCompte; } public void setModuleCompte(boolean moduleCompte) { this.moduleCompte = moduleCompte; } public String getSite() { return site; } public void setSite(String site) { this.site = site; } public boolean isModuleMontant() { return moduleMontant; } public void setModuleMontant(boolean moduleMontant) { this.moduleMontant = moduleMontant; } }