Hi Dan, thanks a lot. Works like a charm.
Cheers Kambiz On 2016-09-30 09:46 CEST, Dan Haywood <[email protected]> wrote: > Hi Kambiz, > > You are pretty close... you can use getIsisSessionFactory().doInSession(...) > > there's an example in the RegisterPanel, a component of the Wicket > RegistrationPage.html / .java [1], ie: > > getIsisSessionFactory().doInSession(new Runnable() { > @Override > public void run() { > final UserRegistrationService userRegistrationService = > getIsisSessionFactory() > > .getServicesInjector().lookupService(UserRegistrationService.class); > > > getIsisSessionFactory().getCurrentSession().getPersistenceSession().getTransactionManager() > .executeWithinTransaction(new TransactionalClosure() { > @Override > public void execute() { > userRegistrationService.registerUser(userDetails); > removeAccountConfirmation(); > } > }); > } > }); > > > HTH > Dan > > [1] > https://github.com/apache/isis/blob/rel/isis-1.13.0/core/viewer-wicket-ui/src/main/java/org/apache/isis/viewer/wicket/ui/pages/accmngt/register/RegisterPanel.java#L127 > > > > On 29 September 2016 at 22:08, Kambiz Darabi <[email protected]> wrote: > >> Hi, >> >> in one of our applications, we have a Wicket page which is mounted onto >> a context path and streams a video resource to the calling client, based >> on some page parameters. >> >> Up to now, this page uses http calls to the RO viewer to perform the >> domain-related validations, lookups etc. >> >> I would like to access the repositories and services directly, which are >> available through getServicesInjector().lookupService(Class), but such >> calls end in NPEs, because the persistence session is null. >> >> PageAbstract has a getPersistenceSession() method which throws an NPE, >> as >> >> getIsisSessionFactory().getCurrentSession() >> >> seems to return null. >> >> Is there something special I need to perform prior to using >> getPersistenceSession() ? >> >> Thanks >> >> >> Kambiz >>
