You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by kshitiz <k....@gmail.com> on 2012/05/20 12:40:51 UTC
wicket not able to find component after adding container
componenent
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 ListItem<PostDomain> listItem,
final UserDomain userDomain) {
super(id);
// defining container for refreshing list of posts
final WebMarkupContainer postDomainContainer = new WebMarkupContainer(
"submitCommentPostDomainContainer");
postDomainContainer.setOutputMarkupId(true);
Form<CommentDomain> commentForm = new Form<CommentDomain>(
"commentForm",
new CompoundPropertyModel<CommentDomain>(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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: wicket not able to find component after adding container
componenent
Posted by kshitiz <k....@gmail.com>.
I solved my problem...found other way around to get my purpose...
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-not-able-to-find-component-after-adding-container-componenent-tp4646756p4647093.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: wicket not able to find component after adding container
componenent
Posted by kshitiz <k....@gmail.com>.
I did...actually this is the code:
public SubmitCommentPanel(String id, final ListItem<PostDomain> listItem,
final UserDomain userDomain) {
super(id);
// defining container for refreshing list of posts
* final WebMarkupContainer postDomainContainer = new WebMarkupContainer(
"submitCommentPostDomainContainer");
postDomainContainer.setOutputMarkupId(true);*
List<PostDomain> postDomainList = new ArrayList<PostDomain>();
postDomainList.add((PostDomain) listItem.getModelObject());
ListView<PostDomain> postDomainListView = new ListView<PostDomain>(
"post", postDomainList) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(final ListItem<PostDomain> listItem1) {
// Defining form for submitting comments for a post
Form<CommentDomain> commentForm = new Form<CommentDomain>(
"commentForm",
new CompoundPropertyModel<CommentDomain>(commentDomain));
commentForm.setModelObject(commentDomain);
// defining text field for user to submit comment
final RequiredTextField<String> commentTextField = new
RequiredTextField<String>(
"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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: wicket not able to find component after adding container
componenent
Posted by Carl-Eric Menzel <cm...@wicketbuch.de>.
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....@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 ListItem<PostDomain>
> listItem, final UserDomain userDomain) {
> super(id);
>
> // defining container for refreshing list of posts
> final WebMarkupContainer postDomainContainer = new
> WebMarkupContainer( "submitCommentPostDomainContainer");
> postDomainContainer.setOutputMarkupId(true);
>
> Form<CommentDomain> commentForm = new
> Form<CommentDomain>( "commentForm",
> new
> CompoundPropertyModel<CommentDomain>(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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org