Hi,

On Tue, Sep 18, 2012 at 5:09 AM, Ondrej Zizka <[email protected]> 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.

No, there is no such functionality in Wicket.
Whether it is doable - yes, everything is doable. But your approach is
much more simpler.
If something like this should be in the framework then
BookmarkablePageLink (and other clients of this API) should use a
helper that will have to find the respective IRequestMapper that is
responsible for that page, then this mapper will have to expose some
of its internals to be able to read its page class and named
parameters placeholders and finally it should use some Expression
Language parser to match the placeholders against the passed POJO ...
You see that it is much more complex.

>
> Thanks,
> Ondra
>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to