Re: [T4] PageRedirectException in pageValidate after AjaxDirectLink

2008-03-27 Thread Andreas Andreou
Tapestry 4.0.x with tacos probably doesn't add the request header...
just the parameter. So, what you're seeing is consistent, and if
you want to plan ahead, check for the existence of either of those

On Thu, Mar 27, 2008 at 11:32 PM, Kelly Merrell <[EMAIL PROTECTED]> wrote:
> Thanks for the example Steve. My only issue is that I don't seem to be
>  getting a "dojo-ajax-request" header in the request. There is a
>  "dojoRequest" parameter, which seems like I can use it for the same
>  purpose. Are you using a version of Tapestry greater than 4.02?
>
>  I'm going to try  to adopt your method, but without moving my
>  authentication code into the servlet filter.
>
>  Thanks again!
>
>
>
>  Steve Shucker wrote:
>  > I already had a servlet filter doing some custom authentication and
>  > handling redirects to a separate login service for expired sessions,
>  > so I added a little extra code in there.  First off, you can identify
>  > ajax requests by the presence of an HttpServletRequest header called
>  > "dojo-ajax-request" with a value of "true".  If I see that header, I
>  > write my own custom response instead of going down the filter chain.
>  > Here's the method I use to build the response:
>  >
>  >private void sendAjaxRedirect(HttpServletResponse httpResponse)
>  > throws IOException {
>  >PrintWriter writer = httpResponse.getWriter();
>  >writer.write("");
>  >writer.write("  > Transitional//EN\"
>  > \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\";
>  > [\n\n]>\n");
>  >writer.write("");
>  >writer.write("  > type=\"script\">\n//  >writer.write("window.location.href = '" +
>  > params.getOriginalUrl() + "';\n");
>  >writer.write("//]]>\n");
>  >writer.write("");
>  >}
>  >
>  > replace "params.getOriginalUrl()" with the entry URL for your app.
>  >
>  > This code generates a response that the tapestry/dojo wiring will
>  > interpret by parsing the window.location.href javascript.
>  >
>  > -Steve
>  >
>  > Kelly Merrell wrote:
>  >> I'm having a problem with my authentication redirect when using Ajax
>  >> to update page components. I use PageRedirectException on each page
>  >> to redirect to a login page if the user is not logged in when the
>  >> page validates. This works as expected when hitting the page
>  >> normally, but if I am using an AjaxDirectLink after the login has
>  >> expired, the response is returned as the HTML of the login page and
>  >> not "handled" by AjaxDirectService so that it is wrapped in the xml
>  >> tags and have the "window.location.href" javascript redirect added.
>  >> As the response is not xml, it breaks on the client side and the page
>  >> does not redirect.
>  >>
>  >> I have seen a few other people bring up this issue, but I can't find
>  >> any evidence of a solution or work around. I would have thought that
>  >> this would be a common problem, but maybe I am just overlooking a
>  >> simple fix. Any help here would be greatly appreciated!
>  >>
>  >> My pageValidate method is simply:
>  >>
>  >> public void pageValidate(PageEvent event) {
>  >>if (!isLoggedIn()) {
>  >>Login loginPage = getRedirectPage();
>  >>throw new PageRedirectException(loginPage);
>  >>}
>  >> }
>  >
>
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Andreas Andreou - [EMAIL PROTECTED] - http://blog.andyhot.gr
Tapestry / Tacos developer
Open Source / JEE Consulting

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T4] PageRedirectException in pageValidate after AjaxDirectLink

2008-03-27 Thread Steve Shucker
I'm using 4.1.5 and I think I wrote that code against 4.1.3.  I agree 
that you shouldn't move your auth code into a filter - I only mentioned 
that to explain why I wasn't handing you the whole filter code.  You may 
have to tweak the generated code a bit for 4.0.2.  I just used firebug 
to grab a dojo response and looked for some JS that I knew was 
executing.  Once you know to look for a custom header, the rest is easy.


-Steve

Kelly Merrell wrote:
Thanks for the example Steve. My only issue is that I don't seem to be 
getting a "dojo-ajax-request" header in the request. There is a 
"dojoRequest" parameter, which seems like I can use it for the same 
purpose. Are you using a version of Tapestry greater than 4.02?


