That method requires that you identify all JSF components and write them into your JSF pages.
What if the dynamic elements cannot be identified until run time?
Swing already provides a mature way to automatically update the GUI based solely on the internal data status, but JSF does not have good support for refreshing the GUI based on a request from the server side.
If you check the standard life cycle of JSF, you will find that the user normally needs to produce an event on the Web page (by clicking a button, for example) to invoke the GUI refresh.
It clears all dynamic elements created previously, creates new dynamic elements based on the new data model, and adds them to the predefined parent.
However, this method also has a limitation because of its ease: it can only be used when the element to be removed or inserted has a fixed parent that is known before run time.
I choose this method (see Listing 5) because the parent of the category links is fixed and predefined in the example.
The inventory information such as book categories and the number of books in each category is displayed in the Web home page (see Figure 1).
View image at full size To reflect accurate information, you need to synchronize the inventory information of the page with the server-side data in real time.