Hi,

Which is the better approach, or which is the main difference?

Have a service to do Login validation, like:
================
in AppModule.java
public static IUserAuthenticator buildUserAuthenticator()
{
  return new UserAuthenticatorImpl();
}

IUserAuthenticator.java
package org.example.hilo.services.interfaces;
public interface IUserAuthenticator
{
  public boolean isValid(String userName, String pwd);
}

UserAuthenticatorImpl.java
package org.example.hilo.services;
import org.example.hilo.services.interfaces.IUserAuthenticator;
public class UserAuthenticatorImpl implements IUserAuthenticator
{
  public boolean isValid(String userName, String pwd)
  {
     if (userName.equalsIgnoreCase(pwd))
     {   return true;   }
     return false;
  }
}

in Login.java
@Inject
private IUserAuthenticator _authenticator;
public String onSuccess()
{
  if (!_authenticator.isValid(_userName, _password))
  {
     _form.recordError(_passwordField, "Invalid user name or password.");
     return null;
  }
  return "Start";
}
================

or have a class to do that, like:
================
UserAuthenticator.java
package org.example.hilo.beans;
public class UserAuthenticator
{
  public boolean isValid(String userName, String pwd)
  {
     if (userName.equalsIgnoreCase(pwd))
     {   return true;   }
     return false;
  }
}

in Login.java
@Inject
private UserAuthenticator _authenticator;
String onSuccess()
{
  if (!_authenticator.isValid(_userName, _password))
  {
     _form.recordError(_passwordField, "Invalid user name or password.");
     return null;
  }
  return "Start";
}

Thank's
Marcus


Related Links:
http://tapestry.apache.org/tapestry5/tapestry-core/index.html
http://elozovan.blogspot.com/2007/05/simpletapestry-5-crud-application-step.html

Reply via email to