jsf and controller, bean
I want to learn that if I can define user input parameters at bean class and take these input parameters from a controller function with submit button :
for example input jsp :
<h:inputSecret value="#{control.userObj.pwrd}"></h:inputSecret>
<开发者_JAVA百科;h:commandButton type="submit" value="Giris" action="#{control.check}">
</h:commandButton>
"User" bean class :
private String userName; (with getter and setter)
"Control" controller class :
private User userObj;
When using nested bean properties, then you need to prepare it yourself so that JSF can call the setters on it. JSF/EL namely won't prepare them for you.
public class Control {
private User userObj;
@PostConstruct
public void init() {
userObj = new User();
}
// ...
}
This way #{control.userObj.userName}
will work in input fields.
See also:
- JSF 2.0 Hello World - The Model, Controller and View
精彩评论