I wrote a simple query in ListView page,there is a select component in
the page bottom,which will load category list from DB by Hibernate.
the ListView.tml will provider query parameter(selectCat) to the ListView class.

when i running them,i got this exception:

2009-09-23 17:45:41 http-8080-2 DEBUG scrip.ListView:[161]:getSelectCat...
2009-09-23 17:45:41 http-8080-2 DEBUG scrip.ListView:[151]:getCatEncoder...
2009-09-23 17:45:41 http-8080-2 ERROR
hibernate.LazyInitializationException:[19]:could not initialize proxy
- no Session
org.hibernate.LazyInitializationException: could not initialize proxy
- no Session
        at 
org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
        at 
org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
        at 
org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.invoke(CGLIBLazyInitializer.java:150)
        at 
com.packtpub.t5first.entities.Category$$EnhancerByCGLIB$$13d50a18.getId(<generated>)
        at 
com.packtpub.t5first.utils.CategoryEncoder.toClient(CategoryEncoder.java:20)
        at 
com.packtpub.t5first.utils.CategoryEncoder.toClient(CategoryEncoder.java:1)
        at 
org.apache.tapestry5.corelib.components.Select.options(Select.java:224)

Here is my code:

---my ListView page class---
public class ListView{
...
        @InjectService("catService")
        private CategoryService catService;

        public SelectModel getCatSelectModel(){
                log.debug("getCatSelectModel...");
                return new CategorySelectModel(catService.list());
        }
        
        public ValueEncoder<Category> getCatEncoder(){
                log.debug("getCatEncoder...");
                return new CategoryEncoder(catService);
        }
        @Persist
        private Category selectCat;
        
        @Inject
        private CategoryDAO catDao;
        
        public Category getSelectCat() {
                log.debug("getSelectCat...");
                return selectCat;
        }

        public void setSelectCat(Category selectCat) {
                log.debug("setSelectCat...");
                this.selectCat = selectCat;
        }
...
}

---my CategoryEncoder class---
public class CategoryEncoder implements ValueEncoder<Category>{
        private CategoryService catService;
        
        public CategoryEncoder(CategoryService catService) {
                super();
                this.catService = catService;
        }

        @Override
        public String toClient(Category cat) {
                return String.valueOf(cat.getId());
        }

        @Override
        public Category toValue(String id) {
                return catService.getFromId(Integer.parseInt(id));
        }
}

---ListView.tml---
<html t:type="layout"
        title="${message:page-scrip-listview}"
        xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd";>
        <t:form t:id="scripListQueryForm">
                <div id="dataListScope">
                        <t:grid
                                t:id="scripGrid"
                                t:source="listDS"
                                t:empty="There are currently no search results"
                                model="beanModel"
                                rowsPerPage="5"
                        row="current"
                        exclude="content"
                        reorder="rownumber,id,title,releaseDate"
                        pagerPosition="bottom"
                        style="width:620px;">
                    </t:grid>
            </div>
            <div id="operationScope">
                <p>
                        <t:label for="queryCat"/>
                        <t:select t:id="queryCat"
                                t:model="catSelectModel"
                                t:value="selectCat"
                                t:encoder="catEncoder"/>
                        <t:Submit t:id="submitQueryButton"/>
                </p>
            </div>
    </t:form>
</html>

who can give me some suggestion? Any help is welcome! :)
-- 
cleverpig(Dan)
Location: Beijing
Address: Room 4018,No.A2 South Avenue Fuxingmen Beijing,P.R.China
Zipcode: 100031
MSN: great_liu...@hotmail.com
QQ: 149291732
Skype: cleverpigatmatrix
Facebook ID:cleverpig
Blog: www.cleverpig.name
Tags: del.icio.us/cleverpig
Twitter: twitter.com/cleverpig
新浪微博: t.sina.com.cn/cleverpig
Organization: www.beijing-open-party.org
or...@facebook: http://www.facebook.com/group.php?gid=8159558294

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to