/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.triz.trizservice.bean;

import com.triz.trizservice.modeles.ServiceUser;
import com.triz.trizservice.service.TransactionService;
import com.triz.util.UtilContext;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 *
 * @author Asma
 */

@Component("userBean")
@Scope("view")
public class UserBean {
    private ServiceUser user;
    private ServiceUser userSelected;
    private List<ServiceUser> listeUser;
    
    @Autowired
    public TransactionService service;
    
    @Autowired
    public UtilContext context;
    
    public void init() {
        System.out.println("//--------------init()ClientBean ");
        user = context.getCurrentUser();
        listeUser = service.getAllUsers();
        System.out.println("listeClient: "+listeUser);
    }
    
    public String ajouterUser() {
        return "form.xhtml?faces-redirect=true&canEdit=true";
    }
    
    public String voirUser() {
        return "form.xhtml?faces-redirect=true&user1=" + userSelected.getUserid();
    }

    public ServiceUser getUser() {
        return user;
    }

    public void setUser(ServiceUser user) {
        this.user = user;
    }

    public ServiceUser getUserSelected() {
        return userSelected;
    }

    public void setUserSelected(ServiceUser userSelected) {
        this.userSelected = userSelected;
    }

    public List<ServiceUser> getListeUser() {
        return listeUser;
    }

    public void setListeUser(List<ServiceUser> listeUser) {
        this.listeUser = listeUser;
    }
}
