On 12/21/11 11:05 AM, Martin Grigorov wrote:

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).

This error means that Wicket sees these components only in the Java
component tree but doesn't see them in the markup tree.
How exactly do you pass the generated markup to Wicket ?

Let's have a simple example:

Simple layout/UI in XML:

<frame>
        <actionbox DataBinding="@Inventory[0]">
                <fop-action enabled="true" />
        </actionbox>

        <list DataBinding="@Inventory[0]">
                <field DataBinding="name"/>
        </list>   
</frame>

Which is read and converted into an in-memory object tree:

frame
        actionbox
                fop-action
...

This is then taken and Wicket classes are instantiated for every in-memory object.

In the constructor of every class (depending on its nature) there is code to build the Wicket based object structure. Something like this:

ListView<ObjectBase> listView = new ListView<ObjectBase>("eachGuiElem", formRoot.getChildren())
{
        @Override
        protected void populateItem(ListItem<ObjectBase> item)
        {
                ObjectBase ob = item.getModelObject();
                                
                item.add(getPanelFromObjectBase("cell", ob, model, form));
        }
};

With that html content:

...
<tr wicket:id="eachGuiElem">
  <td style="border:0px;margin:0px;padding:0px;" wicket:id="cell"></td>
</tr>                     
...

Where getOPanelFromObjectBase contains something like this:

protected Panel getPanelFromObjectBase(String id, ObjectBase ob, IModel<?> model, final Form<?> form)
{
        if (ob.getClass().equals(GListAndDetail.class))
        {
                return new GWListAndDetail(id, model, (GListAndDetail) ob, 
form);
        }
        else if (ob.getClass().equals(GActionBox.class))
        {
                return new GWActionBox(id, model, (GActionBox) ob, form);
        }
...

All classes starting with GWxxx are subclasses of Wicket Panels.

Every GWxxx class has an HTML file with the same name and the ending html in the same directory as the class file. So Wicket should be able to find the right markup. And with the right markup it should be able to render not only the object tree but also the html representation.


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

Reply via email to