"Unable to find component with id"

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

"Unable to find component with id"

btakacs
Hi

I'm new in wicket. I tried to display a list of components, but I get the following error:

WicketMessage: Unable to find component with id 'label' in [MarkupContainer [Component id = link, page = com.myapp.wicket.HomePage, path = 0:mainNavigation:menu:0:link.BookmarkablePageLink, isVisible = true, isVersioned = true]]. This means that you declared wicket:id=label in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/D:/workspace/NetBeansProjects/WicketTest/build/web/WEB-INF/classes/com/myapp/wicket/HeaderPanel.html

The html:
<html xmlns:wicket>
<body>
  <wicket:panel>
   

Wicket Example

        <p id="titleblock">
        Start of Example Title Goes Here
       
   </p>
   
   <ul wicket:id="menu">   
    <li></li>
   
  </ul>

  </wicket:panel>
</body>
</html>

The MarkupComponents are:
#   Path   Size   Type   Model Object
1     mainNavigation     3K     com.myapp.wicket.HeaderPanel     No get method defined for class: class com.myapp.wicket.HomePage expression: mainNavigation  
2     mainNavigation:exampleTitle     421 bytes     org.apache.wicket.markup.html.basic.Label     wicket  
3     mainNavigation:menu     4.4K     org.apache.wicket.markup.html.list.ListView     [com.myapp.wicket.model.MenuModel@11ddcf4, com.myapp.wicket.model.MenuModel@6ca837, com.myapp.wicket.model.MenuModel@197eb84]  
4     mainNavigation:menu:0     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@11ddcf4  
5     mainNavigation:menu:0:label     418 bytes     org.apache.wicket.markup.html.basic.Label     First Page  
6     mainNavigation:menu:0:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
7     mainNavigation:menu:1     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@6ca837  
8     mainNavigation:menu:1:label     419 bytes     org.apache.wicket.markup.html.basic.Label     Second Page  
9     mainNavigation:menu:1:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
10     mainNavigation:menu:2     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@197eb84  
11     mainNavigation:menu:2:label     418 bytes     org.apache.wicket.markup.html.basic.Label     Third Page  
12     mainNavigation:menu:2:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
13     param     409 bytes     org.apache.wicket.markup.html.basic.Label     0  
14     stylesheet     1.4K     org.apache.wicket.markup.html.resources.StyleSheetReference     No get method defined for class: class com.myapp.wicket.HomePage expression: stylesheet

I have the following classes:

public class HeaderPanel{
    public HeaderPanel(String componentName, String exampleTitle)
    {
        super(componentName);
        add(new Label("exampleTitle", exampleTitle));
        ArrayList<MenuModel> menu=new ArrayList<MenuModel>();
        menu.add(new MenuModel("1", "HomePage", "First Page"));
        menu.add(new MenuModel("2", "HomePage", "Second Page"));
        menu.add(new MenuModel("3", "HomePage", "Third Page"));
       
        MenuView view = new MenuView("menu", menu);
        add(view);  
 
    }
}

public class MenuView extends ListView {

    public MenuView(final String id) {
        super(id);
    }

    public MenuView(final String id, final IModel model) {
        super(id, model);
    }

    public MenuView(final String id, final List list) {
        super(id, list);
    }
   
    @Override
    protected void populateItem(ListItem item) {
        final MenuModel element = (MenuModel) item.getModelObject();
        Class clas;
        try {
            clas = Class.forName(element.getClas());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(MenuView.class.getName()).log(Level.WARNING, null, ex);
            clas=this.getApplication().getHomePage();
        }

        item.add(new Label("label", element.getLabel()));
        item.add(new BookmarkablePageLink("link", clas,
                new PageParameters("id=" + element.getId())));
    }
}

public class MenuModel implements Serializable{
   
    public String clas;
    public String label;
    public String id;
   
    public MenuModel(String id, String clas, String label){
        this.id=id;
        this.clas=clas;
        this.label=label;
    }

    public String getClas() {
        return clas;
    }

    public void setClas(String clas) {
        this.clas = clas;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }    
}


Any tips?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

John Patterson
That can't be the markup that generated that error because there is no tag in it with a wicket:id="label" which the error message is complaining about.

