Ho! I found the answer,it's just not a hibernate issue,just since it
was a wrong way to write ValueEncoder implementation.

At first.it's my old 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));
       }
}

these code would get client or server side value from catService,this
is the mistake.

I fixed to these,at first get the category object List,and cut off the
relation between ValueEncoder and catService:

public class GenericValueEncoder<T> implements ValueEncoder<T> {

       protected List<T> list;
       protected final PropertyAccess access;
       protected final String fieldName;

       public GenericValueEncoder(List<T> list, String fieldName,
PropertyAccess propertyAccess) {
               this.list = list;
               this.fieldName = fieldName;
               this.access = propertyAccess;
       }

       public String toClient(T obj) {
               if (fieldName == null) {
                       return obj + "";
               } else {
                       return access.get(obj,fieldName)+"";
               }
       }

       public T toValue(String string) {
               for (T obj : list) {
                       if (toClient(obj).equals(string)) return obj;
               }
               return null;
       }
}

public class CategoryValueEncoder extends GenericValueEncoder<Category>{
        
        public CategoryValueEncoder(List<Category> cats,PropertyAccess
propertyAccess) {
                super(cats,"id",propertyAccess);
        }
}

in ListView class,will be fixed as:
...
@Inject
private PropertyAccess propAccess;
public ValueEncoder<Category> getCatEncoder(){
        log.debug("getCatEncoder...");
        return new CategoryValueEncoder(catService.list(),propAccess);
}
...

ok,it's my resolution.
its knowledge came from tapestry
wiki:http://wiki.apache.org/tapestry/Tapestry5SelectObject?highlight=%28ValueEncoderSource%29
thanks,tapestry and friends!

On Wed, Sep 23, 2009 at 7:22 PM, Thiago H. de Paula Figueiredo
<thiag...@gmail.com> wrote:
> Em Wed, 23 Sep 2009 07:10:29 -0300, cleverpig <greatclever...@gmail.com>
> escreveu:
>
>> org.hibernate.LazyInitializationException: could not initialize proxy
>
> This is a Hibernate issue, not a Tapestry one. By the way, understanding
> this exception is basic Hibernate knowledge. Your solution is in the manual.
> ;)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>



-- 
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