You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tim Colson <tc...@cisco.com> on 2004/03/11 15:25:08 UTC

RE: Help with Webwork (was: error help me)

Gimhan -
  The code looks like perhaps a Webwork application - so the question
might be answered better/faster on the WebWork forum. 

  Assuming EventList action is called, and Hibernate find works, and
EventList returns SUCCESS which, and SUCCESS finds the template - then
maybe the eventlist is not available to the template.

What does $events show in the template?
What does $getProducts() show in the template?

What happens if you add this to doExecute() :
  events = sess.find("from Product");
  request.setAttribute("events", events);

Cheers,
Tim


> -----Original Message-----
> From: Gimhan Priyantha [mailto:gpriyantha@virtusa.com] 
> Sent: Wednesday, March 10, 2004 10:04 PM
> To: velocity-user@jakarta.apache.org
> Subject: error help me
> 
> 
> hai
> (eventlist.vm)
> <html>
>     <head>
>         <title>Product List</title>
>     </head>
>     <body>
> 	<h1>Products </h1>
> 	<ul>
> 	#foreach($event in $events)
> 		
> 	<li>$event.name </li>
> 	#end
> 
>         </ul>       	
>         
>     </body>
> </html>
> 
> (viewe.properties)
> 
> eventlist.action=EventList
> eventlist.success=/WEB-INF/views/eventlist.vm
> 
> newevent.action=NewEvent
> newevent.input=/WEB-INF/views/newEventForm.vm
> newevent.success=index.html
> newevent.enter.action=NewEvent!enter
> 
> 
> 
> (Eventlist.java)
> 
> package test.hibernate.actions;
> 
> import java.util.List;
> import webwork.action.ActionSupport;
> import net.sf.hibernate.Session;
> import net.sf.hibernate.SessionFactory;
> import net.sf.hibernate.cfg.Configuration;
> import net.sf.hibernate.HibernateException;
> import test.hibernate.util.SessionManager;
> import test.hibernate.data.Product;
> 
> public class EventList extends ActionSupport {
>     private List events;
>     
>     public List getProducts() {
>         return events;
>     }
>     
>     public String doExecute() {
> 
>         try {
> 	    	
> 		Configuration cfg=new 
> Configuration().addClass(Product.class);
> 		SessionFactory sf=cfg.buildSessionFactory();
> 		
>             //Session s = SessionManager.getSession();
> 		Session sess=sf.openSession();
>             
>             events = sess.find("from Product");
> 
> 		//sess.close();
>             
> 
> 	//select product from product in class 
> test.hibernate.data.Product
>             return SUCCESS;
>         } catch (HibernateException e) {
>             e.printStackTrace();
>             return ERROR;
>         }
>     }
> 
> index.html
> 
> <html>
>     <head>
>         <title>Hibernate Event Manager</title>
>     </head>
>     <body>
>     
>         <h2>Hibernate Event Manager</h2>
>         <ul>
>             <li>
>                 <a href="eventlist.action">Event Listing</a>
>             </li>
>             <li>
>                 <a href="newevent.enter.action">New Event</a>
>             </li>
>         </ul>
>     
>     </body>
> </html>
> 
> 
> product table
> 
> CREATE TABLE PRODUCTS(
>         ID VARCHAR NOT NULL PRIMARY KEY,
>         NAME VARCHAR NOT NULL,
>         PRICE DOUBLE NOT NULL,
>         AMOUNT INTEGER NOT NULL)
> 
> 
> output of eventlist.action
> 
http://localhost:8080/eventmanager/eventlist.action

Products 


question?

why the $event.name will not display?
help  me


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