File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Custom Component with dynamic components. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom Component with dynamic components." Watch "Custom Component with dynamic components." New topic
Author

Custom Component with dynamic components.

Prateek S Negi
Greenhorn

Joined: Mar 03, 2009
Posts: 1
I need recommendation on what is the best way for this requirement.

I need to have a custom jsf component which will be as follows:

We have attributes (these are not tag attributes) defined in the database for various group.
Lets say the group "user", has attributes "name", "phoneNo" defined in the database. The metadata of the attributes contain information about how the attributes are to be displayed and what are the validations it needs.

I need to develop a UI compnent which will do the following
1. Read the meta data for the attributes from the database depending on the group tag-attribute passed to it .
2. Dynamically creates the UIComponents for a attribute depending on its metadata (how it was defined in the database, such as textbox etc )
3. Read the values of the attributes from a datastructure provided by the managed beans.
4. On submit of the page, repopulate the data-structure appropriately with new values after peforming validation as defined in meta-data.

I would think that the custom UI component would be called as this -->
<my:attributes group="user" data="#{managedBean.values}" />

where group is user
and the datastructure (probably a Hashmap) is provided by the attribute "data".

I would think that I would have to create a custom component.
In this custom component , I would dynamically create the UI components provided by JSF , such as one for text box etc . Add validations to it.
How do I get the user submitted values in this case ?

Or should I create a custom component.
The custom component would directly create the html text box etc . I would be handling the validation and mapping to the model (managedBean.values) in my custom component ?

Any ideas would be appreciated, since I am new to JSF

Thanks,
Prateek
 
 
subject: Custom Component with dynamic components.