Hi,

On Mon, Jan 21, 2013 at 9:55 AM, Martin Grigorov <[email protected]>wrote:

> This is not available out of the box but it is possible to do it without
> any changes in wicket-core.
> Just provide your own impl of IPageFactory interface. Use
> DefaultPageFactory as inspiration.
>
> Here are the problems that I see with it:
> - it will use reflection to find all available constructors in a page
> -- needs a cache to not read class metadata more than once per page
> - needs a logic to decide what to do if  there are more than one converters
> which would create a POJO for the same parameters
>

In such case maybe converter can be specified on annotation?


> - FormComponents' IConverter currently has a unresolved problem - it
> doesn't support base type. E.g. if there is registered converter
> for Employee but a Page has constructor with Person (which is base for
> Employee) parameter should the converter be used ?
>
> What would such converter actually do? I guess the encoder for an employee
> it will generate PageParameters with id->empId (assuming you want a nice
> looking url which will encode 'employee' as Url segment, e.g.
> /company/employee/34).



Later the decoder will do what ? Will make a request to the DB to load all
> the details for the Employee ? I think it should provide a model -
> MyPage(IModel<Employee>), e.g. LDM<Employee>, and make the request to the
> DB as late as possible. But we already have this constructor in (Web)Page
> API (org.apache.wicket.Page#Page(IModel))
>
> A converter could be an interface and have different implementations that
can be chained/combined defined at annotation. E.g. One implementation that
extracts a POJO out of the request parameters using reflection to populate
some fields,  combined with one that fetches the rest of entity from data
for database... Also once bean is constructed users could do whatever they
want with the supplied POJO. Maybe this could be used to provide also an
IModel<Bean> by combining converter?


>
>
> On Mon, Jan 21, 2013 at 9:14 AM, Martijn Dashorst <
> [email protected]> wrote:
>
> > We have a really nice type safe API but the thing that strikes me as
> > odd is that AFIAK we don't have converters from PageParameters to
> > objects and back. Now it probably is not easy to get it right, but
> > what would be not too crazy is to be able to register a
> > PersonPageParametersConverter such that a PersonPage taking a Person
> > as a constructor parameter would be considered bookmarkable.
> >
> > Perhaps this would be good to have as an annotation?
> >
> > Martijn
> >
> > --
> > Become a Wicket expert, learn from the best: http://wicketinaction.com
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com <http://jweekend.com/>
>



-- 
Regards - Ernesto Reinaldo Barreiro
Antilia Soft
http://antiliasoft.com/ <http://antiliasoft.com/antilia>

Reply via email to