Hi Grigoris I will assume that your form is surrounding the @For component. Advices: * remove the updatePassenger it will confuse things. * persist "passengerList" in the session * populate "passengerList" on pageBeginRender * add a "keyExpression" to the For component * then save all the passengers at once.
public void savePassengers() throws DataAccessException { try { for (Passenger passenger : getPassengerList()) { getSession().saveOrUpdate(passenger); } } catch (HibernateException e) { e.printStackTrace(); //nkons debug throw convertHibernateAccessException(e); } } I hope it helps. Regards. -- Alejandro Scandroli Amneris: We build process-driven web applications. http://www.amneris.es On Jan 12, 2008 4:54 PM, Grigoris Ioannou <[EMAIL PROTECTED]> wrote: > Hi all, > > I have a dynamic form where the user can set a dynamic number of passengers. > The html looks like: > > <table jwcid="@For" > source="ognl:passengerList" > value="ognl:currentPassengerId" > width="100%" > border="0"> > <span jwcid="updatePassenger"/> > <tr class="GeneralStrText"> > <td>Title</td> > <td>Name</td> > <td>Surname</td> > <td>Age</td> > </tr> > <tr> > <td> > <input jwcid="[EMAIL PROTECTED]" > value="ognl:currentPassenger.name" > type="text" > class="textField" > maxlength="40" > size="26"/> > > </td> > <td> > <input jwcid="[EMAIL PROTECTED]" > value="ognl:currentPassenger.surname > " > type="text" > class="textField" > maxlength="40" > size="26"/> > > </td> > </tr> > </table> > </td> > </tr> > </table> > > The updatePassenger is an InvokeListener that executes this code: > > public void updatePassenger(IRequestCycle cycle) { > if (cycle.isRewinding()) { > > setCurrentPassenger(getPassengerManager().getPassengerById(getCurrentPassengerId())); > getPassengerManager().savePassenger(getCurrentPassenger()); > } else { > Passenger passenger = > getPassengerManager().getPassengerById(getCurrentPassengerId()); > setCurrentPassenger(passenger); > } > } > (The idea is that in the beginning I retrieve every Passenger's data from > the database and when the form is rewinding I store them in the database > again) > > The getPassengerManager() is a class responsible for handling the Passenger > objects, based on hibernate. The savePassenger function is: > > public void savePassenger(Passenger passenger) throws DataAccessException { > try { > getSession().saveOrUpdate(passenger); > } catch (HibernateException e) { > e.printStackTrace(); //nkons debug > throw convertHibernateAccessException(e); > } > } > > The problem is that when the user submits the form in which all these are > contained, the savePassenger is called (as it should) but nor does it update > the passengers or throw an exception. What am I doing wrong? > > The thing is that in the list with passengers, I am keeping the Ids of the > passengers, not the full Passenger Object, because the DataSqueezer produced > long strings that (I believe) caused some random problems in submission: > blank screens or no reaction. > > I am using Tapestry 4.1.3. Any help would be really appreciated. Thank you > in advance, > > Grigoris > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]