I'm going to try  to adopt your method, but without moving my 
authentication code into the servlet filter.


Thanks again!

Steve Shucker wrote:
I already had a servlet filter doing some custom authentication and 
handling redirects to a separate login service for expired sessions, 
so I added a little extra code in there.  First off, you can identify 
ajax requests by the presence of an HttpServletRequest header called 
"dojo-ajax-request" with a value of "true".  If I see that header, I 
write my own custom response instead of going down the filter chain.  
Here's the method I use to build the response:


   private void sendAjaxRedirect(HttpServletResponse httpResponse) 
throws IOException {

   PrintWriter writer = httpResponse.getWriter();
   writer.write("");
   writer.write("Transitional//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"; 
[\n\n]>\n");

   writer.write("");
   writer.write("type=\"script\">\n//   writer.write("window.location.href = '" + 
params.getOriginalUrl() + "';\n");
   writer.write("//]]>\n");
   writer.write("");
   }

replace "params.getOriginalUrl()" with the entry URL for your app.

This code generates a response that the tapestry/dojo wiring will 
interpret by parsing the window.location.href javascript.


-Steve

Kelly Merrell wrote:
I'm having a problem with my authentication redirect when using Ajax 
to update page components. I use PageRedirectException on each page 
to redirect to a login page if the user is not logged in when the 
page validates. This works as expected when hitting the page 
normally, but if I am using an AjaxDirectLink after the login has 
expired, the response is returned as the HTML of the login page and 
not "handled" by AjaxDirectService so that it is wrapped in the xml 
tags and have the "window.location.href" javascript redirect added. 
As the response is not xml, it breaks on the client side and the 
page does not redirect.


I have seen a few other people bring up this issue, but I can't find 
any evidence of a solution or work around. I would have thought that 
this would be a common problem, but maybe I am just overlooking a 
simple fix. Any help here would be greatly appreciated!


My pageValidate method is simply:

public void pageValidate(PageEvent event) {
   if (!isLoggedIn()) {
   Login loginPage = getRedirectPage();
   throw new PageRedirectException(loginPage);
   }
}





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T4] PageRedirectException in pageValidate after AjaxDirectLink

2008-03-27 Thread Kelly Merrell
Thanks for the example Steve. My only issue is that I don't seem to be 
getting a "dojo-ajax-request" header in the request. There is a 
"dojoRequest" parameter, which seems like I can use it for the same 
purpose. Are you using a version of Tapestry greater than 4.02?


I'm going to try  to adopt your method, but without moving my 
authentication code into the servlet filter.


Thanks again!

Steve Shucker wrote:
I already had a servlet filter doing some custom authentication and 
handling redirects to a separate login service for expired sessions, 
so I added a little extra code in there.  First off, you can identify 
ajax requests by the presence of an HttpServletRequest header called 
"dojo-ajax-request" with a value of "true".  If I see that header, I 
write my own custom response instead of going down the filter chain.  
Here's the method I use to build the response:


   private void sendAjaxRedirect(HttpServletResponse httpResponse) 
throws IOException {

   PrintWriter writer = httpResponse.getWriter();
   writer.write("");
   writer.write("Transitional//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"; 
[\n\n]>\n");

   writer.write("");
   writer.write("type=\"script\">\n//   writer.write("window.location.href = '" + 
params.getOriginalUrl() + "';\n");
   writer.write("//]]>\n");
   writer.write("");
   }

replace "params.getOriginalUrl()" with the entry URL for your app.

This code generates a response that the tapestry/dojo wiring will 
interpret by parsing the window.location.href javascript.


-Steve

Kelly Merrell wrote:
I'm having a problem with my authentication redirect when using Ajax 
to update page components. I use PageRedirectException on each page 
to redirect to a login page if the user is not logged in when the 
page validates. This works as expected when hitting the page 
normally, but if I am using an AjaxDirectLink after the login has 
expired, the response is returned as the HTML of the login page and 
not "handled" by AjaxDirectService so that it is wrapped in the xml 
tags and have the "window.location.href" javascript redirect added. 
As the response is not xml, it breaks on the client side and the page 
does not redirect.


I have seen a few other people bring up this issue, but I can't find 
any evidence of a solution or work around. I would have thought that 
this would be a common problem, but maybe I am just overlooking a 
simple fix. Any help here would be greatly appreciated!


My pageValidate method is simply:

public void pageValidate(PageEvent event) {
   if (!isLoggedIn()) {
   Login loginPage = getRedirectPage();
   throw new PageRedirectException(loginPage);
   }
}





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T4] PageRedirectException in pageValidate after AjaxDirectLink

