You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Scott Anderson <sa...@ttm.com> on 2001/03/26 19:06:44 UTC

Velocity context not working for me?

OK, please tell me where I'm being stupid. :-)

Here's the main part of
WEB-INF/src/java/com/ti/ui/modules/screens/Login.java:

public class Login extends VelocityScreen
{
    public void doBuildTemplate( RunData data, Context context )
    {
	context.put("test", "Yippee");
    }
}


Now, here's templates/screens/Login.vm:

$page.setTitle("Login Screen")

<form method="post"
action="$link.setAction("Login").setPage("Main.vm")">
  <table>
    <tr>
      <td>$test</td>
	<td><input type="text" size="30" name="username" value=""></td>
    </tr>
    <tr>
      <td>$test</td>
	<td><input type="password" size="30" name="password" value=""></td>
    </tr>
    <tr>
      <td>
        <font>
          <input type="submit" value="Login">
        </font>
      </td>
    </tr>
  </table>
</form>



When I pull up http://localhost:8080/portal/servlet/portal/Login, I get
the HTML from Login.vm, but no $test, and the velocity log complains
that $test is not a valid reference.

Since this is how I believe this is supposed to work based on the
documentation, what am I doing wrong?

Thanks,
-scott

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity context not working for me?

Posted by Jason van Zyl <jv...@apache.org>.
Scott Anderson wrote:
> 
> OK, please tell me where I'm being stupid. :-)

What package is your screen in? And what is the entry
for 'module.packages' in your TR.props file. The screen
you are listing below is probably not being found.
 
> Here's the main part of
> WEB-INF/src/java/com/ti/ui/modules/screens/Login.java:
> 
> public class Login extends VelocityScreen
> {
>     public void doBuildTemplate( RunData data, Context context )
>     {
>         context.put("test", "Yippee");
>     }
> }
> 
> Now, here's templates/screens/Login.vm:
> 
> $page.setTitle("Login Screen")
> 
> <form method="post"
> action="$link.setAction("Login").setPage("Main.vm")">
>   <table>
>     <tr>
>       <td>$test</td>
>         <td><input type="text" size="30" name="username" value=""></td>
>     </tr>
>     <tr>
>       <td>$test</td>
>         <td><input type="password" size="30" name="password" value=""></td>
>     </tr>
>     <tr>
>       <td>
>         <font>
>           <input type="submit" value="Login">
>         </font>
>       </td>
>     </tr>
>   </table>
> </form>
> 
> When I pull up http://localhost:8080/portal/servlet/portal/Login, I get
> the HTML from Login.vm, but no $test, and the velocity log complains
> that $test is not a valid reference.
> 
> Since this is how I believe this is supposed to work based on the
> documentation, what am I doing wrong?
> 
> Thanks,
> -scott
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org

-- 
jvz.

Jason van Zyl
jvanzyl@apache.com

http://jakarta.apache.org/velocity
http://jakarta.apache.org/turbine
http://tambora.zenplex.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org


Re: Velocity context not working for me?

Posted by Jon Stevens <jo...@latchkey.com>.
on 3/26/01 9:06 AM, "Scott Anderson" <sa...@ttm.com> wrote:

> When I pull up http://localhost:8080/portal/servlet/portal/Login, I get
> the HTML from Login.vm, but no $test, and the velocity log complains
> that $test is not a valid reference.
> 
> Since this is how I believe this is supposed to work based on the
> documentation, what am I doing wrong?

Wrong URL.

http://localhost:8080/portal/servlet/portal/template/Login.vm

-jon

-- 
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>


---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org