How to preselect an option of h:selectOneMenu

我们两清 提交于 2019-11-28 02:07:32
BalusC

Just preset the property behind <h:selectOneMenu value> with the desired value. You can do it in for example the bean's (post)constructor, action(listener) method, etc.

In your specific example, thus e.g.

public class AuthenticateController {

    private String country;

    @PostConstruct
    public void init() {
        country = "NL";
    }

    // ...
}

It works exactly the same way for all other UIInput components like <h:inputText> and so on. The input component's value itself simply represents the (pre)selected/checked/filled value.

See also:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!