You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by andre seame <an...@hotmail.fr> on 2016/03/22 00:27:36 UTC

Misunderstanding : Unable to find component with id 'phl' or A child with id 'phl' already exists:

Hello,

I try to modify the header of a table. So according to the advice of this mailing list, I write


public class DataTableFilterToolbarPage extends WebPage
{

     /**
     * constructor
     */
    public DataTableFilterToolbarPage()
    {
        List<IColumn<Contact, String>> columns = new ArrayList<IColumn<Contact, String>>();

        columns.add(new PropertyColumn<Contact, String>(new Model<String>("ID"), "id")
        {   private static final long serialVersionUID = 1L;

            @Override
            public Component getHeader(final String componentId)
            {   X1 x = new X1(componentId,"id") ; // My own panel instead of a label
                   return x;
            }

        });


As I want to set the sortable link in a part of X1, I modify HeadersToolbar


public <T> HeadersToolbar(final DataTable<T, S> table, final ISortStateLocator<S> stateLocator)
    {
        super(table);

        RefreshingView<IColumn<T, S>> headers = new RefreshingView<IColumn<T, S>>("headers")
        {
            private static final long serialVersionUID = 1L;

            @Override
            protected Iterator<IModel<IColumn<T, S>>> getItemModels()
            ....

            @Override
            protected void populateItem(Item<IColumn<T, S>> item)

                              {

                if (column.isSortable())
                {
                        header = newSortableHeader("header", column.getSortProperty(), stateLocator);
                }
                else
                {
                        header = new WebMarkupContainer("header");
                }

                if (column instanceof IStyledColumn)
                { .... }

                item.add(header);
                item.setRenderBodyOnly(true)
                ((X1)column.getHeader("panel")).ajout() ; // action on X1
                header.add(column.getHeader("panel"));

Where X1 is

public class X1 extends Panel
{
    public X1(String id, String ColumnTilte) //,  TextField<String> x)
    {
        super(id) ;
        lbl = new Label("labelx", ColumnTilte) ;
        add(lbl) ;
    }

    public Label getLabel() { return lbl ; }

    public void ajout()
    {
       add(new Label("phl","added by  headersTools")) ;
    }
}


Run this code, I get

Unexpected RuntimeException

Last cause: Unable to find component with id 'phl' in [X1 [Component id = panel]]
        Expected: 'filterForm:tableWithFilterForm:topToolbars:toolbars:3:headers:1:header:panel:phl'.
        Found with similar names: ''


Markup

The problem is in "file:/home/phl/apache-tomcat-7.0.47/webapps/phlwick/WEB-INF/classes/xxx/X1.html":

<wicket:panel xmlns:wicket="http://wicket.apache.org">
        1<br />

            <span style="color: Blue;">
                <span wicket:id="labelx" id="labelx">The Title of the column goes here</span>
            </span>

        <br/>
        <span wicket:id="phl">Action from HeadersTools goes here</span> <br />

</wicket:panel>



I was expecting that the action ((X1)column.getHeader("panel")).ajout() ; will define phl in X1


If I change the X.java to


public class X1 extends Panel
{
    public X1(String id, String ColumnTilte) //,  TextField<String> x)
    {
        super(id) ;
        lbl = new Label("labelx", ColumnTilte) ;
        add(lbl) ;
        add(new Label("phl","added by constructor")) ;
    }

    public Label getLabel() { return lbl ; }

    public void ajout()
    {
       add(new Label("phl","added by  headersTools")) ;
    }
}


So I don't understand why the some time the id phl is not declared and sometime is it already declared.


This is probably due to the fact that I don't clearly understand the render mechanism.


Pointers or ideas are welcome.


Thanks,

PHL.


Then I get :

Last cause: A child with id 'phl' already exists:
[X1 [Component id = panel]]
WicketMessage: Error attaching this container for rendering: [HeadersToolbar [Component id = 3]]


RE: Misunderstanding : Unable to find component with id 'phl' or A child with id 'phl' already exists:

Posted by Gabriel Landon <gl...@piti.pf>.
Sorry, I still don't get it.
What are you trying to set? There is no link in your example, only labels.
If you want to change the text in the label, you can use models instead of
static strings.

If you want to add a link in your header you can have a look at
OrderByBorder...

regards,
Gabriel.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Misunderstanding-Unable-to-find-component-with-id-phl-or-A-child-with-id-phl-already-exists-tp4674083p4674090.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: Misunderstanding : Unable to find component with id 'phl' or A child with id 'phl' already exists:

Posted by andre seame <an...@hotmail.fr>.
The ajout method is a debug method. 
The main objective is  that the method
HeadersToolbar//HeadersToolbar(final DataTable/RefreshingView<IColumn<T, S>>//Iterator<IModel<IColumn<T, S>>>//populateItem(Item<IColumn<T, S>> item)

is able to modify the content of "getheader" that is the X1 object (X1 is a for debug). 

In case 1 - I use "ajout" and wicket says  phl already exists in the X1 object. OK, I agree. X1 has already 2 labels. 

In case 2 - I use "ajout", but the phl label is not yet declared in the java object (ajout must add it), but the wicket render says 
"Sorry, phl label does not exists". 

This means that I cannot modify the getheader object from HeadersToolbar. 

The example set the sortable link to the global header object. But I want to put the sortable link to part of the header object. 

Thanks,
PHL
________________________________________
De : Gabriel Landon <gl...@piti.pf>
Envoyé : mardi 22 mars 2016 18:04
À : users@wicket.apache.org
Objet : Re: Misunderstanding : Unable to find component with id 'phl' or A child with id 'phl' already exists:

PHL,

I'm sorry but it's hard to understand what your are trying to do.
Anyway, I find the X1 class very strange. I think you simply need to remove
the "ajout" method as the label is already added in the constructor. You
cannot add a label several times on the same panel unless you are using a
repeater.

public class X1 extends Panel
{
    public X1(String id, String ColumnTilte)
    {
        super(id) ;
        lbl = new Label("labelx", ColumnTilte) ;
        add(lbl) ;
        add(new Label("phl","added by constructor")) ;
    }

    public Label getLabel() { return lbl ; }
}

regards,
Gabriel.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Misunderstanding-Unable-to-find-component-with-id-phl-or-A-child-with-id-phl-already-exists-tp4674083p4674087.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Misunderstanding : Unable to find component with id 'phl' or A child with id 'phl' already exists:

Posted by Gabriel Landon <gl...@piti.pf>.
PHL,

I'm sorry but it's hard to understand what your are trying to do.
Anyway, I find the X1 class very strange. I think you simply need to remove
the "ajout" method as the label is already added in the constructor. You
cannot add a label several times on the same panel unless you are using a
repeater.

public class X1 extends Panel
{
    public X1(String id, String ColumnTilte)
    {
        super(id) ;
        lbl = new Label("labelx", ColumnTilte) ;
        add(lbl) ;
        add(new Label("phl","added by constructor")) ;
    }

    public Label getLabel() { return lbl ; }
} 

regards,
Gabriel.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Misunderstanding-Unable-to-find-component-with-id-phl-or-A-child-with-id-phl-already-exists-tp4674083p4674087.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org