Java – JSF inputtext and sessions in JSF managed beans
•
Java
I want to know how to read the value of the input text from the managed bean
@H_ 502_ 9@
@H_ 502_ 9@
<h:inputText id="username" value="#{mylogin.username}" required="true" />
But if I say I have a value like this @ H_ 502_ 9@
@H_ 502_ 9@
<h:inputText id="username" value="some_value" required="true" />
I want to read this "some_value" in my managed bean Is it possible@ H_ 502_ 9@
Another question is whether session variables in managed beans can be accessed, or should they be passed there in some way@ H_ 502_ 9@
Solution
In the latter case, some_ With all due respect, value is not managed by beans Nevertheless, you can read To do such a thing,
@H_ 502_ 9@
@H_ 502_ 9@
FacesContext ctx = FacesContext.getCurrentInstance(); HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getRequest(); request.getParameter("username");
Similarly, for accessing session variables, @ h_ 502_ 9@
@H_ 502_ 9@
FacesContext ctx = FacesContext.getCurrentInstance(); HttpServletRequest request = (HttpServletRequest)ctx.getExternalContext().getSession(false);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码