You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eman Nollase <em...@gmail.com> on 2009/09/05 19:05:43 UTC
Update ListView using ajax
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.
Re: Update ListView using ajax
Posted by Roger Armstrong <ro...@armstrongconsulting.net>.
Which "markup thing" did you adjust to make it work?
freak182 wrote:
>
> i already make it work. (need to adjust some markup thing :) )
>
--
View this message in context: http://old.nabble.com/Update-ListView-using-ajax-tp25310457p26514074.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 freak182 <em...@gmail.com>.
<div wicket:id="listview">
</div>
same also for table.
Hui Chen wrote:
>
> I met the same problem, how you adjust your markup?
>
> And I found that if the listView is a part of a table markup(as your code
> above) and when it's updated via Ajax by target.addComponent(container),
> the original container in the page can not be replaced , a same new one
> will show in the page.
>
> That means in the table markup, if WebMarkupContainer of listView is the
> <table>, everything will be Ok,
> but if the WebMarkupContainer of listView is a <div>, things weird
> happened .
>
> Why it happens? browser?
>
>
>
> freak182 wrote:
>>
>> Hello,
>>
>> thank you for your. i already make it work. (need to adjust some markup
>> thing :) )
>>
>> thanks a lot.
>> cheers.
>>
>>
>> michael mosmann wrote:
>>>
>>> Hmm,..
>>>
>>> can you post your markup? this code does work with my own markup..
>>>
>>> did you use <div wicket:id="resultcontainer"> or did you use
>>> <wicket:container wicket:id="resultcontainer"> .. do you see something
>>> in wicket-ajax-debug panel? any error-message? any ajax-response?
>>>
>>>> ...and im pretty sure that i already some code in previous version of
>>>> wicket
>>>> and it work..but i dont know what im missing right now. maybe worst
>>>> case i
>>>> will do is to go back to old version of wicket but i want the latest
>>>> version.
>>>
>>> if this does not work with wicket 1.4.1, then it does not work with any
>>> wicket version..
>>>
>>> mm:)
>>>
>>> --
>>> Michael Mosmann - http://www.wicket-praxis.de/blog
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Update-ListView-using-ajax-tp25310457p26635803.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 Hui Chen <ch...@gmail.com>.
I met the same problem, how you adjust your markup?
And I found that if the listView is a part of a table markup(as your code
above) and when it's updated via Ajax by target.addComponent(container),
the original container in the page can not be replaced , a same new one will
show in the page.
That means in the table markup, if WebMarkupContainer of listView is the
<table>, everything will be Ok,
but if the WebMarkupContainer of listView is a <div>, things weird happened
.
Why it happens? browser?
freak182 wrote:
>
> Hello,
>
> thank you for your. i already make it work. (need to adjust some markup
> thing :) )
>
> thanks a lot.
> cheers.
>
>
> michael mosmann wrote:
>>
>> Hmm,..
>>
>> can you post your markup? this code does work with my own markup..
>>
>> did you use <div wicket:id="resultcontainer"> or did you use
>> <wicket:container wicket:id="resultcontainer"> .. do you see something
>> in wicket-ajax-debug panel? any error-message? any ajax-response?
>>
>>> ...and im pretty sure that i already some code in previous version of
>>> wicket
>>> and it work..but i dont know what im missing right now. maybe worst case
>>> i
>>> will do is to go back to old version of wicket but i want the latest
>>> version.
>>
>> if this does not work with wicket 1.4.1, then it does not work with any
>> wicket version..
>>
>> mm:)
>>
>> --
>> Michael Mosmann - http://www.wicket-praxis.de/blog
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
>
--
View this message in context: http://old.nabble.com/Update-ListView-using-ajax-tp25310457p26635790.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 freak182 <em...@gmail.com>.
Hello,
thank you for your. i already make it work. (need to adjust some markup
thing :) )
thanks a lot.
cheers.
michael mosmann wrote:
>
> Hmm,..
>
> can you post your markup? this code does work with my own markup..
>
> did you use <div wicket:id="resultcontainer"> or did you use
> <wicket:container wicket:id="resultcontainer"> .. do you see something
> in wicket-ajax-debug panel? any error-message? any ajax-response?
>
>> ...and im pretty sure that i already some code in previous version of
>> wicket
>> and it work..but i dont know what im missing right now. maybe worst case
>> i
>> will do is to go back to old version of wicket but i want the latest
>> version.
>
> if this does not work with wicket 1.4.1, then it does not work with any
> wicket version..
>
> mm:)
>
> --
> Michael Mosmann - http://www.wicket-praxis.de/blog
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Update-ListView-using-ajax-tp25310457p25326735.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 freak182 <em...@gmail.com>.
Hello,
my markup:
<fieldset>
<legend>List of Files</legend>
<table border="1">
<tr>
<td>Date Uploaded</td>
<td>Name</td>
</tr>
<div wicket:id="resultcontainer">
<tr wicket:id="files">
<td></td>
<td></td>
</tr>
</div>
</table>
</fieldset>
...ajax response:
first result:
<?xml version="1.0" encoding="UTF-8"?><ajax-response><component
id="resultcontainer4" ><![CDATA[<div id="resultcontainer4">
<tr>
<td>9/6/09 12:05 AM</td>
<td>The_tree_is_on_fire.jpg</td>
</tr>
</div>]]></component></ajax-response>
next time i hit the button:
<?xml version="1.0" encoding="UTF-8"?><ajax-response><component
id="resultcontainer4" ><![CDATA[<div id="resultcontainer4">
<tr>
<td>9/6/09 12:59 AM</td>
<td>Death_Valley_IMG_1936.jpg</td>
</tr>
</div>]]></component></ajax-response>
...seems right...but in display in firefox:
http://www.nabble.com/file/p25326096/Screenshot-Mozilla%2BFirefox.png
thanks a lot.
cheers.
michael mosmann wrote:
>
> Hmm,..
>
> can you post your markup? this code does work with my own markup..
>
> did you use <div wicket:id="resultcontainer"> or did you use
> <wicket:container wicket:id="resultcontainer"> .. do you see something
> in wicket-ajax-debug panel? any error-message? any ajax-response?
>
>> ...and im pretty sure that i already some code in previous version of
>> wicket
>> and it work..but i dont know what im missing right now. maybe worst case
>> i
>> will do is to go back to old version of wicket but i want the latest
>> version.
>
> if this does not work with wicket 1.4.1, then it does not work with any
> wicket version..
>
> mm:)
>
> --
> Michael Mosmann - http://www.wicket-praxis.de/blog
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Update-ListView-using-ajax-tp25310457p25326096.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 Michael Mosmann <mi...@mosmann.de>.
Hmm,..
can you post your markup? this code does work with my own markup..
did you use <div wicket:id="resultcontainer"> or did you use
<wicket:container wicket:id="resultcontainer"> .. do you see something
in wicket-ajax-debug panel? any error-message? any ajax-response?
> ...and im pretty sure that i already some code in previous version of wicket
> and it work..but i dont know what im missing right now. maybe worst case i
> will do is to go back to old version of wicket but i want the latest
> version.
if this does not work with wicket 1.4.1, then it does not work with any
wicket version..
mm:)
--
Michael Mosmann - http://www.wicket-praxis.de/blog
---------------------------------------------------------------------
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 freak182 <em...@gmail.com>.
hello,
here is the codes:
final Form<Void> form = new Form<Void>("search");
add(form);
final TextField<String> query = new TextField<String>("query", new
PropertyModel<String>(this, "search") );
form.add(query);
List<CustomFileDescription> results = null;
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 IndicatingAjaxButton buttquery = new IndicatingAjaxButton("submit",
form)
{
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
final List<CustomFileDescription> results =
fileSearchService.search(query.getDefaultModelObjectAsString());
System.out.println(results.size());
files.setDefaultModelObject(results);
target.addComponent(resultcontainer);
}
};
form.add(buttquery);
...and im pretty sure that i already some code in previous version of wicket
and it work..but i dont know what im missing right now. maybe worst case i
will do is to go back to old version of wicket but i want the latest
version.
Thanks a lot.
Cheers.
michael mosmann wrote:
>
> Hi,
>
>> i think i already put it in the webmarkupcontainer and target the
>> markupcontainer.
>
> ok..
> my fault.. sorry.
>
> can you post some more code.. i am not sure to see the full picture yet.
>
>> For no apparent reason the listview is not updating when i targeted it.
>> im
>> using wicket 1.4.1.
>
> does it work without ajax?
>
> mm:)
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Update-ListView-using-ajax-tp25310457p25324461.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 Michael Mosmann <mi...@mosmann.de>.
Hi,
> i think i already put it in the webmarkupcontainer and target the
> markupcontainer.
ok..
my fault.. sorry.
can you post some more code.. i am not sure to see the full picture yet.
> For no apparent reason the listview is not updating when i targeted it. im
> using wicket 1.4.1.
does it work without ajax?
mm:)
---------------------------------------------------------------------
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
Update ListView using ajaX
Posted by local_shamil <sh...@gmail.com>.
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 freak182 <em...@gmail.com>.
Hello,
i think i already put it in the webmarkupcontainer and target the
markupcontainer.
michael mosmann wrote:
>
> Am Sonntag, den 06.09.2009, 01:05 +0800 schrieb Eman Nollase:
>> Hello,
>>
>> For no apparent reason the listview is not updating when i targeted it.
>> im
>> using wicket 1.4.1.
>
> The ListView ist replaced with it's childs. Therefore you can not update
> the ListView. The simple solution to this is a WebMarkupContainer around
> the ListView.
>
> mm:)
>
> --
> Michael Mosmann http://www.wicket-praxis.de/blog/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/Update-ListView-using-ajax-tp25310457p25317613.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 Michael Mosmann <mi...@mosmann.de>.
Am Sonntag, den 06.09.2009, 01:05 +0800 schrieb Eman Nollase:
> Hello,
>
> For no apparent reason the listview is not updating when i targeted it. im
> using wicket 1.4.1.
The ListView ist replaced with it's childs. Therefore you can not update
the ListView. The simple solution to this is a WebMarkupContainer around
the ListView.
mm:)
--
Michael Mosmann http://www.wicket-praxis.de/blog/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org