You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <il...@gmail.com> on 2014/05/08 14:33:18 UTC

autocomplete data source

It turns out that running an event handler (onProvideCompletionsFromXXXX)
in the same component/page may result in various race condition problems.

Suppose you have a complex form and data initialization occurs during
onActivate phase. Then, this initialization is going to happen every time
onProvideCompletions handler is called. If this initialization involves for
example Hibernate objects loading, in several situations I get 'session is
closed' errors (in fact this is very unpredictable - the same operation
under same conditions may either work normally or fail).

Are there any suggested methods to make autocomplete data source totally
independent from current component?

-- 
Ilya Obshadko

Re: autocomplete data source

Posted by Ilya Obshadko <il...@gmail.com>.
Caching is definitely possible. But during onActivate() we cannot reliably
determine whether it was caused by autocomplete event (thus we can use
cached data), or it was caused by any other event (in which case we can't
use cached data).

So separating suggestions data source completely from the page would be an
optimal solution, but it cannot be done without completely re-writing logic
of the component, to make it possible to request an arbitrary event link
instead of event link within current page scope.



On Fri, May 16, 2014 at 2:02 AM, John <jo...@quivinco.com> wrote:

> Could you cache your hibernate results for subsequent calls?
>   ----- Original Message -----
>   From: Ilya Obshadko
>   To: Tapestry users
>   Sent: Thursday, May 08, 2014 1:33 PM
>   Subject: autocomplete data source
>
>
>   It turns out that running an event handler (onProvideCompletionsFromXXXX)
>   in the same component/page may result in various race condition problems.
>
>   Suppose you have a complex form and data initialization occurs during
>   onActivate phase. Then, this initialization is going to happen every time
>   onProvideCompletions handler is called. If this initialization involves
> for
>   example Hibernate objects loading, in several situations I get 'session
> is
>   closed' errors (in fact this is very unpredictable - the same operation
>   under same conditions may either work normally or fail).
>
>   Are there any suggested methods to make autocomplete data source totally
>   independent from current component?
>
>   --
>   Ilya Obshadko
>
>
> ---
> This email is free from viruses and malware because avast! Antivirus
> protection is active.
> http://www.avast.com
>



-- 
Ilya Obshadko

Re: autocomplete data source

Posted by John <jo...@quivinco.com>.
Could you cache your hibernate results for subsequent calls?
  ----- Original Message ----- 
  From: Ilya Obshadko 
  To: Tapestry users 
  Sent: Thursday, May 08, 2014 1:33 PM
  Subject: autocomplete data source


  It turns out that running an event handler (onProvideCompletionsFromXXXX)
  in the same component/page may result in various race condition problems.

  Suppose you have a complex form and data initialization occurs during
  onActivate phase. Then, this initialization is going to happen every time
  onProvideCompletions handler is called. If this initialization involves for
  example Hibernate objects loading, in several situations I get 'session is
  closed' errors (in fact this is very unpredictable - the same operation
  under same conditions may either work normally or fail).

  Are there any suggested methods to make autocomplete data source totally
  independent from current component?

  -- 
  Ilya Obshadko


---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com

Re: autocomplete data source

Posted by Ilya Obshadko <il...@gmail.com>.
Avoiding database operations during onActivate() phase is pretty obvious,
but it's not applicable here, because we need to handle database object
instantiation result (at least). As a simple example, if user doesn't have
access to an object requested, we need to redirect him to a login page. We
cannot do that past onActivate(), because all component rendering methods
cannot return anything besides true or false.

We might have (and in this particular situation we do have) even more
complicated situations, when we need to proceed with normal rendering, or
return Link instance to redirect user somewhere else, or even send
StreamResponse, depending on database instantiation result.



On Sun, May 18, 2014 at 11:27 AM, Geoff Callender <
geoff.callender.jumpstart@gmail.com> wrote:

