How to set default value of h:selectOneRadio button

前端 未结 4 2176
梦毁少年i
梦毁少年i 2021-02-19 21:28

I am unable to set the default value of h:selectOneRadio as i need radio button to be pre selected



        
4条回答
  •  不要未来只要你来
    2021-02-19 21:59

    You need to set the default value in the init method of your backing bean:

    @ManagedBean
    public class YourBackingBean implements Serializable {
    
        private String addressFlag;
    
        @PostConstruct
        public void init() {
            addressFlag = "0";
        }
    
        public String getAddressFlag() {
            return addressFlag;
        }
    
        public void setAddressFlag(String addressFlag) {
            this.addressFlag = addressFlag;
        }
    }
    

提交回复
热议问题