I'm kinda' learning, too, so people on the list may slap my wrist
here...
Using actions the way you have specified there, you would also need
to write org.test.actions.LoginUser.java, which will authenticate the
user. That authentication needs to take place in doPerform(RunData,
Context) . What you really SHOULD do, is set the name of your SUBMIT
button to eventSubmit_doLogin, then put the authentication stuff in
doLogin(RunData, Context), and doPerform(RunData, Context) should say
that no such action exists.
Also, it would probably be better if your FORM tag said something to
the effect of:
<FORM method="POST" action="$link.setPage("index.vm")"> instead of
specifying the complete path. Then, add the 'action' parameter as a
hidden element:
<INPUT type="hidden" name="action" value="LoginUser">
So, if my understanding of the action event model is correct, when
you hit the submit button (named eventSubmit_doLogin),
LoginUser.doLogin() is executed, which will authenticate the user,
then put the appropriate information in the Contecxt, or change the
template back to the Login screen. If it doesn't change the
template, then the Index class is executed, or if it doesn't exist,
whatever your default is, then the template is rendered.
Like I said, I'm new, so I haven't actually tried this with loggin
in, but I've done it with other stuff.
I got all this from http://java.apache.org/turbine/action-event.html
, which is the documentation on the action-event model - and some
help from Scarab.
Will Stranathan
--- Martin Poeschl <[EMAIL PROTECTED]> wrote:
> i can not believe that i am the only one using this functionality
> ...
> please help!!
>
>
>
>
> i solved some problems, but it still doesn't work ...
>
> here is what i did:
> i use tdk1.1a9
> * create a new application (newapp.bat test)
> * set module.packages=org.test,org.apache.turbine.modules
> * set
>
action.sessionvalidator=sessionvalidator.TemplateSecureSessionValidator
> * add template.login=login.vm
> * create login.vm (attached)
> * create org.test.Login.java (attached)
> * build test
>
> now i get my login-screen http://localhost:8080/test/servlet/test
> :o)
>
> but if i try to log in i get the following excption: :-(
>
> [Fri Nov 17 07:24:54 GMT+01:00 2000] -- ERROR -- An error
> occurred
> while rendering template layoutsnull:
> null
> [Fri Nov 17 07:24:54 GMT+01:00 2000] -- ERROR --
> Exception: java.lang.NullPointerException
> Stack Trace follows:
> java.lang.NullPointerException
> at org.apache.velocity.Template.merge(Template.java:276)
> at
>
org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:236)
>
> at
>
org.apache.turbine.services.velocity.TurbineVelocityService.handleRequest(TurbineVelocityService.java:201)
>
> at
>
org.apache.turbine.services.velocity.TurbineVelocity.handleRequest(TurbineVelocity.java:106)
>
> at
>
org.apache.turbine.modules.layouts.VelocityECSLayout.doBuild(VelocityECSLayout.java:129)
>
> at org.apache.turbine.modules.Layout.build(Layout.java:93)
> at
> org.apache.turbine.modules.LayoutLoader.exec(LayoutLoader.java:122)
> at
>
org.apache.turbine.modules.pages.DefaultPage.doBuild(DefaultPage.java:170)
>
> at org.apache.turbine.modules.Page.build(Page.java:92)
> at org.apache.turbine.modules.PageLoader.exec(PageLoader.java:122)
> at org.apache.turbine.Turbine.doGet(Turbine.java:372)
> at org.apache.turbine.Turbine.doPost(Turbine.java:459)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> at
>
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
>
> at org.apache.tomcat.core.Handler.service(Handler.java:286)
> at
>
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> at
>
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:799)
>
> at
>
org.apache.tomcat.core.ContextManager.service(ContextManager.java:745)
> at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
>
> at
>
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:407)
>
> at
>
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
>
> at java.lang.Thread.run(Thread.java:484)
>
>
> please help to solve this problem ... then i will write some nice
> documentation for tdk
>
> login.vm:
>
> $page.setTitle("This is the index title")
> $page.setBgColor("#ffffff")
> <font face="verdana,geneva,helvetica">
> <h3>$message</h3>
>
> <form method="POST" name="turbine"
>
action="http://localhost:8080/test/servlet/test/template/index.vm/action/LoginUser"
> >
> <p>Username
> <input type="text" name="textfield2">
> </p>
> <p>Passwort
> <input type="password" name="textfield">
> </p>
> <p>
> <input type="submit" name="Submit" value="Submit">
> </p>
> </form>
> $today
> </font>
>
>
> Login.java:
>
> package org.test.screens;
>
> // JDK Imports
> import java.io.*;
> import java.util.*;
>
> import org.apache.turbine.modules.*;
> import org.apache.turbine.util.*;
> import org.apache.turbine.services.*;
> import org.apache.turbine.modules.screens.*;
> // Velocity Stuff
> import org.apache.velocity.Context;
>
> /**
> * Sample LoginScreen for using Velocity.
> *
> * @author Dave Bryson<a
>
href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a>
>
> */
> public class Login extends VelocityScreen
> {
> /**
> * This is an example of all you need to do to add custom
> screens
> * into the WebMacro site. Just extend the WebMacroSiteScreen
> and
> * override this method. Note: context is a protected variable
> in
> the
> * base class. It is very important that you add any
> information to
> the
> * WebContext using "context". Otherwise it will not show up in
> your
>
> * template.
> */
> public void doBuildTemplate( RunData data, Context context )
> {
> // Could add Security checks here if desired and
> // perform any needed logic. Then add to the context and
> // let the WebMacroSiteScreen handle the rest.
> //context = getContext(data);
> context.put("today", new Date().toString());
> context.put("message", data.getMessage());
> }
> }
>
>
>
>
>
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Search:
> <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?: [EMAIL PROTECTED]
>
>
> ------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
> Search:
> <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?: [EMAIL PROTECTED]
>
__________________________________________________
Do You Yahoo!?
Yahoo! Calendar - Get organized for the holidays!
http://calendar.yahoo.com/
------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?: [EMAIL PROTECTED]