Adding a JSF 2 compound component at run time from a backup bean

Edited Question ...

Hello,

I would like to download the .xhtml file of my composite component from a bean backup and add it to the page dynamically. The name of the .xhtml file is in the form of a variable.

Example:.

public MyBean (){

    String componentFile = "myCompositeComponent.xhtml"

    public String addComponentToPage(){

          //how do that?...

          return null;
    }

} 

Thank!

+3
source share
2 answers

. . JSF, . @FacesComponent , UIComponent, @FacesRenderer. , , , , .

- rendered.

<my:component1 rendered="#{bean.myComponentType == 'component1'}" />
<my:component2 rendered="#{bean.myComponentType == 'component2'}" />
<my:component3 rendered="#{bean.myComponentType == 'component3'}" />
...

, , Facelets, .

+5

, bean. , , AJAX reRender.

, :

<h:panelGroup id="composite" rendered="#{myBean.renderComponent}">
    <my:compositecomponent/>
</h:panelGroup>

renderComponent boolean. reRender composite , , Richfaces <a4j:commandLink>.

, ,

0

Source: https://habr.com/ru/post/1772532/


All Articles