It sounds like you need to add the nested component to the component tree.

Try something like this:

 HtmlCommandButton b = (HtmlCommandButton) this.getChildren().get(0);
if (b == null) {
    HtmlCommandButton b = (HtmlCommandButton) 
context.getApplication().createComponent  (HtmlCommandButton.COMPONENT_TYPE); 
    b.setValue("Click me"); 

    this.getChildren().add(0, b);
}

 b.encodeBegin(context); 
 b.encodeChildren(context); 
 b.encodeEnd(context); 

There is a wiki on creating composite components here:
http://wiki.apache.org/myfaces/Creating_Composite_Components?highlight=%28composite%29%7C%28components%29


-------------- Original message -------------- 
From: [EMAIL PROTECTED] 

Hi, 
I'm developing some simple custom component, and I'm facing a problem I cannot 
resolve and understand, so I will really appreciate any help. 

I have this piece of code: 

public void encodeBegin(FacesContext c) throws IOException { 
        HtmlCommandButton b = (HtmlCommandButton) 
context.getApplication().createComponent(HtmlCommandButton.COMPONENT_TYPE); 
      b.setValue("Click me"); 
      b.encodeBegin(context); 
      b.encodeChildren(context); 
      b.encodeEnd(context); 
} 

And with above code everything is great, the button renders and when I click 
it, the 

public void decode(FacesContext context) 

method is called... But. If I change HtmlCommandButton to HtmlCommandLink 
something strange happens. The link is created and renders as well, 
but when I click it, the decode method is not called at all. 

Is there any difference between handlig those two components? 
Thanks in advance! 

-- 
greetings
Pawe³ Czerwiñski

Reply via email to