You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by local_shamil <sh...@gmail.com> on 2009/12/06 06:42:59 UTC

Update ListView using ajaX

in case if you found the solution, can u plzz reply to the forum

freak182 wrote:
> 
> Hello,
> 
> For no apparent reason the listview is not updating when i targeted it. im
> using wicket 1.4.1.
> 
> here is the code:
> 
> final WebMarkupContainer resultcontainer = new
> WebMarkupContainer("resultcontainer");
>     add(resultcontainer.setOutputMarkupId(true));
> 
>     final ListView<CustomFileDescription> files = new
> ListView<CustomFileDescription>("files", results)
>     {
>         @Override
>         protected void populateItem(ListItem<CustomFileDescription> item)
>         {
>         final CustomFileDescription fileDesc = item.getModelObject();
>         item.setModel(new
> CompoundPropertyModel<CustomFileDescription>(fileDesc));
>         item.add(new Label("name"));
>         item.add(new Label("lastModified"));
>         }
>     };
>     //files.setReuseItems(true);
>     resultcontainer.add(files);
> 
> final List<CustomFileDescription> results =
> fileSearchService.search(query.getDefaultModelObjectAsString());
>         System.out.println(results.size());
>         files.setDefaultModelObject(results);
>         target.addComponent(resultcontainer);
> 
> ...the results are just appending to each other.
> 
> Thanks a lot.
> Cheers.
> 
> 

-- 
View this message in context: http://old.nabble.com/Update-ListView-using-ajax-tp25310457p26662446.html
Sent from the Wicket - User 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: Update ListView using ajaX

Posted by Don Ferguson <do...@gmail.com>.
Hi all.

Rather than overwriting "results", shouldn't the code be more like:

List<CustomFileDescription> results = new  
ArrayList<CustomFileDescription>();
final WebMarkupContainer resultcontainer = new  
WebMarkupContainer("resultcontainer");
  add(resultcontainer.setOutputMarkupId(true));

  final ListView<CustomFileDescription> files = new  
ListView<CustomFileDescription>("files", results)
    {
       ...
    };
    resultcontainer.add(files);
...

   results.clear();
   results.addAll(Arrays.AsList(
	fileSearchService.search(query.getDefaultModelObjectAsString()
   ));
   target.addComponent(resultcontainer);

When you create the ListView, pass an instantiated List object (the  
Model Object, essentially), and modify the model by adding stuff to it.

-Don

On Dec 5, 2009, at 9:42 PM, local_shamil wrote:

>
> in case if you found the solution, can u plzz reply to the forum
>
> freak182 wrote:
>>
>> Hello,
>>
>> For no apparent reason the listview is not updating when i targeted  
>> it. im
>> using wicket 1.4.1.
>>
>> here is the code:
>>
>> final WebMarkupContainer resultcontainer = new
>> WebMarkupContainer("resultcontainer");
>>    add(resultcontainer.setOutputMarkupId(true));
>>
>>    final ListView<CustomFileDescription> files = new
>> ListView<CustomFileDescription>("files", results)
>>    {
>>        @Override
>>        protected void populateItem(ListItem<CustomFileDescription>  
>> item)
>>        {
>>        final CustomFileDescription fileDesc = item.getModelObject();
>>        item.setModel(new
>> CompoundPropertyModel<CustomFileDescription>(fileDesc));
>>        item.add(new Label("name"));
>>        item.add(new Label("lastModified"));
>>        }
>>    };
>>    //files.setReuseItems(true);
>>    resultcontainer.add(files);
>>
>> final List<CustomFileDescription> results =
>> fileSearchService.search(query.getDefaultModelObjectAsString());
>>        System.out.println(results.size());
>>        files.setDefaultModelObject(results);
>>        target.addComponent(resultcontainer);
>>
>> ...the results are just appending to each other.
>>
>> Thanks a lot.
>> Cheers.
>>
>>
>
> -- 
> View this message in context: http://old.nabble.com/Update-ListView-using-ajax-tp25310457p26662446.html
> Sent from the Wicket - User 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