Hello,
I'm coming back with a beginner question ;-)
After 3 weeks of Java Web App discovering, I'm actually working with
Tapestry 4.0.2, Netbeans 5.5 which give me easy data persistence support
with JPA Toplink essential, and Tomcat5.5 and Mysql5.
So I've finaly got something working with Beanform and JPA and I come to
you to get comments and ideas and best practice.
For the persistence, the method I've found is to do the following :
* To remember with object I'm playing with :
@Persist("client")
public abstract int getProductId();
public abstract void setProductId(int productId);
* To manage the Beanform's bean :
private Product _product ;
public Product getProduct()
{
if( this._product==null && this.getProductId()>0 )
{
this.setProduct( this.loadProduct( this.getProductId()) );
}
return this._product ;
}
public void setProduct( Product product )
{
this._product = product ;
}
* For initializing the page at the first time :
public void activateExternalPage(Object[] parameters, IRequestCycle
cycle)
{
int pid = Integer.parseInt( parameters[0].toString());
setProductId( pid );
this.setProduct( this.loadProduct(pid) );
}
* And finally to implement the Beanform 'save' listener :
public String save()
{
System.out.println( "ProductEdit.save()" );
if( this.getDelegate().getHasErrors() )
return null;
EntityManager em = getDataManagerFactory().GetEntityManager();
/*** I find that method a beat strange but it works ! ***/
em.getTransaction().begin();
em.flush();
em.getTransaction().commit();
return "Home";
}
Thanks to have read my poetry ;-)
Cyrille.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]