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/06/02 20:31:00 UTC

Refresh listItem only of listView

Hi,

I have a scenario like this:

ListView<UserTypeDomain> userTypeDomainListView = new
ListView<UserTypeDomain>(
				"userType", userTypeDomainList) {
			
			protected void populateItem(final ListItem<UserTypeDomain> listItem) {

				listItem.add(new SubmitPostPanel("submitPostPanel",
						pageParameters, listItem, userDomain));

} 
}

In SubmitPostPanel, I have a ajax button for submitting post. What I want is
to refresh that listItem only which is passed in the Panel after submitting
post. I have tried out:

*listItem.setOutputMarkupId(true);*
*listItem.setOutputMarkupPlaceholderTag(true);*
AjaxFallbackButton ajaxPostSubmitButton = new AjaxFallbackButton(
				"postSubmitButton", postForm) {
			
			@Override
			public void onSubmit(AjaxRequestTarget target, final Form<?> form) {
                            *target.add(listItem);*
}

But the item is not getting refreshed. How can I achieve my purpose?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676.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: Refresh listItem only of listView

Posted by kshitiz <k....@gmail.com>.
Yes...u r right....it is working in the same manner only...:)

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676p4649694.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: Refresh listItem only of listView

Posted by Adam Gray <ad...@gmail.com>.
Remember that the code in the onClick is really just a callback.  This code
won't be executed until you have an entire listview to work with, because
the listview won't show up until it's completely rendered.  So in the link
callback, you just add the listview's container to the ajaxrequesttarget
and it happily re-rendered everything in that container.

On Sun, Jun 3, 2012 at 4:05 AM, kshitiz <k....@gmail.com> wrote:

> okk..so if ajaxbutton is part of every item of a listview, how can I
> refresh
> that view by pressing that button.I am asking because you will not able to
> add that listview as target in the button as it would not be completely
> defined by then.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676p4649683.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: Refresh listItem only of listView

Posted by kshitiz <k....@gmail.com>.
okk..so if ajaxbutton is part of every item of a listview, how can I refresh
that view by pressing that button.I am asking because you will not able to
add that listview as target in the button as it would not be completely
defined by then.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676p4649683.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: Refresh listItem only of listView

Posted by Sebastien <se...@gmail.com>.
Hi again,

Except if I am wrong, you cannot re-render just one listitem.
If you are going to change the content of one of the listitem's model
object, you will have to re-render the listview (by re-attaching its parent
to the target).
Now, if the list does not change (meaning, you are not going to add/remove
object), you can set ListView#setReuseItems to true so the re-rendering
will be more efficient.
Also, * If you nest a ListView in a Form, ALLWAYS set this property to
true, as otherwise validation will not work properly.* (setReuseItems
javadoc)

Hope this helps,
Sebastien.


On Sat, Jun 2, 2012 at 8:47 PM, kshitiz <k....@gmail.com> wrote:

> Hi,
>
> Yes...actually userTypeDomainList is a list of domain objects. I am
> creating
> view from this list, where each item of the view has saveral components.
> Now, on updating a component, i want to update its respective item, rather
> than whole listview. Do I need to put that item in a container to refresh
> it?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676p4649678.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: Refresh listItem only of listView

Posted by kshitiz <k....@gmail.com>.
Hi,

Yes...actually userTypeDomainList is a list of domain objects. I am creating
view from this list, where each item of the view has saveral components.
Now, on updating a component, i want to update its respective item, rather
than whole listview. Do I need to put that item in a container to refresh
it?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676p4649678.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: Refresh listItem only of listView

Posted by Sebastien <se...@gmail.com>.
Hi,

Well, you do not tell a much about the issue...

So, several possible answers are:
- You cannot add the listview in the target as it is a repeater, you should
add its (or one of its) parent.
- If you change the list, is your list a model ? (userTypeDomainList)

Regards,
Sebastien.

On Sat, Jun 2, 2012 at 8:31 PM, kshitiz <k....@gmail.com> wrote:

> Hi,
>
> I have a scenario like this:
>
> ListView<UserTypeDomain> userTypeDomainListView = new
> ListView<UserTypeDomain>(
>                                "userType", userTypeDomainList) {
>
>                        protected void populateItem(final
> ListItem<UserTypeDomain> listItem) {
>
>                                listItem.add(new
> SubmitPostPanel("submitPostPanel",
>                                                pageParameters, listItem,
> userDomain));
>
> }
> }
>
> In SubmitPostPanel, I have a ajax button for submitting post. What I want
> is
> to refresh that listItem only which is passed in the Panel after submitting
> post. I have tried out:
>
> *listItem.setOutputMarkupId(true);*
> *listItem.setOutputMarkupPlaceholderTag(true);*
> AjaxFallbackButton ajaxPostSubmitButton = new AjaxFallbackButton(
>                                "postSubmitButton", postForm) {
>
>                        @Override
>                        public void onSubmit(AjaxRequestTarget target,
> final Form<?> form) {
>                            *target.add(listItem);*
> }
>
> But the item is not getting refreshed. How can I achieve my purpose?
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Refresh-listItem-only-of-listView-tp4649676.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
>
>