GeeCON Prague 2014*
The moose likes JSF and the fly likes Problem with adding jsf component programmatically|dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "Problem with adding jsf component programmatically|dynamically" Watch "Problem with adding jsf component programmatically|dynamically" New topic
Author

Problem with adding jsf component programmatically|dynamically

Solmaz Anvar
Greenhorn

Joined: Jul 14, 2005
Posts: 26
Could anyone tell me how can i add jsf component programmatically|dynamically with javax.faces.* api ?
I don't want use jsf taglib in my jsp page to add jsf components.

I need sample codes or some other refrences.

regards
solmaz anvar
[ September 14, 2005: Message edited by: Solmaz Anvar ]

Solmaz Anvar
Ichabod Grabarkowitz
Greenhorn

Joined: Sep 29, 2005
Posts: 1
Who in their right mind would want to add components under program control when they can use html type scripting??

That's almost as crazy as wanting an easy to use timer.
javascript: x()
Confused
Burf
Solmaz Anvar
Greenhorn

Joined: Jul 14, 2005
Posts: 26
it is possible to add components dynamically.
Create a container bean like this one:


public class ComplexBean
{

protected UIComponent component;

public ComplexBean()
{
component = new UIPanel();
}

public UIComponent getComponent()
{
return component;
}

public void setComponent(UIComponent component)
{
this.component = component;
}
}



Use component instance binding in your page, for
instance

<h anelGrid binding="#{ComplexBean.component}"/>

(The bean should be configured as a managed bean).

Now if you add components to your
ComplexBean.getComponent(), they will appear on the
page. You can add the dynamically/programmatically.
Alexander Jesse
Ranch Hand

Joined: Mar 17, 2004
Posts: 35
Originally posted by Ichabod Grabarkowitz:
Who in their right mind would want to add components under program control when they can use html type scripting??

That's almost as crazy as wanting an easy to use timer.
javascript: x()
Confused
Burf


There are people that prefer that dynamic Java mechanism over the stupid craze of DHTML and the stupidity of Javascript based stuff...

Let's cool down:
There are places and reasons where JS is forbidden:
- security-conscious companies (-> the TSS-thread about the hero, which describes a AJAX-hack; or cross-scripting)
- Government contracts (USA, Germany, most probably also others) where the accessability laws do not allow those dynamic things, because handicapped users might have problems...

There is a time and place for both variants of doing dynamic stuff.

regards
Alexander
evan k. stone
Greenhorn

Joined: Nov 29, 2006
Posts: 16
@Solmaz:

I like where you're going with this solution, but I'm confused about how to do this part:

Originally posted by Solmaz Anvar:
Now if you add components to your
ComplexBean.getComponent(), they will appear on the
page. You can add the dynamically/programmatically.


What I'm not sure how to do is "add components to your ComplexBean.getComponent()" - could you provide a little more information (or link to more information) regarding how to do this?

Thanks!

--- EDIT ---
OK - I think I may have found what I needed. Were you suggesting something like this:



Thanks Again!
[ November 29, 2006: Message edited by: evan stone ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with adding jsf component programmatically|dynamically