Hi,
I'm wondering what solution for that you got boys:
- how should I pass the password and the user login through
beans, as I need both of them to retrieve data form database.
Is good enough to have loginBean.java and then on each bean which
needs connect to db do something like:
FacesContext context = FacesContext.getCurrentInstance();
ValueBinding vb =
context.getApplication().createValueBinding("#{loginBean}");
u = ((UserBean) vb.getValue(context));
userName = u.getLoginName();
passwd = u.getPasswd();
Or better solution will be put user and password to the session like:
FacesContext fc = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession)
fc.getExternalContext().getSession(false);
session.setAttribute("USER", loginName);
and then retrieve it when necessery:
HttpSession session = (HttpSession)
context.getExternalContext().getSession(false);
session.getAttribute("USER");
Thanks for any suggestion!
Tomek