You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jason Vincent <jt...@gmail.com> on 2006/01/23 22:22:09 UTC

Shale: not calling prerender or preprocess, and Navigation issue

Hey there,

I've got some unexpected navigation stuff going on, that I was hoping
someone can help explain.

Here is my use-case:
1) Home page is requested.
2) user isn't logged in, so redirect to login url.
3) after login, navigate to home.

In my logs, I'm seeing this behavior, which is wierd... This is just
the initial request to the home page, I didn't hit the login button,
just yet.

HomeVC.init(), requestURI=/cpt/home.jsf
HomeVC.prerender(), requestURI=/cpt/home.jsf
BaseViewController - /cpt/home.jsf is a secure url and not logged in,
redirecting to login: /login/login.jsf
HomeVC.destroy(), requestURI=/cpt/home.jsf
HomeVC.init(), requestURI=/cpt/home.jsf
HomeVC.prerender(), requestURI=/cpt/home.jsf
BaseViewController - /cpt/home.jsf is a secure url and not logged in,
redirecting to login: /login/login.jsf
HomeVC.destroy(), requestURI=/cpt/home.jsf

The init,prerender,destroy are not called for LoginVC - Why not?

The wierd part is that the browser behavior is working as expected -
up to a point.
Once I hit the login button, the user is logged in, but the navigation
rule in faces-config, isn't sending the browser to the home url.

Another interesting thing... after the login form is displayed, and I
Manually enter the login URL - the init,prerender, and destroy methods
are not called by ANY ViewController.

PS... I do have no-cache meta tags in the jsps, and I also set the
headers in my baseViewControler.prerender method - so at least the
browser shouldn't be caching anything.

Can anyone explain what is going on?

Any help is appreciated.
Thanks,
Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Shale: not calling prerender or preprocess, and Navigation issue

Posted by Craig McClanahan <cr...@gmail.com>.
On 1/23/06, Jason Vincent <jt...@gmail.com> wrote:
> Thanks for the response...
>
> The url in the browser is changing to /login/login.jsf... I call the
> redirect, from the the BaseViewController.prerender method...
> externalContext.redirect(toUrl); where in my case the toUrl is
> "/cpt/login/login.jsf".

OK, that implies that the redirect did indeed work.  (It's also
possible to do this sort of "is the user logged on" checking with a
PhaseListener, so you don't have to embed it in every view controller,
but let's not complicate the diagnosis by changing that just yet :-).

>  /cpt is my application context.
>
>         ExternalContext externalContext = getExternalContext();
>         String webappPath = externalContext.getRequestContextPath();
>         String toUrl = webappPath+url;
>         externalContext.redirect(toUrl);
>
> I was under the impression that navigation rules don't come into play
> until some commandLink or commandBotton is clicked.  Is that not true?
>

Yes, that is true ... More precisely, JSF navigation doesn't happen
until after a submit fires off one of your action methods, and it
returns a logical outcome string.  In the case at hand, we would be
waiting for the button handling the submit of the logon form to say
what outcome happened.

> But, I think my navigation rules are indeed wrong. Which may explain
> why the login button isn't going anywhere.  Here are my current
> navigation rules...
>
>     <navigation-rule>
>         <from-view-id>*</from-view-id>
>         <navigation-case>
>             <from-outcome>home</from-outcome>
>             <to-view-id>/home.jsf</to-view-id>
>             <redirect/>
>         </navigation-case>
>     </navigation-rule>
>
>
>     <navigation-rule>
>         <from-view-id>/login/login.jsf</from-view-id>
>         <navigation-case>
>             <from-outcome>success</from-outcome>
>             <to-view-id>/home.jsf</to-view-id>
>         </navigation-case>
>         <navigation-case>
>             <from-outcome>failed</from-outcome>
>             <to-view-id>/login/logon.jsf</to-view-id>
>             <redirect/>
>         </navigation-case>
>     </navigation-rule>
>
> Thanks so much.

There *is* a set of errors in your navigation rules ... view
identifiers should be using the JSP extension, not the JSF_mapped one.
 For example:

  <from-view-id>/login/login.jsp</from-view-id>

since that is the "real" page that did the rendering.  Same thing goes
for <to-view-id> settings.


> Jason

Craig

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Shale: not calling prerender or preprocess, and Navigation issue

Posted by Jason Vincent <jt...@gmail.com>.
Thanks for the response...

The url in the browser is changing to /login/login.jsf... I call the
redirect, from the the BaseViewController.prerender method...        
externalContext.redirect(toUrl); where in my case the toUrl is
"/cpt/login/login.jsf".  /cpt is my application context.

        ExternalContext externalContext = getExternalContext();
        String webappPath = externalContext.getRequestContextPath();
        String toUrl = webappPath+url;
        externalContext.redirect(toUrl);

I was under the impression that navigation rules don't come into play
until some commandLink or commandBotton is clicked.  Is that not true?

But, I think my navigation rules are indeed wrong. Which may explain
why the login button isn't going anywhere.  Here are my current
navigation rules...

    <navigation-rule>
        <from-view-id>*</from-view-id>
        <navigation-case>
            <from-outcome>home</from-outcome>
            <to-view-id>/home.jsf</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>


    <navigation-rule>
        <from-view-id>/login/login.jsf</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/home.jsf</to-view-id>
        </navigation-case>
        <navigation-case>
            <from-outcome>failed</from-outcome>
            <to-view-id>/login/logon.jsf</to-view-id>
            <redirect/>
        </navigation-case>
    </navigation-rule>

Thanks so much.
Jason










On 1/23/06, Craig McClanahan <cr...@gmail.com> wrote:
> Inline ...
>
> On 1/23/06, Jason Vincent <jt...@gmail.com> wrote:
> > Hey there,
> >
> > I've got some unexpected navigation stuff going on, that I was hoping
> > someone can help explain.
> >
> > Here is my use-case:
> > 1) Home page is requested.
> > 2) user isn't logged in, so redirect to login url.
> > 3) after login, navigate to home.
> >
> > In my logs, I'm seeing this behavior, which is wierd... This is just
> > the initial request to the home page, I didn't hit the login button,
> > just yet.
> >
> > HomeVC.init(), requestURI=/cpt/home.jsf
> > HomeVC.prerender(), requestURI=/cpt/home.jsf
> > BaseViewController - /cpt/home.jsf is a secure url and not logged in,
> > redirecting to login: /login/login.jsf
> > HomeVC.destroy(), requestURI=/cpt/home.jsf
> > HomeVC.init(), requestURI=/cpt/home.jsf
> > HomeVC.prerender(), requestURI=/cpt/home.jsf
> > BaseViewController - /cpt/home.jsf is a secure url and not logged in,
> > redirecting to login: /login/login.jsf
> > HomeVC.destroy(), requestURI=/cpt/home.jsf
> >
> > The init,prerender,destroy are not called for LoginVC - Why not?
> >
>
> This is definitely wierd, all right.  It looks like the redirect from
> "/cpt/home.jsf" to "/login/login.jsf" did not actually happen ...
> instead it seems to have redisplayed the home page again.  How are you
> actually doing the redirect?
>
> One other quick thing to check ... in your server's log messages, do
> you see any warning messages that look like this?
>
>     WARNING:  No ViewController for viewId /foo/bar.jsf found under name baz
>
> If you do, its a sign that your view controller managed beans are not
> named as Shale is expecting them ("cpt$home" and "login$login" for the
> paths you are listing above).
>
> Craig
>
>
> > The wierd part is that the browser behavior is working as expected -
> > up to a point.
> > Once I hit the login button, the user is logged in, but the navigation
> > rule in faces-config, isn't sending the browser to the home url.
> >
> > Another interesting thing... after the login form is displayed, and I
> > Manually enter the login URL - the init,prerender, and destroy methods
> > are not called by ANY ViewController.
> >
> > PS... I do have no-cache meta tags in the jsps, and I also set the
> > headers in my baseViewControler.prerender method - so at least the
> > browser shouldn't be caching anything.
> >
> > Can anyone explain what is going on?
> >
> > Any help is appreciated.
> > Thanks,
> > Jason
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Shale: not calling prerender or preprocess, and Navigation issue

