In my case, I was adding something to 'this' instead of the parent / outer
item:

I think the line

        *add(new ListView("reportItems", reportItems) {*

is implicitly

        *this.add(new ListView("reportItems", reportItems) {*

and likely not what you want ... try changing it to

        *listItem*.add(new ListView("reportItems", reportItems) {


or in context:

add(new ListView("reportList", reportVector) {
                       public void populateItem(final ListItem listItem) {
                               Vector<ReportItem> reportItems = ((ReportDAO)
listItem

 .getModelObject()).getReportItems();
*                              listItem.add(new ListView("reportItems",
reportItems) {*


If that doesn't work for you - post the stack trace and try to match up the
line numbers to the source you've posted and someone here might spot the
problem.

-Luther



On Thu, May 28, 2009 at 11:26 PM, khamis0o <[email protected]>wrote:

>
> Can you please share the solution?
> I am doing something similar and I get java.lang.IllegalArgumentException:
> A
> child with id 'reoirtItems' already exists
>
>
> /*java*/
> add(new ListView("reportList", reportVector) {
>                        public void populateItem(final ListItem listItem) {
>                                Vector<ReportItem> reportItems =
> ((ReportDAO) listItem
>
>  .getModelObject()).getReportItems();
>                                add(new ListView("reportItems", reportItems)
> {
>                                        protected void populateItem(final
> ListItem reportItem) {
>
>                                                ReportItem item =
> (ReportItem) reportItem
>
>  .getModelObject();
>                                                int copyId =
> item.getCopyID();
>                                                String image =
> item.getItemImage();
>                                                String itemClass =
> item.getItemClass();
>                                                String itemSubClass =
> item.getItemSubClass();
>                                                String itemLocation =
> item.getItemLocation();
>                                                String actionDate =
> item.getActionDate();
>                                                String status =
> item.getState();
>                                                String userID =
> item.getUserID();
>
>                                                reportItem.add(new
> Label("image",
>                                                                (image ==
> null) ? "Unavailable" : image));
>                                                reportItem
>                                                                .add(new
> Label(
>
>    "itemClass",
>
>    (itemClass.equals("NA") || itemClass == null) ? "Unavailable"
>
>                    : itemClass));
>                                                reportItem.add(new
> Label("itemSubClass",
>
>  (itemSubClass == null) ? "Unavailable"
>
>    : itemSubClass));
>                                                reportItem.add(new
> Label("itemLocation",
>
>  (itemLocation == null) ? "Unavailable"
>
>    : itemLocation));
>                                                reportItem
>                                                                .add(new
> Label("actionDate",
>
>    actionDate == null ? "Unavailable"
>
>                    : actionDate));
>                                                reportItem.add(new
> Label("status",
>                                                                status ==
> null ? "Unavailable" : status));
>                                                reportItem.add(new
> Label("user",
>                                                                userID ==
> null ? "Unavailable" : userID));
>                                        }
>
>                                });
>
>                        }
>                });
> /*HTML*/
> <table wicket:id="reportList">
>        <table wicket:id="reportItems">
>                <tr>
>
>                        ---------------------------------------------
>
>                </tr>
>
>                <td wicket:id="image">[image path]</td>
>                <td>
>                <table>
>
>                        <tr>
>                                <td class="label">Title:</td>
>
>                                <td wicket:id="title">[Item's Title]</td>
>                        </tr>
>
>                        <tr>
>                                <td class="label">Class:</td>
>
>                                <td wicket:id="itemClass">[class]</td>
>                        </tr>
>
>                        <tr>
>
>                                <td class="label">Sub-Class:</td>
>
>                                <td wicket:id="itemSubClass">[subclass]</td>
>
>                        </tr>
>
>
>                        <tr>
>                                <td class="label">Location:</td>
>
>                                <td wicket:id="itemLocation">[location]</td>
>
>                        </tr>
>
>                        <tr>
>
>                                <td class="label">Date:</td>
>
>                                <td wicket:id="actionDate">[Action
> Date]</td>
>
>                        </tr>
>                        <tr>
>
>                                <td class="label">Status:</td>
>
>                                <td wicket:id="itemStatus">[item state]</td>
>
>                        </tr>
>                        <tr>
>
>                                <td class="label">User ID:</td>
>
>                                <td wicket:id="itemStatus">[user id]</td>
>
>                        </tr>
>
>
>                </table>
>                </td>
>        </table>
> </table>
>
>
> Sorry for posting my problem in your thread but i am a newbie here and i
> can't get to subscribe in the mailing list so I can't post any threads..
> Thanks for your understanding.. waiting for your reply.
>
>
> luther.baker wrote:
> >
> > Ahh ... but of course!
> >
> > Thanks both of you. The nested structure did indeed obscure the problem.
> >
> > Fixed and refactored a bit - and now working as expected.
> >
> > Thanks for your time!
> >
> > -Luther
> >
> >
> >
> > On Thu, Mar 26, 2009 at 12:01 PM, Jonathan Locke
> > <[email protected]>wrote:
> >
> >>
> >>
> >> uh, well maybe not dangerous, just less clear than it could be.
> >>
> >>
> >> Jonathan Locke wrote:
> >> >
> >> >
> >> > i think you mean to add the projects listview to the categories list
> >> view
> >> > /item/
> >> >
> >> > your structure is a little dangerous here because you have one
> ListItem
> >> > item
> >> > obscuring the other. if the outer one were called outerItem and the
> >> inner
> >> > one
> >> > were called innerItem, i think you meant to say
> outerItem.add(projects)
> >> > and
> >> > innerItem.add(link)
> >> >
> >> >
> >> > luther.baker wrote:
> >> >>
> >> >> I'm trying to create a page - similar to Jira's BROWSE PROJECTS.
> >> >>
> >> >> My initial take amounts to a loop in a loop.
> >> >>
> >> >> The outer loop is CATEGORIES and the inner loop is PROJECTS in said
> >> >> category.
> >> >>
> >> >> | CATEGORY 1
> >> >> | p1
> >> >> | p2
> >> >> | p3
> >> >>
> >> >> | CATEGORY 2
> >> >> | p4
> >> >> | p5
> >> >> | p6
> >> >>
> >> >> ...
> >> >>
> >> >> I've attached code below but if I removed the nested loop, I can
> >> easily
> >> >> loop
> >> >> over just CATEGORIES but as soon as I add the nested loop, it fails
> >> with
> >> >> the
> >> >> following
> >> >>
> >> >> WicketMessage: Error attaching this container for rendering: [Page
> >> class
> >> >> =
> >> >> com.fuzzybearings.milestones.web.page.user.ProjectsPage, id = 3,
> >> version
> >> >> =
> >> >> 0]
> >> >>
> >> >> Root cause:
> >> >>
> >> >> java.lang.IllegalArgumentException: A child with id 'projects'
> already
> >> >> exists:
> >> >> [MarkupContainer [Component id = categories]]
> >> >>
> >> >>
> >> >> My intuition tells me that 'wicket:id="projects"' is repeating since
> >> it
> >> >> is
> >> >> contained in an outer loop ... but I'm not sure how else to identify
> >> this
> >> >> type of structure in a general way. Is there a loop container more
> >> suited
> >> >> to
> >> >> this ... open to suggestions.
> >> >>
> >> >> Thanks in advance,
> >> >>
> >> >> -Luther
> >> >>
> >> >>
> >> >>
> >> >> *.html snippet
> >> >>
> >> >>         <div wicket:id="categories">
> >> >>         <table>
> >> >>             <tr wicket:id="projects">
> >> >>                 <td> # [project] </td>
> >> >>             </tr>
> >> >>         </table>
> >> >>         </div>
> >> >>
> >> >>
> >> >> *.java snippet
> >> >>
> >> >>     public ProjectsPage(ResourceModel bodyTitle)
> >> >>     {
> >> >>         super(bodyTitle);
> >> >>
> >> >>         ListView categories = new ListView("categories",
> >> >> this.getCategories())
> >> >>         {
> >> >>
> >> >>             @Override
> >> >>             protected void populateItem(ListItem item)
> >> >>             {
> >> >>                 Category category = (Category) item.getModelObject();
> >> >>
> >> >>                 ListView projects = new ListView("projects",
> >> >> ProjectsPage.this.getProjects(category))
> >> >>                 {
> >> >>
> >> >>                     @Override
> >> >>                     protected void populateItem(ListItem item)
> >> >>                     {
> >> >>                         Project project = (Project)
> >> >> item.getModelObject();
> >> >>                         Link link = new Link("projectLink",
> >> >> item.getModel())
> >> >>                         {
> >> >>
> >> >>                             @Override
> >> >>                             public void onClick() { ... }
> >> >>                         };
> >> >>                         link.add(new Label("projectLabel",
> >> >> project.getName()));
> >> >>                         item.add(link);
> >> >>                     }
> >> >>                 };
> >> >>                 this.add(projects);
> >> >>             }
> >> >>         };
> >> >>         this.add(categories);
> >> >>     }
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/nested-loop-view-tp22726252p22726482.html
> >> Sent from the Wicket - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [email protected]
> >> For additional commands, e-mail: [email protected]
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/nested-loop-view-tp22726252p23774065.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to