2008-03-26 Thread Steve Shucker
I already had a servlet filter doing some custom authentication and 
handling redirects to a separate login service for expired sessions, so 
I added a little extra code in there.  First off, you can identify ajax 
requests by the presence of an HttpServletRequest header called 
"dojo-ajax-request" with a value of "true".  If I see that header, I 
write my own custom response instead of going down the filter chain.  
Here's the method I use to build the response:


   private void sendAjaxRedirect(HttpServletResponse httpResponse) 
throws IOException {

   PrintWriter writer = httpResponse.getWriter();
   writer.write("");
   writer.write("Transitional//EN\" 
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"; [\nnbsp ' '>\n]>\n");

   writer.write("");
   writer.write("type=\"script\">\n//   writer.write("window.location.href = '" + 
params.getOriginalUrl() + "';\n");
   writer.write("//]]>\n");
   writer.write("");
   }

replace "params.getOriginalUrl()" with the entry URL for your app.

This code generates a response that the tapestry/dojo wiring will 
interpret by parsing the window.location.href javascript.


-Steve

Kelly Merrell wrote:
I'm having a problem with my authentication redirect when using Ajax 
to update page components. I use PageRedirectException on each page to 
redirect to a login page if the user is not logged in when the page 
validates. This works as expected when hitting the page normally, but 
if I am using an AjaxDirectLink after the login has expired, the 
response is returned as the HTML of the login page and not "handled" 
by AjaxDirectService so that it is wrapped in the xml tags and have 
the "window.location.href" javascript redirect added. As the response 
is not xml, it breaks on the client side and the page does not redirect.


I have seen a few other people bring up this issue, but I can't find 
any evidence of a solution or work around. I would have thought that 
this would be a common problem, but maybe I am just overlooking a 
simple fix. Any help here would be greatly appreciated!


My pageValidate method is simply:

public void pageValidate(PageEvent event) {
   if (!isLoggedIn()) {
   Login loginPage = getRedirectPage();
   throw new PageRedirectException(loginPage);
   }
}

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[T4] PageRedirectException in pageValidate after AjaxDirectLink

2008-03-26 Thread Kelly Merrell
I'm having a problem with my authentication redirect when using Ajax to 
update page components. I use PageRedirectException on each page to 
redirect to a login page if the user is not logged in when the page 
validates. This works as expected when hitting the page normally, but if 
I am using an AjaxDirectLink after the login has expired, the response 
is returned as the HTML of the login page and not "handled" by 
AjaxDirectService so that it is wrapped in the xml tags and have the 
"window.location.href" javascript redirect added. As the response is not 
xml, it breaks on the client side and the page does not redirect.


I have seen a few other people bring up this issue, but I can't find any 
evidence of a solution or work around. I would have thought that this 
would be a common problem, but maybe I am just overlooking a simple fix. 
Any help here would be greatly appreciated!


My pageValidate method is simply:

public void pageValidate(PageEvent event) {
   if (!isLoggedIn()) {
   Login loginPage = getRedirectPage();
   throw new PageRedirectException(loginPage);
   }
}

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



AW: [T4] PageRedirectException

2007-03-22 Thread Holger Stolzenberg
If you can try something like this to get a fresh instance of the desired page.

@InjectPage("NameOfMyPage")
public abstract MyPage getMyPage();

With the instance acquired by this method you can do something like this 
(pseudo code):

IPage page = getMyPage();

Use the page instance to get the validation delegate of it and register your 
error against it.

getRequestCylce.activate( page );


