开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