Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with adding jsf component programmatically|dynamically

 
Solmaz Anvar
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Ichabod Grabarkowitz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic