You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Eko S.W." <sw...@gmail.com> on 2007/05/27 16:11:45 UTC

Problem on creating generic SharedCrudPage using BeanEditForm

Hi all,

I have a problem on using BeanEditForm. I create a page called
SharedCrud<T>, that will do CRUD for a bean. This way, I  can make quick
progress on developing prototype of web application.

Using Generic on JDK 5, the result quite good.
For example. To create 3 Crud Page for a bean, I just define this :

// in HomePage.java
SharedCrud<Journal> _sharedJournalCrud;
SharedCrud<Reference> _sharedReferenceCrud;
SharedCrud<Team> _sharedTeamCrud;

IReferenceDao referenceDao;
IJournalDao journalDao;
ITeamDao teamDao;

@OnEvent(component="OnNewReference")
public SharedCrud onNewReference(int id)
{
   _sharedReferenceCrud.preparePage(referenceDao, referenceDao.findById
(id));
   return _sharedReferenceCrud.
}
// in SharedCrud

T data;
IDao<T> dao;

@OnEvent(component="onSave")
void onSave()
{ // .. kinda
   dao.save(data);
}

But the problem is, in HomePage, the link to SharedCrud, if changing Model
(for example if entering Reference, and then switch to entering Journal), it
will fire error. Some sort like ... "error on reading bean type" (sort of).
I must click it twice to get it working..

So, what is wrong?
If one would like to see the code completely, I will gladly attach it.
Sorry can't do it right now, I am on public internet cafe here (and don't
bring my Laptop)


Imho, I think BeanEditForm is the most important corner where T5 should
focus on, in order to get a real fast framework (agile) on quick starting a
web application.
-- 
Best wishes,
Eko SW
http://swdev.blogs.friendster.com/my_blog/

Re: Problem on creating generic SharedCrudPage using BeanEditForm

Posted by "Eko S.W." <sw...@gmail.com>.
okay.
here I attach four files: SharedCrud for page that can do Crud for any bean
to any table using specific DAO. And the OpenResearch that use SharedCrud.

If you open OpenResearch.html, it display link along top of it.
For example in Reference link, there's a New Reference.
And in Journal link, there's a New Journal
So on, and so on.
That link will use SharedCrud<Reference> and SharedCrud<Journal>,
respectively.

But the problem is, if I click New Reference and then New Journal, the first
time I change to another Bean Type, it'll cause problem and the error is :
An unexpected application exception has occurred.

   - org.apache.tapestry.ioc.internal.util.TapestryException Failure
   reading parameter value of component
   tapestry.pages.shared.SharedCrud:form.textfield: crms.domain.Journal
   - java.lang.ClassCastException crms.domain.Journal
   Stack trace
      -
      org.apache.tapestry.internal.services.CoercingPropertyConduitWrapper.get
      (CoercingPropertyConduitWrapper.java:36)
      -
      org.apache.tapestry.corelib.components.BeanEditForm.getValueForProperty
      (BeanEditForm.java:241)
      - org.apache.tapestry.internal.bindings.PropBinding.get(
      PropBinding.java:54)

(I am sorry that I paste it)
I'll look forward again this problem again.
(somehow I think I know the problem is)
:)
Thanks

-- 
Best wishes,
Eko SW
http://swdev.blogs.friendster.com/my_blog/

Re: Problem on creating generic SharedCrudPage using BeanEditForm

Posted by Howard Lewis Ship <hl...@gmail.com>.
Tapestry has excellent error reporting ... use it.  Don't vaguely tell us
about an exeption, cut and paste it.  And tell us exactly what you were
doing and what you expected to happen.

On 5/27/07, Eko S.W. <sw...@gmail.com> wrote:
>
> Hi all,
>
> I have a problem on using BeanEditForm. I create a page called
> SharedCrud<T>, that will do CRUD for a bean. This way, I  can make quick
> progress on developing prototype of web application.
>
> Using Generic on JDK 5, the result quite good.
> For example. To create 3 Crud Page for a bean, I just define this :
>
> // in HomePage.java
> SharedCrud<Journal> _sharedJournalCrud;
> SharedCrud<Reference> _sharedReferenceCrud;
> SharedCrud<Team> _sharedTeamCrud;
>
> IReferenceDao referenceDao;
> IJournalDao journalDao;
> ITeamDao teamDao;
>
> @OnEvent(component="OnNewReference")
> public SharedCrud onNewReference(int id)
> {
>    _sharedReferenceCrud.preparePage(referenceDao, referenceDao.findById
> (id));
>    return _sharedReferenceCrud.
> }
> // in SharedCrud
>
> T data;
> IDao<T> dao;
>
> @OnEvent(component="onSave")
> void onSave()
> { // .. kinda
>    dao.save(data);
> }
>
> But the problem is, in HomePage, the link to SharedCrud, if changing Model
> (for example if entering Reference, and then switch to entering Journal),
> it
> will fire error. Some sort like ... "error on reading bean type" (sort
> of).
> I must click it twice to get it working..
>
> So, what is wrong?
> If one would like to see the code completely, I will gladly attach it.
> Sorry can't do it right now, I am on public internet cafe here (and don't
> bring my Laptop)
>
>
> Imho, I think BeanEditForm is the most important corner where T5 should
> focus on, in order to get a real fast framework (agile) on quick starting
> a
> web application.
> --
> Best wishes,
> Eko SW
> http://swdev.blogs.friendster.com/my_blog/
>



-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com