You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Mark Nutter <ja...@linklore.org> on 2002/04/12 21:06:36 UTC

Velocity context for Login.vm

I'm still fairly new to Turbine and am trying to do some customization
of the sample app I built when I did the TDK 2.1 HowTo.  Just as a
trivial trial run, I want to add a timestamp to the page you see when
you first go to the site.  It's a rendering of Login.vm, so I assumed I
could just create a Login.java--I accomplished the same thing by editing
Index.vm and Index.java.  But it seems Login.vm is a special case.  My
Login class is never called.  I even tested it by deliberately putting a
divide-by-zero bug in doBuildTemplate(), but Login.vm comes up without a
whimper.  I just copied Index.java to Login.java and changed the
classname, and saved it in the same directory, so I'm confident I'm not
putting it in the wrong place.

I've read the docs both in the /site directory and on the Jakarta web
site, and nothing jumps out at me.  I've tried to trace the program flow
by reading Turbine.java and trying to trace through the various imports
and method calls, but I'm just confusing myself.

Anybody got a quick and easy pointer for me?  If there's a doc or source
file somewhere, I'm not afraid to read it, I just don't know where to
look.  Of course, more complete answers are welcome as well, even if
it's "You can't do that."

Am I barking up a wrong tree?  My ultimate goal is to have a public
front page with a certain amount of dynamic content that you can see
without having to log in, and then after you log in you get extra
functions.  Do I just have to bite the bullet and go the
custom-SessionValidator route?

Thanks.

Mark Nutter
javadev@linklore.org
My horoscope says today is a bad day to be superstitious.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity context for Login.vm

Posted by Mark Nutter <ma...@linklore.org>.
On Fri, 2002-04-12 at 15:26, Jeff Linwood wrote:
> Hi,
> 
> If I understand what you're trying to do, I'd recommend looking into
> the pull model. There is a HOWTO on the Turbine-2 section of the Jakarta
> Turbine web site that covers this in better detail.

Thanks, that'll work to.  I'm curious as much as anything, though--I
want to know why I can't just make a Login.java and have that work the
same way Index.java works.  What's different about the login screen?

Thanks for the response, tho.

Mark Nutter
javadev@linklore.org
My horoscope says today is a bad day to be superstitious.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity context for Login.vm

Posted by Jeff Linwood <je...@greenninja.com>.
Hi,

If I understand what you're trying to do, I'd recommend looking into
the pull model. There is a HOWTO on the Turbine-2 section of the Jakarta
Turbine web site that covers this in better detail.

The basic idea is that instead of creating classes for each template, you
create
classes (called tools)that are accessible by any Velocity template. A simple
example
would be a tool called TimeTool that has getHour() and getMinute() methods.
Create
a Java class that implements
org.apache.turbine.services.pull.ApplicationTool.  Add
an entry to TurbineResources.properties (look at the Pull Model HOWTO and
the Pull
Service documentation) for the tool. Your velocity template might have a
line that looks like this:

Time is $time.getHour : $time.getMinute

The $time comes from your entry in the TurbineResources.properties, which
would look like this:
tool.global.time=com.yourcompany.turbine.tools.TimeTool

Hope this helps,
Jeff
----- Original Message -----
From: "Mark Nutter" <ja...@linklore.org>
To: <tu...@jakarta.apache.org>
Sent: Friday, April 12, 2002 2:06 PM
Subject: Velocity context for Login.vm


> I'm still fairly new to Turbine and am trying to do some customization
> of the sample app I built when I did the TDK 2.1 HowTo.  Just as a
> trivial trial run, I want to add a timestamp to the page you see when
> you first go to the site.  It's a rendering of Login.vm, so I assumed I
> could just create a Login.java--I accomplished the same thing by editing
> Index.vm and Index.java.  But it seems Login.vm is a special case.  My
> Login class is never called.  I even tested it by deliberately putting a
> divide-by-zero bug in doBuildTemplate(), but Login.vm comes up without a
> whimper.  I just copied Index.java to Login.java and changed the
> classname, and saved it in the same directory, so I'm confident I'm not
> putting it in the wrong place.
>
> I've read the docs both in the /site directory and on the Jakarta web
> site, and nothing jumps out at me.  I've tried to trace the program flow
> by reading Turbine.java and trying to trace through the various imports
> and method calls, but I'm just confusing myself.
>
> Anybody got a quick and easy pointer for me?  If there's a doc or source
> file somewhere, I'm not afraid to read it, I just don't know where to
> look.  Of course, more complete answers are welcome as well, even if
> it's "You can't do that."
>
> Am I barking up a wrong tree?  My ultimate goal is to have a public
> front page with a certain amount of dynamic content that you can see
> without having to log in, and then after you log in you get extra
> functions.  Do I just have to bite the bullet and go the
> custom-SessionValidator route?
>
> Thanks.
>
> Mark Nutter
> javadev@linklore.org
> My horoscope says today is a bad day to be superstitious.
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity context for Login.vm

