File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes create UIComponent by java code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "create UIComponent by java code" Watch "create UIComponent by java code" New topic

create UIComponent by java code

liliane fahmy

Joined: Aug 24, 2012
Posts: 22
Hi all,

Please I want to know how to create UIcomponent on the JSF page by java code.

I tried to use addComponentResource invoked from action method,but it didn't work anymore ,here you are the code:

and from the jsf page

There is something wrong or i must do it by another way?
Please help me.

Thanks and best regards
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

It's usually best not to create UIComponents in Java code. As I've said many times, the more JSF-specific your code is, the more likely you're doing it wrong. JSF was designed to work as much as possible with generic POJOs.

When it cannot be avoided, however, you need to do it properly. You can't set a component's model value with the UIComponent "setValue" method. The setValue method is what's used to handle the "value=" attribute on a static View Definition, and that particular attribute takes an EL expression, not a simple property value. So setValue() needs an EL expression plus the EL execution context that handles it.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: create UIComponent by java code
It's not a secret anymore!