Re: redirect from render phase

2014-01-16 Thread Andrey
But in addition our exception handler extracts redirect destination from
our custom exception and performs redirect.
16.01.2014 17:08 пользователь "Thiago H de Paula Figueiredo" <
thiag...@gmail.com> написал:

> On Thu, 16 Jan 2014 10:41:55 -0200, Andrey  wrote:
>
>  Finally we've solved spam problem (but my collegues are not very happy
>> with
>> this entire approach):
>> we use log4j matcher to skip error log message from RenderQueueImpl, and
>> log it if needed in our exception handler.
>>
>> p.s. getters do not help, because they will throw exceptions too when
>> data unavailable.
>>
>
> Then this is normal exception handling.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: redirect from render phase

2014-01-16 Thread Thiago H de Paula Figueiredo

On Thu, 16 Jan 2014 10:41:55 -0200, Andrey  wrote:

Finally we've solved spam problem (but my collegues are not very happy  
with

this entire approach):
we use log4j matcher to skip error log message from RenderQueueImpl, and
log it if needed in our exception handler.

p.s. getters do not help, because they will throw exceptions too when  
data unavailable.


Then this is normal exception handling.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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



Re: redirect from render phase

2014-01-16 Thread Andrey
Finally we've solved spam problem (but my collegues are not very happy with
this entire approach):
we use log4j matcher to skip error log message from RenderQueueImpl, and
log it if needed in our exception handler.

p.s. getters do not help, because they will throw exceptions too when data
unavailable.
page request check looks better but, imho, code would become much harder to
understand and support.


2014/1/16 Thiago H de Paula Figueiredo 

> On Thu, 16 Jan 2014 05:49:09 -0200, Andrey  wrote:
>
>  Hello!
>>
>
> Hi!
>
>
>  We are in need of redirect from render phase.
>> Reasons are: we cannot fetch all required data in onActivate method of
>> page, because onActivate is called for page even for component events
>> inside page.
>> So we load data in setupRender. But there can be problems like data not
>> found, service unavailable etc.
>>
>
> You don't need to load data in setupRender or onActivate() in most cases.
> Suppose you're using Grid to list some data fetched from a database.
> Instead of
>
> @Property
> private List data;
>
> void setupRender() {
> data = someMethodThatReturnsYourData();
> }
>
> and a template like this: , you can
> keep the template and fetch the data in a getter:
>
> // this annotation guarantees the method body will be actually called only
> once per
> // request, even if the method is called many times in the same request
> @Cached
> public List getData() {
> return someMethodThatReturnsYourData();
> }
>
> In onActivate(), or any other method, you can check whether it's a page
> request or not:
>
> @Inject
> private Request request;
>
> @Inject
> private ComponentEventLinkEncoder componentEventLinkEncoder;
>
> boolean pageRequest = 
> componentEventLinkEncoder.decodePageRenderRequest(request)
> != null;
>
>
>  Is there any correct way in tapestry to redirect during render?
>>
>
> No.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
откланиваюсь,
Андрюха


Re: redirect from render phase

2014-01-16 Thread Geoff Callender
This may help:


http://jumpstart.doublenegative.com.au/jumpstart/examples/infrastructure/handlingabadcontext/1

Geoff

On 16/01/2014, at 6:49 PM, Andrey wrote:

> Hello!
> 
> We are in need of redirect from render phase.
> Reasons are: we cannot fetch all required data in onActivate method of
> page, because onActivate is called for page even for component events
> inside page.
> So we load data in setupRender. But there can be problems like data not
> found, service unavailable etc.
> 
> To solve this we've made our own RedirectException, and exception handler
> that catches it and performs redirect.
> 
> The last problem we have is spam in logs, that goes from RenderQueueImpl
> class.
> 
> Is there any correct way in tapestry to redirect during render?
> 
> With best regards, Andrey.


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



Re: redirect from render phase

2014-01-16 Thread Thiago H de Paula Figueiredo

On Thu, 16 Jan 2014 05:49:09 -0200, Andrey  wrote:


Hello!


Hi!


We are in need of redirect from render phase.
Reasons are: we cannot fetch all required data in onActivate method of
page, because onActivate is called for page even for component events
inside page.
So we load data in setupRender. But there can be problems like data not
found, service unavailable etc.


You don't need to load data in setupRender or onActivate() in most cases.  
Suppose you're using Grid to list some data fetched from a database.  
Instead of


@Property
private List data;

void setupRender() {
data = someMethodThatReturnsYourData();
}

and a template like this: , you can  
keep the template and fetch the data in a getter:


// this annotation guarantees the method body will be actually called only  
once per

// request, even if the method is called many times in the same request
@Cached
public List getData() {
return someMethodThatReturnsYourData();
}

In onActivate(), or any other method, you can check whether it's a page  
request or not:


@Inject
private Request request;

@Inject
private ComponentEventLinkEncoder componentEventLinkEncoder;

boolean pageRequest =  
componentEventLinkEncoder.decodePageRenderRequest(request) != null;



Is there any correct way in tapestry to redirect during render?


No.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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