Posted by Mark Nutter <ja...@linklore.org>.
Thanks, that helps.  I'm still not getting my data to display properly,
though.  Do I need to set something in turbine.properties too?

Mark

PS- I'm not making a syntax error, I think.  In doBuildTemplate I have:

  context.put("updatetime","today");

That's just a test value, obviously.  My Login screen is displaying
"$updatetime" where I expect it to say "today".

Thanks again.

On Mon, 2002-04-15 at 03:46, Fabio Daprile wrote:
> Hello,
> 
> i've got the same problem  a few weeks ago.
> I needed to execute some code before the Login.vm was displayed.
> 
> The code does not execute if  your java class extends a secure screen.
> If you extend the class VelocityScreen, then everything works.
> 
> 
> 
> public class Login extends VelocityScreen
> {
>     /**
>      * Place all the data object in the context
>      * for use in the template.
>      */
> 
>     public void doBuildTemplate( RunData data, Context context )
>     {
...


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity context for Login.vm

Posted by Fabio Daprile <fa...@wuerth.it>.
Hello,

i've got the same problem  a few weeks ago.
I needed to execute some code before the Login.vm was displayed.

The code does not execute if  your java class extends a secure screen.
If you extend the class VelocityScreen, then everything works.



public class Login extends VelocityScreen
{
    /**
     * Place all the data object in the context
     * for use in the template.
     */

    public void doBuildTemplate( RunData data, Context context )
    {
        ParameterParser _formParams;
        HttpSession _session;
        Enumeration _dataelts;
        String _tempParm;
        List _paramsList;
        Map _map;
        int counter = 0;

        _session = data.getSession();
        _formParams = data.getParameters();

        //System.out.println("TEMPSCREEN" + data.getScreen());
        //while(_dataelts.hasMoreElements())
        //{
          //_tempParm = _dataelts.nextElement().toString();

          //System.out.println("LOGIN NAME  " + _tempParm + "=" + 
_formParams.getString(_tempParm));
        //}
        _dataelts = _formParams.keys();

        _paramsList = new ArrayList();

        while(_dataelts.hasMoreElements())
        {
          _tempParm = _dataelts.nextElement().toString();
          if(!_tempParm.equals("template"))
          {
            counter++;
            _map = new HashMap();
            _map.put("name", _tempParm);
            _map.put("value", _formParams.getString(_tempParm));
            _paramsList.add(_map);
          }
        }

        context.put("ParamsList", _paramsList);
        context.put("ParamsNumber", String.valueOf(counter));
        context.put("TempScreen" ,data.getScreen()+".vm");
    }
}


bye

Fabio Daprile

Mark Nutter wrote:

>I'm still fairly new to Turbine and am trying to do some customization
>of the sample app I built when I did the TDK 2.1 HowTo.  Just as a
>trivial trial run, I want to add a timestamp to the page you see when
>you first go to the site.  It's a rendering of Login.vm, so I assumed I
>could just create a Login.java--I accomplished the same thing by editing
>Index.vm and Index.java.  But it seems Login.vm is a special case.  My
>Login class is never called.  I even tested it by deliberately putting a
>divide-by-zero bug in doBuildTemplate(), but Login.vm comes up without a
>whimper.  I just copied Index.java to Login.java and changed the
>classname, and saved it in the same directory, so I'm confident I'm not
>putting it in the wrong place.
>
>I've read the docs both in the /site directory and on the Jakarta web
>site, and nothing jumps out at me.  I've tried to trace the program flow
>by reading Turbine.java and trying to trace through the various imports
>and method calls, but I'm just confusing myself.
>
>Anybody got a quick and easy pointer for me?  If there's a doc or source
>file somewhere, I'm not afraid to read it, I just don't know where to
>look.  Of course, more complete answers are welcome as well, even if
>it's "You can't do that."
>
>Am I barking up a wrong tree?  My ultimate goal is to have a public
>front page with a certain amount of dynamic content that you can see
>without having to log in, and then after you log in you get extra
>functions.  Do I just have to bite the bullet and go the
>custom-SessionValidator route?
>
>Thanks.
>
>Mark Nutter
>javadev@linklore.org
>My horoscope says today is a bad day to be superstitious.
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>

-- 

-- 
Fabio Daprile

Würth-Phoenix Srl
Via Kravogl 4, I-39100 Bolzano
Tel: +39 0471/564111 - (direct 564070)
Fax: +39 0471/564122

mailto:fabio.daprile@wuerth-phoenix.com
http://www.wuerth-phoenix.com
http://www.wuerth.com





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>