You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Gurumurthy R <gu...@rediffmail.com> on 2001/10/01 19:06:50 UTC

Action Beans...

hi,

thanks i got the result.  the next thing what I am doing is:

1. create a login.vm file with a text field and a submit button

<form method=post action="$link.setPage("show.vm").setAction("Show")")>


2. when the button is pressed after typing any text, then another file show.vm will be called.

show.vm contains,

$student.setName("*")
Hi, you are $student.name


The steps I did was:

a. I created a bean (ShowBean.java) with setName() and getName()method in /WEB-INF/actions directory
b. I created a Show.java file where I added:
   context.put("student",new ShowBean())
c. I "ant init" successfully.
d. I started the catalina server successfully
e. I now give the url: I get the login.vm screen\
f. I type the name and press the button, here I get "error"

pl. clarify why?

guru
On Mon, 01 Oct 2001 Christoph Reck wrote :
> Probably you did not compile your *,java file into 
> a class file and placed that class file into 
> WEB-INF/classes
> (check file dates to detect what the newest is...).
> 
> You will also probably need to restart the catalina 
> server
> (I believe the default is that it does not do class 
> reloading).
> 
> :) Christoph
> 
> 
> Gurumurthy R wrote:
> > 
> > yes,
> > 
> > i did the same.  i checked my .java file.
> > 
> > it contains;
> > 
> > context.put("hello","This is just sample");
> > 
> > i also checked the .log file, which says:
> > 
> > Velocity started successfully.
> > 
> > but .vm file not able to fetch the result ($hello) 
> from .class file,
> > 
> > if u further help me in giving guidelines,  i will be 
> great to you.  sorry for the trouble i give.
> > 
> > thanks in advance,
> > 
> > expecting a reply from u,
> > 
> > thanks,
> > 
> > guru
> > 
> > On Fri, 28 Sep 2001 Christoph Reck wrote :
> > 
> > > Please check your log file. It seems that your 
> servlet
> > 
> > > is being accessed,
> > 
> > > therefore velocity is running. Yout logfile will
> > 
> > > probably have a line
> > 
> > > saying that the $hello reference is not in the 
> context.
> > 
> > >
> > 
> > > Ensure that you did:
> > 
> > >   ctx.put("hello", "...some sensible string 
> here...");
> > 
> > >
> > 
> > > If your Catalina server did not start the velocity
> > 
> > > servlet, probably you
> > 
> > > did not configure the servlet container properly 
> (e.g.
> > 
> > > to
> > 
> > > locate your servlet at "HelloWorld/servlet/HelloWorl-
> d/Tu-
> > 
> > > rbine")
> > 
> > > or you did not compile the servlet properly. Please
> > 
> > > read the
> > 
> > > documentation on how to get your servlet runnin (in
> > 
> > > case of turbine
> > 
> > > check the Turbine docs).
> > 
> > >
> > 
> > > I hope you can enter the wonderful velocity world 
> now.
> > 
> > >
> > 
> > > :) Christoph
> > 
> > >
> > 
> > > One comment embedded below:
> > 
> > >
> > 
> > > Gurumurthy R wrote:
> > 
> > > >
> > 
> > > > Hello Folks,
> > 
> > > >
> > 
> > > > I wrote HelloWorld.vm and put in the appropriate
> > 
> > > template/screens directory.
> > 
> > > >
> > 
> > > > I also wrote HelloWorld.java and put in the
> > 
> > > /WEB-INF/classes directory.
> > 
> > > >
> > 
> > > > I started catalina server.
> > 
> > > >
> > 
> > > > My package name is: HelloWorld
> > 
> > > >
> > 
> > > > so, when I enter the URL in the browser like this:
> > 
> > > >
> > 
> > > > http://localhost:8080/HelloWorld/servlet/HelloWorl-
> d/Tu-
> > 
> > > rbine/template/HelloWorld.vm
> > 
> > >
> > 
> > > I would expect in a non-turbine environment:
> > 
> > >   http://localhost:8080/HelloWorld/servlet/template/-
> Hell-
> > 
> > > oWorld.vm
> > 
> > > Where HelloWorld is your WEB-Application, template 
> is
> > 
> > > the servlet responding
> > 
> > > to *.vm requests, and HelloWorld.vm is the template
> > 
> > > name located at the
> > 
> > s configured
> > 
> > > with.
> > 
> > >
> > 
> > > >
> > 
> > > > The output what I am getting is:
> > 
> > > >
> > 
> > > > $hello of the emergency broadcast station.
> > 
> > > >
> > 
> > > > (The problem is that $hello is not being replaced 
> at
> > 
> > > all)
> > 
> > > >
> > 
> > > > Can you pl. help me?
> > 
> > > >
> > 
> > > > Thanks in advance,
> > 
> > > >
> > 
> > > > Guru
> > 
> >