You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by pipothebit <pi...@yahoo.es> on 2006/10/11 17:08:30 UTC

Master detail problem

hellow and sorry for my english,
I am novice tapestry user and I have a problem with a master detail
relation.

I have a simple bean like this:

...
public class Master imelements Serializable {
  private String name;
  private List<Detail> detail = new ArrayList<Detail>();
.....
.....
}
...


I need to do all the operations in a single page and the code is like
this:

...
<form jwcid="@Form" success="listener:doSubmit">
  <input jwcid="@TextField" value="ognl:master.name" size="40"/>
  <a href="#" jwcid="@DirectLink" listener="listener:addAction">add</a>
  <table>
    <tr>
      <td colspan="2">value</td>
    </tr>
    <tr jwcid="@For" source="ognl:master.detail" value="ognl:item"
element="tr" index="ognl:index">
      <td>
	<input jwcid="@TextField" type="text" size="40"
value="ognl:item.value"/>
      </td>
      <td>
        <a href="#" jwcid="@DirectLink" listener="listener:delAction"
parameters="ognl:{index}">del</a>
      </td>
    </tr>
  </table>
  <input type="submit" value="Submit"/>
...
...
</form>
...

The java code of the page is like this:

...
public abstract class MasterDetail extends BasePage {
  @Persist
  public abstract Master getMaster();
  public abstract void setMaster(Master master);

  public void addAction() throws Exception {
    getMaster().getDetail().add(new Detail());
  }

  public void delAction(int index) throws Exception {
    getMaster().getDetail().remove(index);
  }

  @InjectPage("ListPage")
  public abstract ListPage getListPage();
  public IPage doSubmit() throws Exception {
    ...
    ... Database
    ...
    return getListPage();
  }
}

All work fine except when I add a new Detail to de Master record. In
that case the Master bean do not get the state saved previously, that
is, I enter a name and when I pres the "add" link to add a new Detail
the Master bean is reseted. The empty element is added to de Detail List
but all previos values of the bean are lost. But when I enter values to
all fields and press the submit button the values are correctly saved.

Can some one help me?
very thank you.


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y m�viles desde 1 c�ntimo por minuto. 
http://es.voice.yahoo.com

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


Re: Master detail problem

Posted by pipothebit <pi...@yahoo.es>.
Ok, very thank you for your reply.

The problem is than I am using the wrong component.

In a form to populate tehe values of form fields to the bean properties
it must be submited. If you use the DirectLink component the form is not
submited, and values are not populated to bean properties. DirectLink
simply call java code. With the LinkSubmit component the form is
submited and values are populated.


Very thank you.

El jue, 12-10-2006 a las 10:33 -0700, Josh Long escribió:
> I'm not sure, but try and make sure that a) your object is
> serializable,b) that it has a working equals/ hashCode based on
> something that works well for objects in a collection, c) that all the
> above is actually doing what you hope it is in the DB and, finally, d)
> that you call setMaster on the page when youve updated the object
> (unless of course youre resetting the object graph on pageBeginRender
> each time)
> 
> Peace,
> Josh
> 
> 
> 
> On 10/11/06, pipothebit <pi...@yahoo.es> wrote:
> > hellow and sorry for my english,
> > I am novice tapestry user and I have a problem with a master detail
> > relation.
> >
> > I have a simple bean like this:
> >
> > ...
> > public class Master imelements Serializable {
> >   private String name;
> >   private List<Detail> detail = new ArrayList<Detail>();
> > .....
> > .....
> > }
> > ...
> >
> >
> > I need to do all the operations in a single page and the code is like
> > this:
> >
> > ...
> > <form jwcid="@Form" success="listener:doSubmit">
> >   <input jwcid="@TextField" value="ognl:master.name" size="40"/>
> >   <a href="#" jwcid="@DirectLink" listener="listener:addAction">add</a>
> >   <table>
> >     <tr>
> >       <td colspan="2">value</td>
> >     </tr>
> >     <tr jwcid="@For" source="ognl:master.detail" value="ognl:item"
> > element="tr" index="ognl:index">
> >       <td>
> >         <input jwcid="@TextField" type="text" size="40"
> > value="ognl:item.value"/>
> >       </td>
> >       <td>
> >         <a href="#" jwcid="@DirectLink" listener="listener:delAction"
> > parameters="ognl:{index}">del</a>
> >       </td>
> >     </tr>
> >   </table>
> >   <input type="submit" value="Submit"/>
> > ...
> > ...
> > </form>
> > ...
> >
> > The java code of the page is like this:
> >
> > ...
> > public abstract class MasterDetail extends BasePage {
> >   @Persist
> >   public abstract Master getMaster();
> >   public abstract void setMaster(Master master);
> >
> >   public void addAction() throws Exception {
> >     getMaster().getDetail().add(new Detail());
> >   }
> >
> >   public void delAction(int index) throws Exception {
> >     getMaster().getDetail().remove(index);
> >   }
> >
> >   @InjectPage("ListPage")
> >   public abstract ListPage getListPage();
> >   public IPage doSubmit() throws Exception {
> >     ...
> >     ... Database
> >     ...
> >     return getListPage();
> >   }
> > }
> >
> > All work fine except when I add a new Detail to de Master record. In
> > that case the Master bean do not get the state saved previously, that
> > is, I enter a name and when I pres the "add" link to add a new Detail
> > the Master bean is reseted. The empty element is added to de Detail List
> > but all previos values of the bean are lost. But when I enter values to
> > all fields and press the submit button the values are correctly saved.
> >
> > Can some one help me?
> > very thank you.
> >
> >
> >
> > ______________________________________________
> > LLama Gratis a cualquier PC del Mundo.
> > Llamadas a fijos y móviles desde 1 céntimo por minuto.
> > http://es.voice.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y m�viles desde 1 c�ntimo por minuto. 
http://es.voice.yahoo.com

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


