Subversion Repositories Integrator Subversion

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 espaco 1
package br.gov.al.saude.scs.web.managebean.municipio;
2
 
3
import java.io.Serializable;
4
import java.util.ArrayList;
5
import java.util.List;
6
 
7
import javax.faces.bean.ManagedBean;
8
import javax.faces.event.ValueChangeEvent;
9
 
10
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.context.annotation.Scope;
12
import org.springframework.stereotype.Component;
13
 
14
import br.gov.al.saude.framework.core.util.VerificadorUtil;
15
import br.gov.al.saude.scg.model.view.MunicipioView;
16
import br.gov.al.saude.scg.model.view.UfView;
17
import br.gov.al.saude.scs.core.application.municipio.MunicipioFacade;
18
 
19
@Component
20
@ManagedBean
21
@Scope("view")
22
public class MunicipioBean implements Serializable {
23
 
24
        private static final long serialVersionUID = 1L;
25
 
26
        private List<MunicipioView> municipios;
27
 
28
        private MunicipioFacade municipioFacade;
29
 
30
        @Autowired
31
        public MunicipioBean(MunicipioFacade municipioFacade) {
32
                this.municipioFacade = municipioFacade;
33
        }
34
 
35
        public void municipioListener(ValueChangeEvent e){
36
                UfView uf = (UfView) e.getNewValue();
37
 
38
                if(VerificadorUtil.naoEstaNulo(uf)) {
39
                        municipios = municipioFacade.listar(uf.getCodigo());
40
                } else {
41
                        municipios = new ArrayList<MunicipioView>();
42
                }
43
        }
44
 
45
        public void municipioListener1(UfView uf){
46
                if(VerificadorUtil.naoEstaNulo(uf)) {
47
                        municipios = municipioFacade.listar(uf.getCodigo());
48
                } else {
49
                        municipios = new ArrayList<MunicipioView>();
50
                }
51
        }
52
 
53
        public List<MunicipioView> getMunicipios() {
54
                return municipios;
55
        }
56
}