wiki's ControlAccess sample NPE

2008-10-08 Thread lyifan

Hi all,

I've been trying to run the ControlAccess sample on the Tapestry5Howtos site
during these 2 days. But I haven't got any luck

When Component page = componentSource.getPage(pageName) is called, a NPE is
thrown. I'm using Tapestry5.0.15 and tomcat 6.0.18 on windowsXp sp3

Any comment is welcome.

Thanks

Yifan

-- 
View this message in context: 
http://n2.nabble.com/wiki%27s-ControlAccess-sample-NPE-tp1307854p1307854.html
Sent from the Tapestry Users mailing list archive at Nabble.com.


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



T5.0.6 about Tapestry ioc

2007-11-16 Thread lyifan

I want to implement a service:

public interface Transport {
public void send();
}

public class HttpTransport implement Transport {
private String _address;
private int _port;
private boolean _ssl;
public HttpTransport (String address, int port, boolean ssl) {
 _address = address;
 _port = port;
 _ssl = ssl;
}

public void send) {
// ..
}
}

The parameter of the constructor is from http request. How can I build this
service? I know I can use setters, but I just wanna know how to build a
service using constructor.
-- 
View this message in context: 
http://www.nabble.com/T5.0.6-about-Tapestry-ioc-tf4820490.html#a13791068
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5.0.6 about Tapestry ioc

2007-11-16 Thread lyifan

Hi Chris,

Do you mean that any constructor parameters can be replaced by an object
that provides those parameters?
for an instance, if address, port, ssl are saved in a config file, I have to
pass a ConfigFile object as the parameter of the HttpTransport constructor.
Am I right?

thank you


Chris Lewis-5 wrote:
 
 I'm not sure I understand the constructor parameters. Do you mean they 
 come from some other object (HttpRequest)? If so, why not just take 
 HttpRequest as a constructor argument? If you do that then you can auto 
 bind this service and IoC will know how to create it. If you insist on 
 the parameters currently listed, then you'll need to have a service 
 builder method, and inject HttpRequest as an argument into that method.
 
 lyifan wrote:
 I want to implement a service:

 public interface Transport {
 public void send();
 }

 public class HttpTransport implement Transport {
 private String _address;
 private int _port;
 private boolean _ssl;
 public HttpTransport (String address, int port, boolean ssl) {
  _address = address;
  _port = port;
  _ssl = ssl;
 }

 public void send) {
 // ..
 }
 }

 The parameter of the constructor is from http request. How can I build
 this
 service? I know I can use setters, but I just wanna know how to build a
 service using constructor.
   
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/T5.0.6-about-Tapestry-ioc-tf4820490.html#a13792550
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 how to control login state

2007-11-04 Thread lyifan

Thanks a lot everyone. Finally the BasePase way works

But the dispatcher way still doesn't work.



lyifan wrote:
 
 I am a 100% new user for tapestry. Currently I'm working on 5.0.5, but I
 got stuck from the just beginning.
 
 I want to implement a kind of user access controller. All the pages,
 excepts for the login page, can be accessed by authenticated users only.
 users who hasn't passed the authentication will be redirected to the login
 page to input their user name and password, and then, if the user name and
 password are correct, they will see the page they want
 
 I think this is a very very simple thing to do.But after a few days
 working, I am very frustrated.
 
 Firstly, I've tried the onActivate method. My code looks like below:
 
 class BasePage {
 @ApplicationState
  private UserIdentity _userIdentity;
  private boolean _userIdentityExists;
 
 Object onActivate() {
   
  if( !_userIdentityExists)
  return Login; //Login is my login page
 
  return null;
 }
 }
 
 And the I visited http://localhost:8080/myapp(default page is start), I
 got a blank empty page. There is nothing at all on the browser. But I can
 see the login page when I went to http://localhost:8080/myapp/login
 
 After that I found an article at
 http://wiki.apache.org/tapestry/Tapestry5HowToCreateADispatcher. According
 to this, I created my dispatcher. But I found ASO doesn't work in my
 dispatcher class.
 boolean _myIdentityExists always be false.
 
 And if I contribute it use before:PageRender, the dispatch method would
 not be invoked then I visit the default start page. I had to use
 before:RootPath. Following it my dispatcher class code:
 
 public class SessionController implements Dispatcher {
 
   @ApplicationState
   private MyIdentity _myIdentity;
   private boolean _myIdentityExists;
   
   public SessionController() {
   System.out.println(SessionController: SessionController 
 created.);
   }
 
   public boolean dispatch(Request request, Response response) throws
 IOException {
   System.out.println(Requesting  + request.getPath());
 
   if (! _myIdentityExists ) { // _myIdentityExists always be false
   if( _myIdentity == null ) { // here MyIdentity won't be 
 created
   _myIdentity = new MyIdentity(); // I have to 
 create it by myself.
   System.out.println(SessionController: Identity 
 does not exist.);
 response.sendRedirect(login); 
return true; // this works, I can see the
 login page correctly.
   }else
   System.out.println(SessionController: Identity 
 exists.);
   }
   
   return false;
   }
 }
 
 and here is the code in AppModule:
 public void
 contributeMasterDispatcher(OrderedConfigurationDispatcher configuration,
 @InjectService(SessionController) Dispatcher
 sessionController) {
 configuration.add(SessionController, sessionController,
 before:PageRender);
   }
 
 
 before:PageRender and before:Asset do not call dispatch method,
 before:RootPath does
 
 I set the session timeout to 1 min in the web.xml. 
   session-config
   session-timeout1/session-timeout
   /session-config
 
 After 1 min, I came to the start page.supposedly, I would be redirected to
 the login page because session is timeout. But I could still visit the
 start page, which meas _myIdentity is still in the Session after the
 timeout. Is it a bug or I shouldn't create it by myself?
 

-- 
View this message in context: 
http://www.nabble.com/T5-how-to-control-login-state-tf4744201.html#a13576094
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 how to control login state

2007-11-03 Thread lyifan

Thank you Marcus. 
But I can't understand where to add getters and setters. Do you mean put
getters and setters to ASO class or to a certain class where declares an
ASO?

Marcus-11 wrote:
 
 Add getters and setters ASO.
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/T5-how-to-control-login-state-tf4744201.html#a13566970
Sent from the Tapestry - User mailing list archive at Nabble.com.


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



Re: T5 how to control login state

2007-11-03 Thread lyifan

It still doesn't work, Marcus
I've changed the onActivate method to public


Marcus-11 wrote:
 
 Add getters and setters ASO.
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/T5-how-to-control-login-state-tf4744201.html#a13567511
Sent from the Tapestry - User mailing list archive at Nabble.com.


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