> That's why I advise the following:
>
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/navigation/onactivateandonpassivate/3
>
> HTH,
>
> Geoff
>
> On 8 May 2014, at 10:33 pm, Ilya Obshadko <il...@gmail.com> wrote:
>
> > It turns out that running an event handler (onProvideCompletionsFromXXXX)
> > in the same component/page may result in various race condition problems.
> >
> > Suppose you have a complex form and data initialization occurs during
> > onActivate phase. Then, this initialization is going to happen every time
> > onProvideCompletions handler is called. If this initialization involves
> for
> > example Hibernate objects loading, in several situations I get 'session
> is
> > closed' errors (in fact this is very unpredictable - the same operation
> > under same conditions may either work normally or fail).
> >
> > Are there any suggested methods to make autocomplete data source totally
> > independent from current component?
> >
> > --
> > Ilya Obshadko
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Ilya Obshadko

Re: autocomplete data source

Posted by Geoff Callender <ge...@gmail.com>.
That's why I advise the following:

	http://jumpstart.doublenegative.com.au/jumpstart7/examples/navigation/onactivateandonpassivate/3

HTH,

Geoff

On 8 May 2014, at 10:33 pm, Ilya Obshadko <il...@gmail.com> wrote:

> It turns out that running an event handler (onProvideCompletionsFromXXXX)
> in the same component/page may result in various race condition problems.
> 
> Suppose you have a complex form and data initialization occurs during
> onActivate phase. Then, this initialization is going to happen every time
> onProvideCompletions handler is called. If this initialization involves for
> example Hibernate objects loading, in several situations I get 'session is
> closed' errors (in fact this is very unpredictable - the same operation
> under same conditions may either work normally or fail).
> 
> Are there any suggested methods to make autocomplete data source totally
> independent from current component?
> 
> -- 
> Ilya Obshadko


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: autocomplete data source

Posted by Ilya Obshadko <il...@gmail.com>.
Most of the page requests are in fact AJAX (page contains a lot of zone
updates besides autocomplete events). So distinguishing by isXHR() doesn't
help.


On Thu, May 15, 2014 at 6:39 PM, Michael Gentry <mg...@masslight.net>wrote:

> Hi Ilya,
>
> onActivate() gets called for both normal page render requests and AJAX/XHR
> requests (used by the autocomplete).  Have you tried:
>
> @Inject
> private Request request;
>
> and calling the isXHR() method in request in your onActivate() to determine
> if the request is normal or AJAX?
>
> onActivate()
> {
>   if (request.isXHR()) // Do AJAX
>   { ... }
>   else // Do Normal
>   { ... }
> }
>
> mrg
>
>
>
> On Thu, May 8, 2014 at 8:33 AM, Ilya Obshadko <ilya.obshadko@gmail.com
> >wrote:
>
> > It turns out that running an event handler (onProvideCompletionsFromXXXX)
> > in the same component/page may result in various race condition problems.
> >
> > Suppose you have a complex form and data initialization occurs during
> > onActivate phase. Then, this initialization is going to happen every time
> > onProvideCompletions handler is called. If this initialization involves
> for
> > example Hibernate objects loading, in several situations I get 'session
> is
> > closed' errors (in fact this is very unpredictable - the same operation
> > under same conditions may either work normally or fail).
> >
> > Are there any suggested methods to make autocomplete data source totally
> > independent from current component?
> >
> > --
> > Ilya Obshadko
> >
>



-- 
Ilya Obshadko

Re: autocomplete data source

Posted by Michael Gentry <mg...@masslight.net>.
Hi Ilya,

onActivate() gets called for both normal page render requests and AJAX/XHR
requests (used by the autocomplete).  Have you tried:

@Inject
private Request request;

and calling the isXHR() method in request in your onActivate() to determine
if the request is normal or AJAX?

onActivate()
{
  if (request.isXHR()) // Do AJAX
  { ... }
  else // Do Normal
  { ... }
}

mrg



On Thu, May 8, 2014 at 8:33 AM, Ilya Obshadko <il...@gmail.com>wrote:

> It turns out that running an event handler (onProvideCompletionsFromXXXX)
> in the same component/page may result in various race condition problems.
>
> Suppose you have a complex form and data initialization occurs during
> onActivate phase. Then, this initialization is going to happen every time
> onProvideCompletions handler is called. If this initialization involves for
> example Hibernate objects loading, in several situations I get 'session is
> closed' errors (in fact this is very unpredictable - the same operation
> under same conditions may either work normally or fail).
>
> Are there any suggested methods to make autocomplete data source totally
> independent from current component?
>
> --
> Ilya Obshadko
>