But you also do not add a tag for exampleTitle which you add here
        add(new Label("exampleTitle", exampleTitle));

Basically, every wicket:id in your html files must have a component in your java file and visa versa

btakacs wrote
Hi

I'm new in wicket. I tried to display a list of components, but I get the following error:

WicketMessage: Unable to find component with id 'label' in [MarkupContainer [Component id = link, page = com.myapp.wicket.HomePage, path = 0:mainNavigation:menu:0:link.BookmarkablePageLink, isVisible = true, isVersioned = true]]. This means that you declared wicket:id=label in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/D:/workspace/NetBeansProjects/WicketTest/build/web/WEB-INF/classes/com/myapp/wicket/HeaderPanel.html

The html:
<html xmlns:wicket>
<body>
  <wicket:panel>
   

Wicket Example

        <p id="titleblock">
        Start of Example Title Goes Here
       
   </p>
   
   <ul wicket:id="menu">   
    <li></li>
   
  </ul>

  </wicket:panel>
</body>
</html>

The MarkupComponents are:
#   Path   Size   Type   Model Object
1     mainNavigation     3K     com.myapp.wicket.HeaderPanel     No get method defined for class: class com.myapp.wicket.HomePage expression: mainNavigation  
2     mainNavigation:exampleTitle     421 bytes     org.apache.wicket.markup.html.basic.Label     wicket  
3     mainNavigation:menu     4.4K     org.apache.wicket.markup.html.list.ListView     [com.myapp.wicket.model.MenuModel@11ddcf4, com.myapp.wicket.model.MenuModel@6ca837, com.myapp.wicket.model.MenuModel@197eb84]  
4     mainNavigation:menu:0     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@11ddcf4  
5     mainNavigation:menu:0:label     418 bytes     org.apache.wicket.markup.html.basic.Label     First Page  
6     mainNavigation:menu:0:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
7     mainNavigation:menu:1     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@6ca837  
8     mainNavigation:menu:1:label     419 bytes     org.apache.wicket.markup.html.basic.Label     Second Page  
9     mainNavigation:menu:1:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
10     mainNavigation:menu:2     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@197eb84  
11     mainNavigation:menu:2:label     418 bytes     org.apache.wicket.markup.html.basic.Label     Third Page  
12     mainNavigation:menu:2:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
13     param     409 bytes     org.apache.wicket.markup.html.basic.Label     0  
14     stylesheet     1.4K     org.apache.wicket.markup.html.resources.StyleSheetReference     No get method defined for class: class com.myapp.wicket.HomePage expression: stylesheet

I have the following classes:

public class HeaderPanel{
    public HeaderPanel(String componentName, String exampleTitle)
    {
        super(componentName);
        add(new Label("exampleTitle", exampleTitle));
        ArrayList<MenuModel> menu=new ArrayList<MenuModel>();
        menu.add(new MenuModel("1", "HomePage", "First Page"));
        menu.add(new MenuModel("2", "HomePage", "Second Page"));
        menu.add(new MenuModel("3", "HomePage", "Third Page"));
       
        MenuView view = new MenuView("menu", menu);
        add(view);  
 
    }
}

public class MenuView extends ListView {

    public MenuView(final String id) {
        super(id);
    }

    public MenuView(final String id, final IModel model) {
        super(id, model);
    }

    public MenuView(final String id, final List list) {
        super(id, list);
    }
   
    @Override
    protected void populateItem(ListItem item) {
        final MenuModel element = (MenuModel) item.getModelObject();
        Class clas;
        try {
            clas = Class.forName(element.getClas());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(MenuView.class.getName()).log(Level.WARNING, null, ex);
            clas=this.getApplication().getHomePage();
        }

        item.add(new Label("label", element.getLabel()));
        item.add(new BookmarkablePageLink("link", clas,
                new PageParameters("id=" + element.getId())));
    }
}

public class MenuModel implements Serializable{
   
    public String clas;
    public String label;
    public String id;
   
    public MenuModel(String id, String clas, String label){
        this.id=id;
        this.clas=clas;
        this.label=label;
    }

    public String getClas() {
        return clas;
    }

    public void setClas(String clas) {
        this.clas = clas;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }    
}


Any tips?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

