Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Adminpage;
- import java.io.Serializable;
- import java.util.HashMap;
- import java.util.Map;
- import javax.annotation.PostConstruct;
- import javax.faces.application.FacesMessage;
- import javax.faces.bean.ManagedBean;
- import javax.faces.bean.ViewScoped;
- import javax.faces.context.FacesContext;
- import javax.inject.Inject;
- import Security.C_SecurityGroup;
- import Security.C_SecurityGroup_JSF;
- import Security.C_Test;
- import Security.I_getSecurityGroup;
- @ManagedBean
- @ViewScoped
- public class B_AdminAddUser implements Serializable {
- private static final long serialVersionUID = 1L;
- private Map<String,Map<String,String>> data = new HashMap<String, Map<String,String>>();
- private String vorname;
- private String nachname;
- private String email;
- private String username;
- private String passwort;
- private String confirmation;
- private String securitygroup;
- private String markt;
- private String country;
- private String city;
- private Map<String,String> countries;
- private Map<String,String> cities;
- private static Map<String, C_SecurityGroup_JSF> securitygroups;
- private Map<String, M_Markt_JSF> marketlist;
- @Inject
- I_getSecurityGroup getsecgroup;
- @Inject
- I_getMarkets getmarkets;
- @Inject
- I_UserService userservice;
- @PostConstruct
- public void init() {
- countries = new HashMap<String, String>();
- countries.put("USA", "USA");
- countries.put("Germany", "Germany");
- countries.put("Brazil", "Brazil");
- Map<String,String> map = new HashMap<String, String>();
- map.put("New York", "New York");
- map.put("San Francisco", "San Francisco");
- map.put("Denver", "Denver");
- data.put("USA", map);
- map = new HashMap<String, String>();
- map.put("Berlin", "Berlin");
- map.put("Munich", "Munich");
- map.put("Frankfurt", "Frankfurt");
- data.put("Germany", map);
- map = new HashMap<String, String>();
- map.put("Sao Paolo", "Sao Paolo");
- map.put("Rio de Janerio", "Rio de Janerio");
- map.put("Salvador", "Salvador");
- data.put("Brazil", map);
- }
- public Map<String, Map<String, String>> getData() {
- return data;
- }
- public String getMarkt() {
- return markt;
- }
- public void setMarkt(String markt) {
- this.markt = markt;
- }
- public Map<String, M_Markt_JSF> getMarketlist() {
- marketlist = getmarkets.getMarkets();
- return marketlist;
- }
- public void setMarketlist(Map<String, M_Markt_JSF> marketlist) {
- this.marketlist = marketlist;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getUsername() {
- return username;
- }
- public void setUsername(String username) {
- this.username = username;
- }
- public String getPasswort() {
- return passwort;
- }
- public void setPasswort(String passwort) {
- this.passwort = passwort;
- }
- public String getConfirmation() {
- return confirmation;
- }
- public void setConfirmation(String confirmation) {
- this.confirmation = confirmation;
- }
- public Map<String, C_SecurityGroup_JSF> getSecuritygroups() {
- securitygroups = getsecgroup.getSecurityGroups();
- return securitygroups;
- }
- public void setSecuritygroups(Map<String, C_SecurityGroup_JSF> securitygroups) {
- this.securitygroups = securitygroups;
- }
- public String getSecuritygroup() {
- return securitygroup;
- }
- public void setSecuritygroup(String securitygroup) {
- this.securitygroup = securitygroup;
- }
- public String getNachname() {
- return nachname;
- }
- public void setNachname(String nachname) {
- this.nachname = nachname;
- }
- public String getVorname() {
- return vorname;
- }
- public void setVorname(String vorname) {
- this.vorname = vorname;
- }
- public String getCountry() {
- return country;
- }
- public void setCountry(String country) {
- this.country = country;
- }
- public String getCity() {
- return city;
- }
- public void setCity(String city) {
- this.city = city;
- }
- public Map<String, String> getCountries() {
- return countries;
- }
- public Map<String, String> getCities() {
- return cities;
- }
- public void onCountryChange() {
- if(country !=null && !country.equals(""))
- cities = data.get(country);
- else
- cities = new HashMap<String, String>();
- }
- public void checknewuser(){
- FacesMessage msg;
- if (passwort.equals(confirmation) == false){
- msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid", "Passwords do not match");
- }
- else{
- msg = new FacesMessage("Erfolgreich!", "Neuer User: " + username + " wurde angelegt!");
- }
- FacesContext.getCurrentInstance().addMessage(null, msg);
- }
- public void displayLocation() {
- FacesMessage msg;
- if(city != null && country != null)
- msg = new FacesMessage("Selected", city + " of " + country + " Vorname: " + vorname);
- else
- msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid", "City is not selected.");
- FacesContext.getCurrentInstance().addMessage(null, msg);
- }
- public void newuser(){
- userservice.adduser(vorname, nachname, email, username, passwort, markt, securitygroup);
- }
- }
Add Comment
Please, Sign In to add comment