Re: Master detail problem

Posted by Josh Long <st...@gmail.com>.
I'm not sure, but try and make sure that a) your object is
serializable,b) that it has a working equals/ hashCode based on
something that works well for objects in a collection, c) that all the
above is actually doing what you hope it is in the DB and, finally, d)
that you call setMaster on the page when youve updated the object
(unless of course youre resetting the object graph on pageBeginRender
each time)

Peace,
Josh



On 10/11/06, pipothebit <pi...@yahoo.es> wrote:
> hellow and sorry for my english,
> I am novice tapestry user and I have a problem with a master detail
> relation.
>
> I have a simple bean like this:
>
> ...
> public class Master imelements Serializable {
>   private String name;
>   private List<Detail> detail = new ArrayList<Detail>();
> .....
> .....
> }
> ...
>
>
> I need to do all the operations in a single page and the code is like
> this:
>
> ...
> <form jwcid="@Form" success="listener:doSubmit">
>   <input jwcid="@TextField" value="ognl:master.name" size="40"/>
>   <a href="#" jwcid="@DirectLink" listener="listener:addAction">add</a>
>   <table>
>     <tr>
>       <td colspan="2">value</td>
>     </tr>
>     <tr jwcid="@For" source="ognl:master.detail" value="ognl:item"
> element="tr" index="ognl:index">
>       <td>
>         <input jwcid="@TextField" type="text" size="40"
> value="ognl:item.value"/>
>       </td>
>       <td>
>         <a href="#" jwcid="@DirectLink" listener="listener:delAction"
> parameters="ognl:{index}">del</a>
>       </td>
>     </tr>
>   </table>
>   <input type="submit" value="Submit"/>
> ...
> ...
> </form>
> ...
>
> The java code of the page is like this:
>
> ...
> public abstract class MasterDetail extends BasePage {
>   @Persist
>   public abstract Master getMaster();
>   public abstract void setMaster(Master master);
>
>   public void addAction() throws Exception {
>     getMaster().getDetail().add(new Detail());
>   }
>
>   public void delAction(int index) throws Exception {
>     getMaster().getDetail().remove(index);
>   }
>
>   @InjectPage("ListPage")
>   public abstract ListPage getListPage();
>   public IPage doSubmit() throws Exception {
>     ...
>     ... Database
>     ...
>     return getListPage();
>   }
> }
>
> All work fine except when I add a new Detail to de Master record. In
> that case the Master bean do not get the state saved previously, that
> is, I enter a name and when I pres the "add" link to add a new Detail
> the Master bean is reseted. The empty element is added to de Detail List
> but all previos values of the bean are lost. But when I enter values to
> all fields and press the submit button the values are correctly saved.
>
> Can some one help me?
> very thank you.
>
>
>
> ______________________________________________
> LLama Gratis a cualquier PC del Mundo.
> Llamadas a fijos y móviles desde 1 céntimo por minuto.
> http://es.voice.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

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