msc65jap
In reply to this post by btakacs
Send the code for HomePage.html and HomePage.html. It looks like you
declaring the label in the markup incongruent to your page hierarchy;
make sure it's in the wicket tag "menu".

Cheers,
JP.

On Thu, Aug 21, 2008 at 5:00 PM, btakacs <[hidden email]> wrote:

>
> Hi
>
> I'm new in wicket. I tried to display a list of components, but I get the
> following error:
>
> WicketMessage: Unable to find component with id 'label' in [MarkupContainer
> [Component id = link, page = com.myapp.wicket.HomePage, path =
> 0:mainNavigation:menu:0:link.BookmarkablePageLink, isVisible = true,
> isVersioned = true]]. This means that you declared wicket:id=label in your
> markup, but that you either did not add the component to your page at all,
> or that the hierarchy does not match.
> [markup =
> file:/D:/workspace/NetBeansProjects/WicketTest/build/web/WEB-INF/classes/com/myapp/wicket/HeaderPanel.html
>
> The html:
> <html xmlns:wicket>
> <body>
>  <wicket:panel>
>    <h1>Wicket Example</h1>
>    <p id="titleblock">
>        Start of Example Title Goes Here
>
>   </p>
>
>   <ul wicket:id="menu">
>    <li>  </li>
>
>  </ul>
>
>  </wicket:panel>
> </body>
> </html>
>
> The MarkupComponents are:
> #       Path    Size    Type    Model Object
> 1       mainNavigation          3K      com.myapp.wicket.HeaderPanel            No get
> method defined for class: class com.myapp.wicket.HomePage expression:
> mainNavigation
> 2       mainNavigation:exampleTitle     421 bytes
> org.apache.wicket.markup.html.basic.Label       wicket
> 3       mainNavigation:menu     4.4K
> org.apache.wicket.markup.html.list.ListView
> [com.myapp.wicket.model.MenuModel@11ddcf4,
> com.myapp.wicket.model.MenuModel@6ca837,
> com.myapp.wicket.model.MenuModel@197eb84]
> 4       mainNavigation:menu:0           4.4K
> org.apache.wicket.markup.html.list.ListItem
> com.myapp.wicket.model.MenuModel@11ddcf4
> 5       mainNavigation:menu:0:label     418 bytes
> org.apache.wicket.markup.html.basic.Label       First Page
> 6       mainNavigation:menu:0:link      1K
> org.apache.wicket.markup.html.link.BookmarkablePageLink         No get method
> defined for class: class com.myapp.wicket.HomePage expression: link
> 7       mainNavigation:menu:1           4.4K
> org.apache.wicket.markup.html.list.ListItem
> com.myapp.wicket.model.MenuModel@6ca837
> 8       mainNavigation:menu:1:label     419 bytes
> org.apache.wicket.markup.html.basic.Label       Second Page
> 9       mainNavigation:menu:1:link      1K
> org.apache.wicket.markup.html.link.BookmarkablePageLink         No get method
> defined for class: class com.myapp.wicket.HomePage expression: link
> 10      mainNavigation:menu:2           4.4K
> org.apache.wicket.markup.html.list.ListItem
> com.myapp.wicket.model.MenuModel@197eb84
> 11      mainNavigation:menu:2:label     418 bytes
> org.apache.wicket.markup.html.basic.Label       Third Page
> 12      mainNavigation:menu:2:link      1K
> org.apache.wicket.markup.html.link.BookmarkablePageLink         No get method
> defined for class: class com.myapp.wicket.HomePage expression: link
> 13      param           409 bytes       org.apache.wicket.markup.html.basic.Label
> 0
> 14      stylesheet      1.4K
> org.apache.wicket.markup.html.resources.StyleSheetReference     No get
> method defined for class: class com.myapp.wicket.HomePage expression:
> stylesheet
>
> I have the following classes:
>
> public class HeaderPanel{
>    public HeaderPanel(String componentName, String exampleTitle)
>    {
>        super(componentName);
>        add(new Label("exampleTitle", exampleTitle));
>        ArrayList<MenuModel> menu=new ArrayList<MenuModel>();
>        menu.add(new MenuModel("1", "HomePage", "First Page"));
>        menu.add(new MenuModel("2", "HomePage", "Second Page"));
>        menu.add(new MenuModel("3", "HomePage", "Third Page"));
>
>        MenuView view = new MenuView("menu", menu);
>        add(view);
>
>    }
> }
>
> public class MenuView extends ListView {
>
>    public MenuView(final String id) {
>        super(id);
>    }
>
>    public MenuView(final String id, final IModel model) {
>        super(id, model);
>    }
>
>    public MenuView(final String id, final List list) {
>        super(id, list);
>    }
>
>    @Override
>    protected void populateItem(ListItem item) {
>        final MenuModel element = (MenuModel) item.getModelObject();
>        Class clas;
>        try {
>            clas = Class.forName(element.getClas());
>        } catch (ClassNotFoundException ex) {
>            Logger.getLogger(MenuView.class.getName()).log(Level.WARNING,
> null, ex);
>            clas=this.getApplication().getHomePage();
>        }
>
>        item.add(new Label("label", element.getLabel()));
>        item.add(new BookmarkablePageLink("link", clas,
>                new PageParameters("id=" + element.getId())));
>    }
> }
>
> public class MenuModel implements Serializable{
>
>    public String clas;
>    public String label;
>    public String id;
>
>    public MenuModel(String id, String clas, String label){
>        this.id=id;
>        this.clas=clas;
>        this.label=label;
>    }
>
>    public String getClas() {
>        return clas;
>    }
>
>    public void setClas(String clas) {
>        this.clas = clas;
>    }
>
>    public String getLabel() {
>        return label;
>    }
>
>    public void setLabel(String label) {
>        this.label = label;
>    }
>
>    public String getId() {
>        return id;
>    }
>
>    public void setId(String id) {
>        this.id = id;
>    }
> }
>
>
> Any tips?
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/%22Unable-to-find-component-with-id%22-tp19091781p19091781.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

btakacs
In reply to this post by John Patterson
Hi

John Patterson wrote
Basically, every wicket:id in your html files must have a component in your java file and visa versa
I think, there is a mutual mapping between html and java.
<ul wicket:id = "menu"> -- MenuView view = new MenuView("menu", menu);    add(view);   // in HeaderPanel.java
 -- item.add(new BookmarkablePageLink("link", clas, new PageParameters("id=" + element.getId())));   // in MenuView.java
 -- item.add(new Label("label", element.getLabel()));   // in MenuView.java

Sorry, I see that I pasted the result code not the wicket templates. Here are the real template files:

HeaderPanel.html

<html xmlns:wicket>
<body>
  <wicket:panel>
   

Wicket Example

            <p id="titleblock">
        Start of Example Title Goes Here       
   </p>
   
   <ul wicket:id = "menu">   
    <li>
</li>   
  </ul>

  </wicket:panel>
</body>
</html>


HomePage.html

<html>
  <head>
    <title></title>
    <link wicket:id='stylesheet'/>
  </head>
  <body>
   
    Hello


  </body>
</html>





John Patterson wrote
That can't be the markup that generated that error because there is no tag in it with a wicket:id="label" which the error message is complaining about.

But you also do not add a tag for exampleTitle which you add here
        add(new Label("exampleTitle", exampleTitle));

Basically, every wicket:id in your html files must have a component in your java file and visa versa

btakacs wrote
Hi

I'm new in wicket. I tried to display a list of components, but I get the following error:

WicketMessage: Unable to find component with id 'label' in [MarkupContainer [Component id = link, page = com.myapp.wicket.HomePage, path = 0:mainNavigation:menu:0:link.BookmarkablePageLink, isVisible = true, isVersioned = true]]. This means that you declared wicket:id=label in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.
[markup = file:/D:/workspace/NetBeansProjects/WicketTest/build/web/WEB-INF/classes/com/myapp/wicket/HeaderPanel.html

The html:
<html xmlns:wicket>
<body>
  <wicket:panel>
   

Wicket Example

        <p id="titleblock">
        Start of Example Title Goes Here
       
   </p>
   
   <ul wicket:id="menu">   
    <li></li>
   
  </ul>

  </wicket:panel>
</body>
</html>

The MarkupComponents are:
#   Path   Size   Type   Model Object
1     mainNavigation     3K     com.myapp.wicket.HeaderPanel     No get method defined for class: class com.myapp.wicket.HomePage expression: mainNavigation  
2     mainNavigation:exampleTitle     421 bytes     org.apache.wicket.markup.html.basic.Label     wicket  
3     mainNavigation:menu     4.4K     org.apache.wicket.markup.html.list.ListView     [com.myapp.wicket.model.MenuModel@11ddcf4, com.myapp.wicket.model.MenuModel@6ca837, com.myapp.wicket.model.MenuModel@197eb84]  
4     mainNavigation:menu:0     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@11ddcf4  
5     mainNavigation:menu:0:label     418 bytes     org.apache.wicket.markup.html.basic.Label     First Page  
6     mainNavigation:menu:0:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
7     mainNavigation:menu:1     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@6ca837  
8     mainNavigation:menu:1:label     419 bytes     org.apache.wicket.markup.html.basic.Label     Second Page  
9     mainNavigation:menu:1:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
10     mainNavigation:menu:2     4.4K     org.apache.wicket.markup.html.list.ListItem     com.myapp.wicket.model.MenuModel@197eb84  
11     mainNavigation:menu:2:label     418 bytes     org.apache.wicket.markup.html.basic.Label     Third Page  
12     mainNavigation:menu:2:link     1K     org.apache.wicket.markup.html.link.BookmarkablePageLink     No get method defined for class: class com.myapp.wicket.HomePage expression: link  
13     param     409 bytes     org.apache.wicket.markup.html.basic.Label     0  
14     stylesheet     1.4K     org.apache.wicket.markup.html.resources.StyleSheetReference     No get method defined for class: class com.myapp.wicket.HomePage expression: stylesheet

I have the following classes:

public class HeaderPanel{
    public HeaderPanel(String componentName, String exampleTitle)
    {
        super(componentName);
        add(new Label("exampleTitle", exampleTitle));
        ArrayList<MenuModel> menu=new ArrayList<MenuModel>();
        menu.add(new MenuModel("1", "HomePage", "First Page"));
        menu.add(new MenuModel("2", "HomePage", "Second Page"));
        menu.add(new MenuModel("3", "HomePage", "Third Page"));
       
        MenuView view = new MenuView("menu", menu);
        add(view);  
 
    }
}

public class MenuView extends ListView {

    public MenuView(final String id) {
        super(id);
    }

    public MenuView(final String id, final IModel model) {
        super(id, model);
    }

    public MenuView(final String id, final List list) {
        super(id, list);
    }
   
    @Override
    protected void populateItem(ListItem item) {
        final MenuModel element = (MenuModel) item.getModelObject();
        Class clas;
        try {
            clas = Class.forName(element.getClas());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(MenuView.class.getName()).log(Level.WARNING, null, ex);
            clas=this.getApplication().getHomePage();
        }

        item.add(new Label("label", element.getLabel()));
        item.add(new BookmarkablePageLink("link", clas,
                new PageParameters("id=" + element.getId())));
    }
}

public class MenuModel implements Serializable{
   
    public String clas;
    public String label;
    public String id;
   
    public MenuModel(String id, String clas, String label){
        this.id=id;
        this.clas=clas;
        this.label=label;
    }

    public String getClas() {
        return clas;
    }

    public void setClas(String clas) {
        this.clas = clas;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }    
}


Any tips?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

btakacs
Hi

It seems that there is some kind of fromatting in place which is confused because of my code fragments.
I've just read the help.

So, the mapping between components:
<ul wicket:id = "menu"> -- MenuView view = new MenuView("menu", menu);    add(view);   // in HeaderPanel.java
<a wicket:id = "link"> -- item.add(new BookmarkablePageLink("link", clas, new PageParameters("id=" + element.getId())));   // in MenuView.java
<span wicket:id="label" /> -- item.add(new Label("label", element.getLabel()));   // in MenuView.java

HeaderPanel.html
<html xmlns:wicket>
<body>
  <wicket:panel>
    <h1>Wicket Example</h1>	
    <p id="titleblock">
        <b><font size="+1">Start of <span wicket:id="exampleTitle">Example Title Goes Here</span></font></b>
        
   </p>
   
   <ul wicket:id = "menu">    
    <li><a wicket:id = "link"><span wicket:id="label" /></a></li>
    
  </ul>


  </wicket:panel>
</body>
</html>


HomePage.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
  <head>
    <title></title>
    <link wicket:id='stylesheet'/>
  </head>
  <body>
    <span wicket:id='mainNavigation'/>
    <span wicket:id="param">Hello</span>


  </body>
</html>

Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

btakacs
I have just tried to change the markup to:
<ul>    
    <wicket:container wicket:id = "menu"> <li><a wicket:id = "link"><span wicket:id="label" /></a></li></wicket:container>
  </ul>

but it has the same result.

And then I tried to remove that element from the markup:

<ul>    
    <wicket:container wicket:id = "menu"> <li><a wicket:id = "link">something</a></li></wicket:container>
  </ul>

... and the framework missed it:

org.apache.wicket.WicketRuntimeException: The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).

1. [Component id = label, page = com.myapp.wicket.HomePage, path = 0:mainNavigation:menu:0:label.Label, isVisible = true, isVersioned = true]
2. [Component id = label, page = com.myapp.wicket.HomePage, path = 0:mainNavigation:menu:1:label.Label, isVisible = true, isVersioned = true]
3. [Component id = label, page = com.myapp.wicket.HomePage, path = 0:mainNavigation:menu:2:label.Label, isVisible = true, isVersioned = true]

at org.apache.wicket.Page.checkRendering(Page.java:1116)
at org.apache.wicket.Page.renderPage(Page.java:914)

any tips?
Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

Martijn Dashorst
Administrator
1. you are repeating the UL tag instead of the LI tag. You should use
<li wicket:id="menu">, but I'd recommend to rename the component to
menuitem to make it more clear
2. you don't have child components defined in the markup for each
element. This is necessary.

<ul>
<li wicket:id="menu"><a href="#" wicket:id="link"><span
wicket:id="label"></span></a></li>
</ul>

and in your populateItem:

link = new BookmarkablePageLink("link", ...);
item.add(link);
link.add(new Label("label", ....));

Martijn

On Fri, Aug 22, 2008 at 11:01 AM, btakacs <[hidden email]> wrote:

>
> I have just tried to change the markup to:
>
> <ul>
>    <wicket:container wicket:id = "menu"> <li>  </li></wicket:container>
>  </ul>
>
>
> but it has the same result.
>
> And then I tried to remove that element from the markup:
>
>
> <ul>
>    <wicket:container wicket:id = "menu"> <li> something
> </li></wicket:container>
>  </ul>
>
>
> ... and the framework missed it:
>
>
> org.apache.wicket.WicketRuntimeException: The component(s) below failed to
> render. A common problem is that you have added a component in code but
> forgot to reference it in the markup (thus the component will never be
> rendered).
>
> 1. [Component id = label, page = com.myapp.wicket.HomePage, path =
> 0:mainNavigation:menu:0:label.Label, isVisible = true, isVersioned = true]
> 2. [Component id = label, page = com.myapp.wicket.HomePage, path =
> 0:mainNavigation:menu:1:label.Label, isVisible = true, isVersioned = true]
> 3. [Component id = label, page = com.myapp.wicket.HomePage, path =
> 0:mainNavigation:menu:2:label.Label, isVisible = true, isVersioned = true]
>
> at org.apache.wicket.Page.checkRendering(Page.java:1116)
> at org.apache.wicket.Page.renderPage(Page.java:914)
>
>
> any tips?
> --
> View this message in context: http://www.nabble.com/%22Unable-to-find-component-with-id%22-tp19091781p19103768.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: "Unable to find component with id"

btakacs
In reply to this post by btakacs
Hi, All

I found out the solution:

Wicket is very strict with the hierarchy. If I define the markup this way:
<ul wicket:id = "menu">    
    <li><a wicket:id = "link"><span wicket:id="label" /></a></li>
</ul>

then I have to create components that way:
BookmarkablePageLink link=new BookmarkablePageLink("link", clas,
                new PageParameters("id=" + element.getId()));
        link.add(new Label("label", element.getLabel()));
        item.add(link);

so the component hierarchy must match.

Thanks to everybody.