myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marko Asplund" <>
Subject Re: Component coding questions
Date Sat, 17 Mar 2007 20:22:24 GMT
Volker Weber wrote:
> > My current problems are related to container components. When I remove
> > container components odd things happen. Removing component a results
> > in the entire component subtree not being rendered.
> ? Maybe i don't understand you correct, if you remove the parent why
> did you expect the children are rendered?
>  > If I remove
>  > container b I fail to get any response for the HTTP request,
> > and if I
> > remove both I get an error about MyFaces not being able to add a child
> > node (see below).
> What did you mean with remove both ? When you removing a the entire
> subtree is removed.

> Plese post the code for adding an removing. did you already assign
> uniqe ids to all created components, the exception says someting about
> dublicate ids. Also add ids to all tags to identifiy the problematic
> components.

I'm assigning IDs explicitly. While going through the code a minute
ago I found a flaw that was causing one problem (in one particular
case a container component was added as its own child).

What I meant by "removing a container component", was that I modified
the code to omit a container from the hierarchy and adding its
children directly as children of the omitted component's parent.

Currently, if I remove the h:panelGrid element from the view, my
custom component tree is not rendered at all. I'll probably want to
include my component tree in a some container component such as
h:panelGrid but I'd just like to know why this happens.

I've done some changes to the code posted earlier, here's the code in
a somewhat simplified form. Are there any potential problems with the
way the component hierarchy is built?

      <my:inputSelectSet value="#{myBean.items}"/>

public class MyInputSelectSet extends UIInput {
    public MyInputSelectSet() {

    public void encodeBegin(FacesContext ctx) throws IOException {

    private void initializeComponent() {
        for(int i = 0; i<5; i++)
            addSelectInputParameter(this, app);

    private void addSelectInputParameter(UIComponent container,
Application app) {
        MyInputSelect sip =

        HtmlOutputLabel l =

        HtmlPanelGroup group =


    public String getFamily() { return COMPONENT_FAMILY; }

    private String getId() { return
FacesContext.getCurrentInstance().getViewRoot().createUniqueId(); }

public class MyInputSelect extends UIInput {
    public MyInputSelect() {

    public void initializeComponent() {
        Application app = FacesContext.getCurrentInstance().getApplication();
        UIInput input = (UIInput)app.createComponent(UIInput.COMPONENT_TYPE);

        HtmlSelectManyListbox menu =

        List<SelectItem> items = new ArrayList<SelectItem>();
        for(int i = 0; i < 5; i++)
            items.add(new SelectItem(new String(i), new String(i));
        UISelectItems selectItems = new UISelectItems();


    public void decode(FacesContext ctx) {
        // read child component values and set components value accordingly

    public String getFamily() { return COMPONENT_FAMILY; }

    private String getId() { return
FacesContext.getCurrentInstance().getViewRoot().createUniqueId(); }

View raw message