-Igor
On 1/27/06,
David Leangen <[EMAIL PROTECTED]> wrote:
> here is how i would do it.
Awesome!
The little bit I was missing is how the page is used as the model, and
the model is updated in onSubmit().
I added a new wiki page that explains this:
http://www.wicket-wiki.org.uk/wiki/index.php/Reading_from_a_Database
If I have time, I'll try to add more info for beginners.
I am getting this Exception, though:
java.lang.IllegalArgumentException: A child with id 'article.title'
already exists:
Why is this happening and how do I avoid this?
Cheers,
Dave
On Thu, 2006-01-26 at 22:53 -0800, Igor Vaynberg wrote:
> makes perfect sense. its pretty easy once you get the feel for how
> things work.
>
> the problem with what you are doing right now is that you are
> initializing your "repeater" in the page constructor. since the page
> is only constructed once the display doesnt change. what you want is a
> type of a repeater that refreshes every time the page renders. this is
> exactly what the listview is for. since you are working with the
> database you might also check out the dataprovider/dataview repeaters
> that are made to work specifically with database-fed data.
>
> but for simplicity lets go with the listview. what the listview does
> on every page render is read the list (which is its model object) and
> render items based on that list.
>
> here is how i would do it.
>
> SearchPage extends WebPage {
>
> String criteria;
> List results;
>
> //getters and setters
>
> public SearchPage() {
> ListView view=new ListVIew("list", new PropertyModel(this,
> "results") {
> populateItem(ListItem item) {
> String result=item.getModelObject();
> add(new Label("item", result));
> }
>
> );
>
> Form form=new SearchForm(....);
> form.add(new TextField("id", new PropertyModel(this, "criteria"));
> form.add(new Button() {
> onsubmit() {
> results=getResultsFromCriteria(criteria);
> }
> }
> }
>
> so what we have here works like this:
> everytime the page renders the listview will feed off the results list
> which is a page property
>
> everytime the form is submitted it changes the value of the list that
> feeds the listview based on the criteria string.
>
> so all the objects are created once in the constructor, but the data
> is retrieved dynamically.
>
> for a listview explanation please see here:
>
> http://thread.gmane.org/gmane.comp.java.wicket.user/7763
>
> -Igor
>
>
>
>
>
>
>
>
>
>
>
>
> On 1/26/06, David Leangen <[EMAIL PROTECTED]> wrote:
>
> Igor, thanks, as always, for the help.
>
> > i dont really understand what you are trying to do. what is
> your end
> > goal to have displayed on the page? what are your inputs?
> where are
> > they coming from?
>
> I suppose that what I want to do is very typical, but I just
> haven't yet
> figured out how to do it in Wicket. Here is the pseudocode:
>
>
> [Initial conditions: no query string]
>
> Get query string from form input
> With query string
> Get query _expression_
> o test validity of _expression_
> o return query model object
> With query _expression_, return search results
> o retrieved from (dynamic) DB
> o paged based on query
> For each result
> Display result
>
>
> Pretty basic, I guess. Hope this makes sense.
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log files
> for problems? Stop! Download the new AJAX search engine that
> makes
> searching your log files as easy as surfing
> the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?
> cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Wicket-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
