you can create some reusable bookmarkablelink like below
public  class ReleaseBookmarkablePageLink extends BookmarkablePageLink{
        private Release release;
        public ReleaseBookmarkablePageLink(String id,Class<? extends
Page>pageClass,Release release){
            super(id,pageClass);
            this.release=release;
        }
        @Override
        protected void onInitialize() {
            super.onInitialize();
            getPageParameters().set("product",
release.getProduct().getName())    ;
            getPageParameters().set("version", release.getVersion() );
        }
    }

if you don't want to serialize release object,you can just serialize
it's key and retrieve release object from it


On Tue, Sep 18, 2012 at 7:39 AM, Ondrej Zizka <ozi...@redhat.com> wrote:
> Hi,
>
> I found myself repeatedly creating a PageParameters object from some
> domain object for BookmarkablePageLink just to have it then "parsed"
> back to that same domain object.
> Example:
>
>     Release rel { product: AS; version: 7.1.2 }
>     =>
>     add( new BookmarkablePageLink ( "link", ReleasePage.class, new
> PageParameters()
>             .add("product", rel.getProduct().getName())
>             .add("version", rel.getVersion() )
>     ) );
>
> So to avoid repeating that all the time, I created (besides a link
> component) this in ReleasePage:
>
>     public static PageParameters createPageParameters( Release rel ){
>         return new PageParameters()
>             .add("product", rel.getProduct().getName())
>             .add("version", rel.getVersion() );
>     }
>
> And I was thinking - is there some mechanism to automatically create the
> params from the domain object, using properties matching against mount()
> string?
> E.g. like this:
>
>     mountPage("/release/${product.name}/${version}", ReleasePage.class);
>     new BookmarkablePageLink ( "link", ReleasePage.class, rel);   //
> This would create page params the properties.
>
> Anything like this available? If not, is it doable? It would reduce
> quite some boilerplate code.
>
> Thanks,
> Ondra
>
>



-- 
regards,

Vineet Semwal

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to