Re: wicket not able to find component after adding container componenent
You need to add the container to the panel: add(postDomainContainer); And you need to add the form to the container instead of the panel itself: postDomainContainer.add(commentForm); Your component hierarchy must match the tag hierarchy. Hope this helps Carl-Eric www.wicketbuch.de On Sun, 20 May 2012 03:40:51 -0700 (PDT) kshitiz k.agarw...@gmail.com wrote: Hi, I am trying to cover a form in a container. *SubmitCommentPanel:* wicket:panel * div wicket:id=submitCommentPostDomainContainer* form wicket:id=commentForm /form /div /wicket:panel The java code is : public SubmitCommentPanel(String id, final ListItemPostDomain listItem, final UserDomain userDomain) { super(id); // defining container for refreshing list of posts final WebMarkupContainer postDomainContainer = new WebMarkupContainer( submitCommentPostDomainContainer); postDomainContainer.setOutputMarkupId(true); FormCommentDomain commentForm = new FormCommentDomain( commentForm, new CompoundPropertyModelCommentDomain(commentDomain)); }; * add(commentForm);* But the error is: *Last cause: Unable to find component with id 'commentForm' in [WebMarkupContainer [Component id = submitCommentPostDomainContainer]]* But if I remove container portion, the code runs fine. Cant I add the container. One thing to note that the whole panel is in another container: div wicket:id=postDomainListContainer form wicket:id=postForm /form * div wicket:id=submitCommentPanel/div br/br* /div The above panel though runs fine. What is the issue? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-not-able-to-find-component-after-adding-container-componenent-tp4646756.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: wicket not able to find component after adding container componenent
I did...actually this is the code: public SubmitCommentPanel(String id, final ListItemPostDomain listItem, final UserDomain userDomain) { super(id); // defining container for refreshing list of posts * final WebMarkupContainer postDomainContainer = new WebMarkupContainer( submitCommentPostDomainContainer); postDomainContainer.setOutputMarkupId(true);* ListPostDomain postDomainList = new ArrayListPostDomain(); postDomainList.add((PostDomain) listItem.getModelObject()); ListViewPostDomain postDomainListView = new ListViewPostDomain( post, postDomainList) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItemPostDomain listItem1) { // Defining form for submitting comments for a post FormCommentDomain commentForm = new FormCommentDomain( commentForm, new CompoundPropertyModelCommentDomain(commentDomain)); commentForm.setModelObject(commentDomain); // defining text field for user to submit comment final RequiredTextFieldString commentTextField = new RequiredTextFieldString( comment, Model.of(commentDomain.getComment())); AjaxFallbackButton ajaxCommentSubmitButton = new AjaxFallbackButton( commentSubmitButton, commentForm) { /** * */ private static final long serialVersionUID = 1L; @Override public void onSubmit(AjaxRequestTarget target, final Form? form) { /* * Populating commentDomain instance for submitting * comment. This instance is then passed to * CommentService class */ if (target != null) { try { CommentService commentService = new CommentService(); commentService.addComment(commentDomain); } catch (Exception exception) { error(exception.getMessage()); } setResponsePage(getPage().getPageClass()); target.add(postDomainContainer); } } @Override protected void onError(AjaxRequestTarget target, Form? form) { // TODO Auto-generated method stub } }; commentForm.add(commentTextField); commentForm.add(ajaxCommentSubmitButton); *listItem.add(commentForm);* } }; *postDomainContainer.add(postDomainListView); add(postDomainContainer);* } -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-not-able-to-find-component-after-adding-container-componenent-tp4646756p4647052.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org