Posted by Craig McClanahan <cr...@gmail.com>.
Inline ...

On 1/23/06, Jason Vincent <jt...@gmail.com> wrote:
> Hey there,
>
> I've got some unexpected navigation stuff going on, that I was hoping
> someone can help explain.
>
> Here is my use-case:
> 1) Home page is requested.
> 2) user isn't logged in, so redirect to login url.
> 3) after login, navigate to home.
>
> In my logs, I'm seeing this behavior, which is wierd... This is just
> the initial request to the home page, I didn't hit the login button,
> just yet.
>
> HomeVC.init(), requestURI=/cpt/home.jsf
> HomeVC.prerender(), requestURI=/cpt/home.jsf
> BaseViewController - /cpt/home.jsf is a secure url and not logged in,
> redirecting to login: /login/login.jsf
> HomeVC.destroy(), requestURI=/cpt/home.jsf
> HomeVC.init(), requestURI=/cpt/home.jsf
> HomeVC.prerender(), requestURI=/cpt/home.jsf
> BaseViewController - /cpt/home.jsf is a secure url and not logged in,
> redirecting to login: /login/login.jsf
> HomeVC.destroy(), requestURI=/cpt/home.jsf
>
> The init,prerender,destroy are not called for LoginVC - Why not?
>

This is definitely wierd, all right.  It looks like the redirect from
"/cpt/home.jsf" to "/login/login.jsf" did not actually happen ...
instead it seems to have redisplayed the home page again.  How are you
actually doing the redirect?

One other quick thing to check ... in your server's log messages, do
you see any warning messages that look like this?

    WARNING:  No ViewController for viewId /foo/bar.jsf found under name baz

If you do, its a sign that your view controller managed beans are not
named as Shale is expecting them ("cpt$home" and "login$login" for the
paths you are listing above).

Craig


> The wierd part is that the browser behavior is working as expected -
> up to a point.
> Once I hit the login button, the user is logged in, but the navigation
> rule in faces-config, isn't sending the browser to the home url.
>
> Another interesting thing... after the login form is displayed, and I
> Manually enter the login URL - the init,prerender, and destroy methods
> are not called by ANY ViewController.
>
> PS... I do have no-cache meta tags in the jsps, and I also set the
> headers in my baseViewControler.prerender method - so at least the
> browser shouldn't be caching anything.
>
> Can anyone explain what is going on?
>
> Any help is appreciated.
> Thanks,
> Jason
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org