I found two others links that can help to my question

http://www.gorerle.com/vlab-wiki/index.php?title=JSF
http://www.jsftutorials.net/jsfNavigation/jsf-login-navigation-redirect.html

But I donĀ“t think that they were clear, even the second link have a note
that says:

*Note: This is only an example that shows how you can use navigation handler
decorator. Do NOT use it as a ready-to-use solution for login facility. Use
Phase Listener instead.*

I will search for a Phase Listener example, but still is not clear which is
the better solution and how to implemented it.

Thanks!

On Dec 5, 2007 11:10 AM, daniel ccss <[EMAIL PROTECTED]> wrote:

> Thanks Both of you, i was out for a while.
>
> Ok I think this is a common question, and not a simple question as I wrote
> in my subject, something similar was talked in this thread:
>
> http://forum.java.sun.com/thread.jspa?threadID=690288&messageID=4017603
>
> I think the NavigationHandler is the easier and nice solution, but I have
> some questions about it beacause I implemented it but nothing happens:
>
>
> init()
> {
>     if(userInSession){
>        do the load of the controls
>     }else{
>         FacesContext.getCurrentInstance
> ().getApplication().getNavigationHandler().
>                handleNavigation(FacesContext.getCurrentInstance(),null,"*
> showLoggin*");
>
>     }
> }
>
>
> 1- Is necesary to use shale-view?
> 2- The third argument is a navigation rule that is in the faces-config.xml
> ??
> 3- Can anyone give a sample code of how to do this? I think its not clear
> how to handdle this, and many people will use it if is clear :).
>
>
> Thanks
>
>
> On Nov 23, 2007 11:40 PM, Gerhard Petracek < [EMAIL PROTECTED]>
> wrote:
>
> > one more supplement to complete the picture of the last two mails - i
> > missed to add these details at my last mail *sorry* for that...
> >
> > in my previous mail i wrote that the NavigationHandler approach doesn't
> > solve your problem, because the init-method gets invoked before. i missed to
> > add some details to complete this comment because of quick answering.
> > normally it works very well if you navigate to the login page before you use
> > the bean - which is the case if you use the whole bean only within your
> > target page(s) (where a successful login is required) (-> the init-method
> > isn't invoked if you navigate to the login page) -> it's a valid approach as
> > i mentioned it in my first mail.
> >
> > (i thought about possible scenarios where you have a combination of: a
> > login isn't required for all pages - as it seems to be the case within our
> > application - and if you use the bean before the NavigationHandler gets
> > invoked - and the user hasn't logged in -> in such a special case the
> > init-method recognizes that the user isn't logged in but the navigation to
> > the login page occurs later. i don't know your implementation details and if
> > such a scenario would lead to a side effect within your implementation or
> > not - so i skip details here.)
> >
> > summarized: also the NavigationHandler approach works for common cases (
> > e.g. there is no problem if you navigate to the login page before you
> > have the chance to use the bean) - in that case it also fits into my summary
> > of the first mail.
> >
> >
> > regards,
> > gerhard
> >
> >
> >
> > 2007/11/24, Gerhard Petracek < [EMAIL PROTECTED]>:
> > >
> > > hello daniel,
> > >
> > > some additional information:
> > > just to avoid misunderstandings - the summary of the suggestion has no
> > > reference to the NavigationHandler approach because in that case your
> > > init-method would get executed before.
> > >
> > > generally spoken: to implement a custom NavigationHandler is just an
> > > alternative approach (in your case it doesn't solve your problem).
> > > if someone is interested in this approach you will find an example at:
> > > http://www.jsftutorials.net/jsfNavigation/jsf-login-navigation-redirect.html
> > >
> > > (i didn't look at the details of this specific solution - it's just an
> > > example... - and they also suggest to use a PhaseListener)
> > >
> > > regards,
> > > gerhard
> > >
> > >
> > >
> > > 2007/11/24, Gerhard Petracek < [EMAIL PROTECTED]>:
> > > >
> > > > hello daniel,
> > > >
> > > > i would like to suggest other solutions.
> > > >
> > > > i think you are familiar with the common ways of handling navigation
> > > > (summarized - e.g. if you use the "from-outcome" approach an
> > > > action-method returns the outcome or you use a static string within your
> > > > page - with this approach only these outcomes are used for navigation)
> > > > -> if your "init"-method is not an action method (it doesn't sound
> > > > like one) - you should consider alternative solutions.
> > > >
> > > > --- just a general information before we start ---
> > > > with this additional information i don't refer to the solution you
> > > > are having in mind!
> > > > basically you can manually navigate e.g. with:
> > > >         
> > > > FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(
> > > > ... );
> > > > or with:
> > > >             
> > > > FacesContext.getCurrentInstance().getExternalContext().redirect(
> > > > ... );
> > > >
> > > > however, be careful with these mechanisms - they don't work at any
> > > > point of your application and you risk to "break" your application if 
> > > > you
> > > > misuse these mechanisms.
> > > > ---
> > > >
> > > > if you don't like to use security extensions such as Acegi you have
> > > > to implement custom mechanisms to provide login pages and to avoid 
> > > > initial
> > > > actions within your bean. in that case i would suggest more generic
> > > > solutions - e.g. a custom PhaseListener or a custom
> > > > NavigationHandler.
> > > >
> > > > to summarize my suggestion: use/implement a mechanism which takes
> > > > place before your init-method gets executed.
> > > >
> > > > regards,
> > > > gerhard
> > > >
> > > >
> > > >
> > > > 2007/11/23, daniel ccss <[EMAIL PROTECTED]>:
> > > > >
> > > > > I have a simple question
> > > > >
> > > > > I have been working with myfaces-tomahawk for 6 months, great, but
> > > > > I
> > > > > have a question, how to call an 'action' from the backing bean,
> > > > > until
> > > > > today I have called all my action methods from the JSP page, on
> > > > > the
> > > > > onClick, onChange, etc events, but now I need to call an action
> > > > > from
> > > > > another method in my backing bean.
> > > > >
> > > > > I have an init method in my backing bean that ask if the user is
> > > > > in
> > > > > session, if yes all the load of the combos etc is make, if not I
> > > > > need
> > > > > to call a method that returns to the login page by returning the
> > > > > navigation rule like this:
> > > > >
> > > > > //init
> > > > > {
> > > > >      if(userInSession){
> > > > >         do the load of the controls
> > > > >      }else{
> > > > >         returnToLogin();
> > > > >      }
> > > > > }
> > > > >
> > > > > private String returnToLogin(){
> > > > >       return "login";
> > > > > }
> > > > >
> > > > > and in faces-config.xml i have the navigation rule:
> > > > >
> > > > > <navigation-rule>
> > > > >   <from-view-id>....
> > > > >
> > > > >   <navigation-case>
> > > > >    <from-outcome>login</from-outcome>
> > > > >    <to-view-id>/JSP/Login.jsp</to-view-id>
> > > > >   </navigation-case>
> > > > > ....
> > > > >
> > > > > But nothing happens, this type of call can be done?, or only I can
> > > > >
> > > > > call an action that returns to a navigation rule from the JSP, if
> > > > > so,
> > > > > how can I send the person to the login page in case he copy the
> > > > > url in
> > > > > the browser and never pass for the login page.
> > > > >
> > > > > Thanks all
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > http://www.irian.at
> > > >
> > > > Your JSF powerhouse -
> > > > JSF Consulting, Development and
> > > > Courses in English and German
> > > >
> > > > Professional Support for Apache MyFaces
> > >
> > >
> > >
> > >
> > > --
> > >
> > > http://www.irian.at
> > >
> > > Your JSF powerhouse -
> > > JSF Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache MyFaces
> > >
> >
> >
> >
> > --
> >
> > http://www.irian.at
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
>
>

Reply via email to