aspose file tools
The moose likes JSF and the fly likes Creating component in backinbean Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Creating component in backinbean" Watch "Creating component in backinbean" New topic
Author

Creating component in backinbean

Kumar Gaurav
Ranch Hand

Joined: Apr 08, 2008
Posts: 108
Hi All,

Can anyone please provide input on how to create a component, say an inputtext from backingbean.

Please help me out and if possible provide some code also.


Regards,
Gaurav
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 14491
    
    7

Kito Mann has an example or 2 in his "JSF in Action" book.

The easiest way to do this is to bind the component's parent to a backing bean property, then use that property in a setParent operation for the component that you constructed.

For Input text, just invoke the no-argument bean constructor for an HtmlInputText object, then set the properties of the constructed component the same way you would for XML template declarations. EL items (such as the "value" attribute) are a little more complicated, but there are examples floating around on the web that were good enough for me.

CAUTION #1: You can't do the "setParent" operation in the backing bean's constructor, since the property set methods haven't yet been invoked to do the parent component's binding to the backing bean. A PostConstruct method can be used to do this, however.

CAUTION #2: Don't go overboard on this. When a GUI (web or otherwise) gets too dynamic, it confuses the users. So it's often better to simply enable/disable controls than to make them appear and disappear. That, in fact is a major gripe I have with MS Word 2003 - the "Print" menu would vanish on me.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating component in backinbean
 
Similar Threads
do web component exm have The drag and drop
Component Diagram...what's legal
abstract class
Need a Hyperlink component in Android
Accessing requestURI