Your myList instance variable is not initialized with the data you want to 
display. 

> Date: Sat, 5 Mar 2011 05:59:28 -0800
> From: shekharlaa...@gmail.com
> To: user@struts.apache.org
> Subject: display data of action class on jsp in struts2
> 
> 
> i m new to struts2,rest plugin and i m tring to retrieve data from database
> through jpa  and display it on jsp.
> my action class successfully running and retrieving the data but unable to
> show it on my jsp page.so if any body have idea about it please help me
> my action class is
> 
> [code]
> 
> package com.action;
> 
> import java.util.Iterator;
> import java.util.List;
> 
> import javax.persistence.EntityManager;
> import javax.persistence.EntityManagerFactory;
> import javax.persistence.EntityTransaction;
> import javax.persistence.Persistence;
> import javax.persistence.Query;
> 
> import org.apache.struts2.convention.annotation.*;
> import org.apache.struts2.rest.DefaultHttpHeaders;
> 
> import com.opensymphony.xwork2.ActionSupport;
> 
> @ParentPackage(value="default")
> @Namespace("/")
> @ResultPath(value="/")
> 
> 
> public class noOfUsers extends ActionSupport {
>       /**
>        * 
>        */
>       private static final long serialVersionUID = 1L;
> 
>       private String firstname;
>       List  myList;
> 
>       private String user;
>       
> @SuppressWarnings("unchecked")
> @Action(value="usersn",results={
>       @Result(name="create",type="tiles",location="users")    
>       })
>       
>       public static DefaultHttpHeaders create(){  
>               EntityManagerFactory 
> emf=Persistence.createEntityManagerFactory("tujpa");
>               EntityManager em=emf.createEntityManager();
>               EntityTransaction entr=em.getTransaction();
>               entr.begin();
>               Query query=em.createQuery("select u.firstname from User u ");
>               List myList=query.getResultList();  
>               System.out.println(myList);
>                     entr.commit();
>                     em.close();
>                   return new DefaultHttpHeaders("create");        
>       }
> 
> public List getMyList(){
>     return myList;
>   }
> }
> 
> [/code ]
> 
> 
> thanks in advance
> -- 
> View this message in context: 
> http://old.nabble.com/display-data-of-action-class-on-jsp-in-struts2-tp31075171p31075171.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
> 
                                          

Reply via email to