Dynamic choice of bean in EL

前端 未结 2 1509
北海茫月
北海茫月 2021-01-14 07:33

Is there a way to specify a managed bean used in EL at runtime and not design time? E.g. actionListener=\"#{myBean.method}\" such that myBean part

2条回答
  •  轮回少年
    2021-01-14 08:18

    If your question refers to generating a set of pages for a number of subclasses with common elements you can also use page composition to achieve this.

    For example if Resident and NonResident are managed beans for subclasses of Person:

    eg. in 'non-resident.xhtml'

    
        
        
    
    

    and in 'resident.xhtml'

    
        
        
    
    

    then 'anyone.xhtml' can define the common elements using 'Controller' for the bean name.

    This approach also enables you to eliminate duplicate page definition.

提交回复
热议问题