1 4 package xpetstore.web.webwork.action.category; 5 6 import java.util.Iterator ; 7 8 import cirrus.hibernate.Session; 9 10 import xpetstore.domain.Category; 11 import xpetstore.domain.Product; 12 13 import xpetstore.web.webwork.action.BaseAction; 14 15 16 23 public class CategoryAction 24 extends BaseAction 25 { 26 28 private Category _category = null; 29 private String _categoryId = ""; 30 31 33 36 protected String doExecute( ) 37 throws Exception 38 { 39 Session s = getHibernateSession( ); 40 41 try 42 { 43 _category = ( Category ) s.load( Category.class, _categoryId ); 44 45 49 Iterator it = _category.getProducts( ).iterator( ); 50 51 while ( it.hasNext( ) ) 52 { 53 Product p = ( Product ) it.next( ); 54 p.getName( ); 55 } 56 57 return SUCCESS; 58 } 59 finally 60 { 61 s.close( ); 62 } 63 } 64 65 68 public Category getCategory( ) 69 { 70 return _category; 71 } 72 73 76 public String getCategoryId( ) 77 { 78 return _categoryId; 79 } 80 81 85 public void setCategory( Category category ) 86 { 87 _category = category; 88 } 89 90 94 public void setCategoryId( String categoryId ) 95 { 96 _categoryId = categoryId; 97 } 98 } 99 | Popular Tags |