You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by anita nichols <an...@gmail.com> on 2007/10/10 23:22:13 UTC

Wicket Question

I have question regarding this code:
I got this error message:

WicketMessage: Unable to find component with id 'check' in [MarkupContainer
[Component id = item, page = com.fsp.HomePage, path = 0:showItems:
item.HomePage$TodoContainer$1, isVisible = true, isVersioned = true]]. This
means that you declared wicket:id=check in your markup, but that you either
did not add the component to your page at all, or that the hierarchy does
not match.

java
-----------
public class TodoContainer extends WebMarkupContainer
    {

        public TodoContainer(String id)
        {
            super(id);


            add(new SortableListView("item", "id" , items)
            {

                  /**
                 * callback extension point for populating each list item.
                 * @param item
                 */
                public void populateItemInternal(final ListItem item)
                {
                    // add an AJAX checkbox to the item
                    item.add(new AjaxCheckBox("check",
                            new PropertyModel(item.getModel(), "checked"))

                    {

                        protected void onUpdate(AjaxRequestTarget target)
                        {
                            // no need to do anything, the model is updated
by
                            // itself, and we don't have to re-render a
                            // component (the client already has the correct
                            // state).

                        }
                    });
                    // display the text of the milestone item

                    item.add(new AjaxEditInPlaceLabel("text", new
PropertyModel( item.getModel(), "text")));

                }
            });
        }
    }

html
------------

<div wicket:id="showItems">

        <div class="item" wicket:id="item">
            <div class="itemCheck" style="position:relative; margin:2px;
padding:2px; width:142px;"><input type="checkbox" wicket:id="check" />
            <span wicket:id="text">item text</span>
            </div>
        </div>
    </div>
 <div class="item">
        <div class="itemCheck">&nbsp;</div>
        <div class="itemText" wicket:id="addItems">


            <a href="#" wicket:id="link">New
item</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" wicket:id="remove">Remove
completed</a>
             <form wicket:id="form">

                <input type="text" wicket:id="text" />
                <input type="button" wicket:id="add" value="Add item" /> or
                <input type="button" wicket:id="cancel" value="Cancel" />
            </form>