Mit lieben Grüßen aus dem eWerk

  |  Holger Stolzenberg
  |  Softwareentwickler
  |
  |  Geschäftsführer: 
  |  Frank Richter, Erik Wende, Hendrik Schubert
  |
  |  eWerk IT GmbH
  |  Markt 16
  |  Leipzig 04109
  |  http://www.ewerk.com
  |  HRB 9065, AG Leipzig
  |  Hauptniederlassung Leipzig
  |
  |  fon +49.341.4 26 49-0
  |  fax +49.341.4 26 49-88
  |  mailto:[EMAIL PROTECTED]
  |
  |  Support:
  |  fon 0700 CALLME24 (0700 22556324)
  |  fax 0700 CALLME24 (0700 22556324)
  |
  | Auskünfte und Angebote per Mail
  | sind freibleibend und unverbindlich. 

-Ursprüngliche Nachricht-
Von: Kolesnikov, Alexander GNI [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 22. März 2007 13:32
An: Tapestry users
Betreff: [T4] PageRedirectException

I am using contrib:Table to display the results of a search. If a search 
returns zero results, I want to treat this as an error and to show the search 
form again with this error in the same way as if it was a faulty user input 
validation.

It seems to me that a good solution to throw a PageRedirectException at the 
moment when the Table component receives a source with 0 records in it. I have 
tried to do this in the method that provides the model for the page, like so:

public IBasicTableModel getModel() {
// some code to prepare the model

if (model.getRowCount() == 0) {
throw new PageRedirectException("Search");
}   
return model;
}

But in this case the PageRedirectException was not caught by Tapestry but 
propagated.

Another attempt was to override the renderComponent() method of the Table 
component, like so:

protected void renderComponent(IMarkupWriter writer, IRequestCycle
cycle) {

if (getSource().getRowCount() == 0) {
throw new PageRedirectException("Search");
}
super.renderComponent(writer, cycle);
}

This seems to work when redirecting to a different page. However, I want to 
redirect to the same page because the search form and the table of results are 
simply two views of the same page, shown or hidden by If components as needed. 
And when I am trying to redirect to the same page, again, PageRedirectException 
is not caught but propagated, and the application crashes.

Does anybody know, why  PageRedirectException is sometimes caught but at other 
times propagated and what to do about this? Or maybe you can see a different 
solution for my problem?

Thanks,

Alex

--
CONFIDENTIALITY NOTICE: If you have received this email in error, please 
immediately notify the sender by e-mail at the address shown.  This email 
transmission may contain confidential information.  This information is 
intended only for the use of the individual(s) or entity to whom it is intended 
even if addressed incorrectly.  Please delete it from your files if you are not 
the intended recipient.  Thank you for your compliance.  Copyright 2007 CIGNA 
==

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[T4] PageRedirectException

2007-03-22 Thread Kolesnikov, Alexander GNI
I am using contrib:Table to display the results of a search. If a search
returns zero results, I want to treat this as an error and to show the
search form again with this error in the same way as if it was a faulty
user input validation.

It seems to me that a good solution to throw a PageRedirectException at
the moment when the Table component receives a source with 0 records in
it. I have tried to do this in the method that provides the model for
the page, like so:

public IBasicTableModel getModel() {
// some code to prepare the model

if (model.getRowCount() == 0) {
throw new PageRedirectException("Search");
}   
return model;
}

But in this case the PageRedirectException was not caught by Tapestry
but propagated.

Another attempt was to override the renderComponent() method of the
Table component, like so:

protected void renderComponent(IMarkupWriter writer, IRequestCycle
cycle) {

if (getSource().getRowCount() == 0) {
throw new PageRedirectException("Search");
}
super.renderComponent(writer, cycle); 
}

This seems to work when redirecting to a different page. However, I want
to redirect to the same page because the search form and the table of
results are simply two views of the same page, shown or hidden by If
components as needed. And when I am trying to redirect to the same page,
again, PageRedirectException is not caught but propagated, and the
application crashes.

Does anybody know, why  PageRedirectException is sometimes caught but at
other times propagated and what to do about this? Or maybe you can see a
different solution for my problem?

Thanks,

Alex

--
CONFIDENTIALITY NOTICE: If you have received this email in error, please 
immediately notify the sender by e-mail at the address shown.  This email 
transmission may contain confidential information.  This information is 
intended only for the use of the individual(s) or entity to whom it is intended 
even if addressed incorrectly.  Please delete it from your files if you are not 
the intended recipient.  Thank you for your compliance.  Copyright 2007 CIGNA
==