Java Code Examples for javax.faces.context.ExternalContext#getSessionMap()

The following examples show how to use javax.faces.context.ExternalContext#getSessionMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProductsDAO.java    From primefaces-blueprints with The Unlicense 6 votes vote down vote up
public List<Product> getAllProducts(int first, int pageSize,
		String sortField, String sortOrderValue, Map<String, Object> filters) {
	Session session = getSession();// sessionFactory.openSession();
	session.beginTransaction();

	ExternalContext externalContext = FacesContext.getCurrentInstance()
			.getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	productCategory = (String) sessionMap.get("productCategory");
	String query = null;
	
	Query queryResult=null;
	if (productCategory != "") {
		query = "from Product where prodcat = :productCategory ORDER BY "+sortField+" "+sortOrderValue;
		queryResult = session.createQuery(query);
		queryResult.setParameter("productCategory", productCategory);
	} else {
		query = "from Product ORDER BY "+sortField+" "+sortOrderValue;
	    queryResult = session.createQuery(query);
	}
	List<Product> allProducts = queryResult.list();
	session.getTransaction().commit();
	return allProducts;

}
 
Example 2
Source File: LoginView.java    From Tutorials with Apache License 2.0 5 votes vote down vote up
public String login() {
	FacesContext context = FacesContext.getCurrentInstance();
	HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();

	try {
		request.login(email, password);
	} catch (ServletException e) {
		context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Login failed!", null));
		return "signin";
	}

	Principal principal = request.getUserPrincipal();

	this.user = userEJB.findUserById(principal.getName());

	log.info("Authentication done for user: " + principal.getName());

	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("User", user);

	if (request.isUserInRole("users")) {
		return "/user/privatepage?faces-redirect=true";
	} else {
		return "signin";
	}
}
 
Example 3
Source File: HealthkartController.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
@PostConstruct
public void init() {
	ExternalContext externalContext = FacesContext.getCurrentInstance()
			.getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("productCategory", "");
	lazyLoad();
}
 
Example 4
Source File: AdvisorDAO.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
public AdvisorDAO() {
	super();
	
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	advisorNumber=(String) sessionMap.get("advisornumber");
}
 
Example 5
Source File: DealerDAO.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
public DealerDAO() {
	super();
	
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	dealerNumber=(String) sessionMap.get("dealertinnumber");
	// TODO Auto-generated constructor stub
}
 
Example 6
Source File: TransactionSummaryController.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
public String displayAllTransactions() {
	ExternalContext externalContext = FacesContext.getCurrentInstance()
			.getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("investmentNumber", "");
	return "transactionsummary.xhtml?faces-redirect=true";
}
 
Example 7
Source File: InvestmentSummaryDAO.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
public InvestmentSummaryDAO() {
	super();
	
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	accountNumber=(String) sessionMap.get("accountNumber");
	// TODO Auto-generated constructor stub
}
 
Example 8
Source File: TransactionSummaryDAO.java    From primefaces-blueprints with The Unlicense 5 votes vote down vote up
public TransactionSummaryDAO() {
	super();
	// TODO Auto-generated constructor stub
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	investmentNumber=(String) sessionMap.get("investmentNumber");
}
 
Example 9
Source File: HealthkartController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public void selectCategory(String category) {
	ExternalContext externalContext = FacesContext.getCurrentInstance()
			.getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("productCategory", category);
}
 
Example 10
Source File: DealerController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public String storeSelectedAdvisor(){
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("advisornumber", advisorobj.getAdvisornumber());
	return "advisorinfo.xhtml?faces-redirect=true";
}
 
Example 11
Source File: ServiceCenterController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public String storeSelectedDealer(){
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("dealertinnumber", dealerobj.getDealertinnumber());
	return "dealerinfo.xhtml?faces-redirect=true";
}
 
Example 12
Source File: InvestmentSummaryController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public String storeSelectedInvestornum(){
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("investmentNumber", investmentobj.getInvestmentNumber());
	return "transactionsummary.xhtml?faces-redirect=true";
}
 
Example 13
Source File: InvestmentSummaryController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public String displayAllInvestments(){
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("accountNumber", "");
	return "investmentsummary.xhtml?faces-redirect=true";
}
 
Example 14
Source File: AccountSummaryController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public String storeSelectedAccount(){
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("accountNumber", accountObj.getAccountNumber());
	return "investmentsummary.xhtml?faces-redirect=true";
}
 
Example 15
Source File: AccountSummaryController.java    From primefaces-blueprints with The Unlicense 4 votes vote down vote up
public String displayAllAccounts(){
	ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
	Map<String, Object> sessionMap = externalContext.getSessionMap();
	sessionMap.put("accountNumber", "");
	return "accountsummary.xhtml?faces-redirect=true";
}