How to dynamically add JSF components

前端 未结 3 2182
-上瘾入骨i
-上瘾入骨i 2020-11-22 05:22

Can I add JSF components dynamically? I need to have a form with a button which should add one to the form. Is this possible?

I know

3条回答
  •  眼角桃花
    2020-11-22 06:21

    It's should be like that

    Bind a form tag to the bean property

    
    
    ...
    
    @ManagedBean("myBean")
    public class Bean{
       property HtmlForm myform;
    }

    on event, create a new instance of the input component

    HtmlInputText input=new HtmlInputText();

    and attach to the your form

    myform.getChildren().add(input);

提交回复
热议问题