You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2006/09/11 10:43:28 UTC

[Myfaces Wiki] Trivial Update of "Programmatic" by AlekseiValikov

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by AlekseiValikov:
http://wiki.apache.org/myfaces/Programmatic

New page:
= Programmatic manipulation of the components =

This page is for those developers who would like to create JSF-based UIs programmatically.
It covers dynamic creation of components and components trees in the runtime.

== The problem ==

Most people who use JSF build static UIs. That is, they write JSPs or Facelets pages explicitly defining the UIs. Such a page typically consists of a number of tags which actually create the component tree. 

In case of dynamic component creation you don't know your the structure of your page in advance and therefore you can't describe it in any static way. You simply can't design a JSP or Facelets XHTML or anything similar because you simply do not know, which components will make up your page, in which order, and what the structure will be.

The example of such scenario is any model-dirven UI. Imagine you'd like to implement a generic bean editor. You know how to edit string, number, date or whatever properties, but the structure of the generic bean is not known in advance. Therefor you will need to build your component subtree in the runtime.

Building component structures in the runtime has quite a lot of peculiarities. We'll try to gather the information on this topic in this page.
It's community driven, so if you have an idea, a recipe or and advise, please feel free to append.

== Creating and binding components ==

To make your dymanic component structures be visible to the end-user, you basically need to do the following:

 1. Implement a backing bean that creates the component structure and exposes it via a property.
 1. Bind a component to this property in the JSP or Facelets page.