On Mon, 2007-04-30 at 23:55 +0200, Martin Grotzke wrote:
> hi igor,
> 
> i hope i got the idea now. i post my beans here, 
aehem, sorry - forgot to include SearchResultsView:

    public SearchResultsView(String id, PropertyModel model ) {
        super( id, model );
        final String query = (String) getModelObject();
        final List<? extends Product> products = 
((StealthShopApplication)getApplication()).getSearchService().find( query );
        setList( products );
    }

    @SuppressWarnings("serial")
    @Override
    protected void populateItem( ListItem listItem ) {
        final Product product = 
            (Product)listItem.getModelObject();
        listItem.add( new Label("id", product.getId() ) );
        listItem.add( new Label( "title", product.getTitle() ) );
        listItem.add( new Label( "description", product.getDescription() ) );
        listItem.add(new Link("showDetailsLink"){
            public void onClick(){
                PageParameters pp = new PageParameters();
                pp.add("productId", product.getId());
                setResponsePage(Index.class, pp);
            }
        });
    }

cheers :)
martin


> it would be nice
> if could tell me if anything's not following the right path :)
> 
> // the start page, simply with the search form
>     public Index(final PageParameters parameters) {
>         LOG.debug( "Creating new Index page with params " + parameters );
>         add( new SearchForm( "searchForm", new Model() ) );
>     }
> 
> // the search form
>     public SearchForm(String id, IModel model) {
>         super( id, model );
>         add( new TextField( "query", model ) );
>     }
> 
>     @Override
>     protected void onSubmit() {
>         // set response page with page params for bookmarkable urls
>         final PageParameters params = new PageParameters();
>         params.add( "query", (String) getModelObject() );
>         setResponsePage( SearchPage.class, params );
>     }
> 
> // the search page with form and results
>     private String _userInput;
> 
>     public SearchPage(final PageParameters parameters) {
>         _userInput = parameters.getString( "query" );
>         add( new SearchForm( "searchForm", new PropertyModel( this, 
> "userInput" ) ) ); 
>         add( new SearchResultsView( "productList", new PropertyModel( this, 
> "userInput" ), this ) );
>     }
> 
>     public String getUserInput() {
>         return _userInput;
>     }
> 
>     public void setUserInput( String userInput ) {
>         _userInput = userInput;
>     }
> 
> 
> cheers,
> martin
> 
> 
> On Mon, 2007-04-30 at 14:02 -0700, Igor Vaynberg wrote:
> > i suggest you read here:
> > http://cwiki.apache.org/confluence/display/WICKET/Working+with+Wicket
> > +models
> > 
> > the idea is pretty simple: 
> > the form submits its data into a bean, and the view renders according
> > to that bean. this is accomplished by having the form and the view's
> > models connected to the same bean via models.
> > 
> > -igor
> > 
> > 
> > On 4/30/07, Martin Grotzke <[EMAIL PROTECTED]> wrote:
> >         hi igor,
> >         
> >         i'm trying to implement your advice, but don't really know
> >         how to do this.
> >         
> >         what would the SearchForm then look like? does the form itself
> >         use the model and how is the input field added to the form? 
> >         
> >         and how can the ResultsView access the value of the
> >         PropertyModel?
> >         the model has a getObject(Component) accessor - does this mean
> >         that
> >         the ResultsView would need pass the SearchPage into getObject?
> >         
> >         thanx && cheers, 
> >         martin
> >         
> >         
> >         
> >         On Sun, 2007-04-29 at 18:05 -0700, Igor Vaynberg wrote:
> >         > in reality this isnt how its supposed to work.
> >         >
> >         > usually you would have something like this:
> >         >
> >         > searchpage { 
> >         >   private criteria crit;
> >         >
> >         >    searchpage() {
> >         >       add(new searchform("form", new PropertyModel(this,
> >         "crit"));
> >         >       add(new resultsview("view", new PropertyModel(this,
> >         "crit")); 
> >         >    }
> >         > }
> >         >
> >         > that way the form and the view are bound to the same
> >         criteria object.
> >         > the form modifies it, and the view renders according to it.
> >         you would
> >         > not call any setresponsepage in the form, the same insatance
> >         of the 
> >         > page would be reused. that is the wicket way. however, if
> >         you must
> >         > have that nice bookmarkable url then you need to call
> >         > setresponsepage(class, pageparams) from the form. it is not
> >         as clean,
> >         > but it works. 
> >         >
> >         > -igor
> >         >
> >         > On 4/29/07, Martin Grotzke <[EMAIL PROTECTED]>
> >         wrote:
> >         >         On Sun, 2007-04-29 at 17:41 -0700, Igor Vaynberg
> >         wrote: 
> >         >         > no, once the form is submitted the page is no
> >         longer
> >         >         bookmarkable and
> >         >         > so it will lose any bookmarkable/mounted url.
> >         >         >
> >         >         > if you want to keep it you can call 
> >         >         setresponsepage( page.class,
> >         >         > params) in onsubmit(), but in your case that is
> >         silly since
> >         >         > searchresultspage probably contains the submitted
> >         form
> >         >         anyways? 
> >         >         well, i can do this (setResponsePage with params).
> >         >         the SearchResultsPage indeed has a also an instance
> >         of the
> >         >         form,
> >         >         and the user can also initiate a search on the 
> >         >         SearchResultsPage.
> >         >
> >         >         so for each search the SearchForm.onSubmit creates a
> >         new
> >         >         SearchResultsPage and (indirectly) a new
> >         SearchForm...
> >         >
> >         >         i just wonder if this this is the way how wicket
> >         should work, 
> >         >         or if
> >         >         this stateless way is s.th. that is not really the
> >         target of
> >         >         component based frameworks...
> >         >
> >         >         thanx && cheers,
> >         >         martin
> >         >
> >         >
> >         >         >
> >         >         > -igor
> >         >         >
> >         >         >
> >         >         > On 4/29/07, Martin Grotzke <
> >         [EMAIL PROTECTED]>
> >         >         wrote:
> >         >         >         hi all,
> >         >         >
> >         >         >         i'm just starting with wicket and have a
> >         simple
> >         >         search 
> >         >         >         form, that leads to a SearchResultsPage.
> >         >         >
> >         >         >         the SearchResultsPage is mounted as a
> >         bookmarkable
> >         >         page (via
> >         >         >         mountBookmarkablePage("/search", 
> >         >         SearchResultsPage.class);),
> >         >         >         although the url that is shown then
> >         contains s.th.
> >         >         like
> >         >
> >         >         ?wicket:interface=:6:searchForm::IFormSubmitListener... 
> >         >         >
> >         >         >         is it possible to have a nicer url for the
> >         submitted
> >         >         form?
> >         >         >
> >         >         >         i'm using wicket 1.2.6 right now...
> >         >         > 
> >         >         >         thanx in advance,
> >         >         >         cheers,
> >         >         >         martin
> >         >         >
> >         >         >
> >         >         >
> >         >         >
> >         >
> >         
> > ------------------------------------------------------------------------- 
> >         >         >         This SF.net email is sponsored by DB2
> >         Express
> >         >         >         Download DB2 Express C - the FREE version
> >         of DB2
> >         >         express and
> >         >         >         take
> >         >         >         control of your XML. No limits. Just data.
> >         Click to 
> >         >         get it
> >         >         >         now.
> >         >         >         http://sourceforge.net/powerbar/db2/
> >         >         >
> >         _______________________________________________ 
> >         >         >         Wicket-user mailing list
> >         >         >         Wicket-user@lists.sourceforge.net
> >         >         >
> >         >
> >         https://lists.sourceforge.net/lists/listinfo/wicket-user
> >         >         >
> >         >         >
> >         >         >
> >         >         >
> >         >
> >         
> > ------------------------------------------------------------------------- 
> >         >         > This SF.net email is sponsored by DB2 Express
> >         >         > Download DB2 Express C - the FREE version of DB2
> >         express and
> >         >         take
> >         >         > control of your XML. No limits. Just data. Click
> >         to get it 
> >         >         now.
> >         >         > http://sourceforge.net/powerbar/db2/
> >         >         > _______________________________________________
> >         Wicket-user
> >         >         mailing list Wicket-user@lists.sourceforge.net
> >         >
> >         https://lists.sourceforge.net/lists/listinfo/wicket-user
> >         >         --
> >         >         Martin Grotzke
> >         >         http://www.javakaffee.de/blog/
> >         >
> >         >
> >         
> > ------------------------------------------------------------------------- 
> >         >         This SF.net email is sponsored by DB2 Express
> >         >         Download DB2 Express C - the FREE version of DB2
> >         express and
> >         >         take
> >         >         control of your XML. No limits. Just data. Click to
> >         get it 
> >         >         now.
> >         >         http://sourceforge.net/powerbar/db2/
> >         >         _______________________________________________
> >         >         Wicket-user mailing list 
> >         >         Wicket-user@lists.sourceforge.net
> >         >
> >         https://lists.sourceforge.net/lists/listinfo/wicket-user
> >         >
> >         >
> >         >
> >         >
> >         
> > -------------------------------------------------------------------------
> >         > This SF.net email is sponsored by DB2 Express
> >         > Download DB2 Express C - the FREE version of DB2 express and
> >         take 
> >         > control of your XML. No limits. Just data. Click to get it
> >         now.
> >         > http://sourceforge.net/powerbar/db2/
> >         > _______________________________________________ Wicket-user
> >         mailing list Wicket-user@lists.sourceforge.net
> >         https://lists.sourceforge.net/lists/listinfo/wicket-user
> >         -- 
> >         Martin Grotzke
> >         http://www.javakaffee.de/blog/
> >         
> >         
> > -------------------------------------------------------------------------
> >         This SF.net email is sponsored by DB2 Express 
> >         Download DB2 Express C - the FREE version of DB2 express and
> >         take
> >         control of your XML. No limits. Just data. Click to get it
> >         now.
> >         http://sourceforge.net/powerbar/db2/
> >         _______________________________________________
> >         Wicket-user mailing list
> >         Wicket-user@lists.sourceforge.net
> >         https://lists.sourceforge.net/lists/listinfo/wicket-user
> >         
> >         
> > 
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________ Wicket-user mailing list 
> > Wicket-user@lists.sourceforge.net 
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________ Wicket-user mailing list 
> Wicket-user@lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/wicket-user
-- 
Martin Grotzke
http://www.javakaffee.de/blog/

Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to