You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Tibo23 <th...@gmail.com> on 2010/11/25 00:38:08 UTC

Reusable login component

Hello,

I have a login component and I want to reuse it into several pages.
Everything is ok until my issue : how to redirect to a specific page
depending on the parent page which contains the component.

-------------------------

Page1 :
<html>
...
<t:login />
...
</html>

if login is successful, redirect to Page11 else redirect to Page 1

-------------------------

Page2 :
<html>
...
<t:login />
...
</html>

if login is successful, redirect to Page21 else redirect to Page 2

-------------------------

For the moment the redirection is done on the login component but the aim
should be to do it into the page containing the login component.
May I use parameter? May I use events?

Thanks by advance for your help.
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Reusable-login-component-tp3279297p3279297.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

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


Re: Reusable login component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 25 Nov 2010 10:08:19 -0200, Katia Aresti <ka...@gmail.com>  
wrote:

> There are always several ways to do the same thing.

Agreed. :)

> @Thiago
>
> Doing with events like this, does not come up to the same thing ? In the  
> end I have to catch the event on my page to decide where to go. So, why  
> not
> telling the component from the beginning where to go ?
> I mean, why complicating life defining new events handling, triggering  
> and catching for this use case ? Isn't it more simple and more readable  
> to tell the login form where to go from the beginning ?

I guess you're right.  When I read your message, I've read "parameter" as  
"query parameter", not as "component parameter". (facepalm)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Reusable login component

Posted by Katia Aresti <ka...@gmail.com>.
2010/11/25 Thiago H. de Paula Figueiredo <th...@gmail.com>

> On Wed, 24 Nov 2010 21:51:18 -0200, Katia Aresti <ka...@gmail.com>
> wrote:
>
>  You are using the wrong list, you should post this questions into the
>> "Tapestry users" <us...@tapestry.apache.org>
>>
>
> Absolutely correct.
>
>
>  My answer : I would use input parameters (emulating the pagelink component
>> that gets the page as an input parameter). You could easily pass two params.
>>
>
> Or trigger and event and use the value returned by the method that handle
> to event as a way to decide which page to show next.
>

There are always several ways to do the same thing.

@Thiago

Doing with events like this, does not come up to the same thing ? In the end
I have to catch the event on my page to decide where to go. So, why not
telling the component from the beginning where to go ?
I mean, why complicating life defining new events handling, triggering and
catching for this use case ? Isn't it more simple and more readable to tell
the login form where to go from the beginning ?


>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>

Re: Reusable login component

Posted by Christophe Cordenier <ch...@gmail.com>.
Hi !

Use events and callbacks, see ComponentResources.triggerEvent

2010/11/25 Tibo23 <th...@gmail.com>

>
> How to tell the component from the beginning where to go? Because it
> depends
> on the parent page where the login component is included AND on a
> authentication fonction success?
>
> Here is my Login component :
>
> public class Login {
>
>        @Inject
>        private IAuthenticationService authenticationService;
>
>        @Property
>        private String login;
>
>        @Property
>        private String password;
>
>        public Object onSuccess () {
>                if (authenticationService.login (login, password) != null) {
>                        return (Main.class);
>                }
>                return (Index.class);
>        }
>
> }
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Reusable-login-component-tp3279297p3280031.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Regards,
Christophe Cordenier.

Committer on Apache Tapestry 5
Co-creator of wooki @wookicentral.com

Re: Reusable login component

Posted by Katia Aresti <ka...@gmail.com>.
Without doing it with callbacks and events, more simple for your use case :

you can define 2 input parameters like this in you component :

@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String successPage;

@Parameter(defaultPrefix = BindingConstants.LITERAL)
private String errorPage;

you change like this :

   public Object onSuccess () {
               if (authenticationService.login (login, password) != null) {
                       return successPage;
               }
               return errorPage;
       }

And finally when you use you component, you can pass the values as
parameters on the same way as you do it with other components.

Katia

2010/11/25 Tibo23 <th...@gmail.com>

>
> How to tell the component from the beginning where to go? Because it
> depends
> on the parent page where the login component is included AND on a
> authentication fonction success?
>
> Here is my Login component :
>
> public class Login {
>
>        @Inject
>        private IAuthenticationService authenticationService;
>
>        @Property
>        private String login;
>
>        @Property
>        private String password;
>
>        public Object onSuccess () {
>                if (authenticationService.login (login, password) != null) {
>                        return (Main.class);
>                }
>                return (Index.class);
>        }
>
> }
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Reusable-login-component-tp3279297p3280031.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Reusable login component

Posted by Tibo23 <th...@gmail.com>.
How to tell the component from the beginning where to go? Because it depends
on the parent page where the login component is included AND on a
authentication fonction success?

Here is my Login component :

public class Login {

	@Inject
	private IAuthenticationService authenticationService;

	@Property
	private String login;

	@Property
	private String password;

	public Object onSuccess () {
		if (authenticationService.login (login, password) != null) {
			return (Main.class);
		}
		return (Index.class);
	}

}
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Reusable-login-component-tp3279297p3280031.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: Reusable login component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Hi, Katia!

On Thu, 25 Nov 2010 06:13:48 -0200, Katia Aresti <ka...@gmail.com>
wrote:

> There are always several ways to do the same thing.

> @Thiago Doing with events like this, does not come up to the same to same
> thing ? In the end I have to catch the event on my page to decide where  
> to go. So, why not telling the component from the beginning where to go ?
> I mean, why complicating life defining new events handling, triggering  
> and catching for this use case ? Isn't it simpler and more readable to  
> tell the login form where to go from the beginning ?

I guess you're right. :) When I read your message, I've read "parameter"
as "query parameter", not as "component parameter". (facepalm)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Reusable login component

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 24 Nov 2010 21:51:18 -0200, Katia Aresti <ka...@gmail.com>  
wrote:

> You are using the wrong list, you should post this questions into the
> "Tapestry users" <us...@tapestry.apache.org>

Absolutely correct.

> My answer : I would use input parameters (emulating the pagelink  
> component that gets the page as an input parameter). You could easily  
> pass two params.

Or trigger and event and use the value returned by the method that handle  
to event as a way to decide which page to show next.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: Reusable login component

Posted by Katia Aresti <ka...@gmail.com>.
You are using the wrong list, you should post this questions into the
"Tapestry users" <us...@tapestry.apache.org>
My answer : I would use input parameters (emulating the pagelink component
that gets the page as an input parameter). You could easily pass two params.



Katia

2010/11/25 Tibo23 <th...@gmail.com>

>
> Hello,
>
> I have a login component and I want to reuse it into several pages.
> Everything is ok until my issue : how to redirect to a specific page
> depending on the parent page which contains the component.
>
> -------------------------
>
> Page1 :
> <html>
> ...
> <t:login />
> ...
> </html>
>
> if login is successful, redirect to Page11 else redirect to Page 1
>
> -------------------------
>
> Page2 :
> <html>
> ...
> <t:login />
> ...
> </html>
>
> if login is successful, redirect to Page21 else redirect to Page 2
>
> -------------------------
>
> For the moment the redirection is done on the login component but the aim
> should be to do it into the page containing the login component.
> May I use parameter? May I use events?
>
> Thanks by advance for your help.
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Reusable-login-component-tp3279297p3279297.html
> Sent from the Tapestry - Dev mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: dev-help@tapestry.apache.org
>
>