in my case onAddRow will not do any persisting. I will only persist the added row once the user saves the whole form. Also, I use my own transaction handling which is all done in a filter outside Tapestry. So any exception will actually roll back the transaction.
The fact that I don't use any of the Tapestry hibernate/transaction stuff might cause a substantial difference. Cheers, Joost On Tue, Apr 28, 2009 at 6:59 PM, zack1403 <zack.mann...@gmail.com> wrote: > > Thanks Joost! While I'm sorting through that to find out what youre doing > that I am missing, here is a question. When my onAddRow event is throwing > an exception, shouldn't the transaction be rolled back? I would think that > is expected behavior but the transaction is being committed. When I refresh > the page the row is there. Is there a reason that isnt consistent with the > rest of tapestry transactions? > > Zack > > > Joost Schouten (mailing lists) wrote: >> >> sorry, I forgot the encoder for the AjaxFormLoop: >> >> public ValueEncoder<AjaxFormLoopEntityHolder<ContactDetail>> >> getContactDetailEncoder() { >> >> final LegalEntityService service = >> serviceProvider.getService(LegalEntityService.class); >> >> return new >> ValueEncoder<AjaxFormLoopEntityHolder<ContactDetail>>() { >> >> public String >> toClient(AjaxFormLoopEntityHolder<ContactDetail> detail) >> { >> return detail.getKey().toString(); >> } >> >> public AjaxFormLoopEntityHolder<ContactDetail> >> toValue(String detailId) >> { >> >> AjaxFormLoopEntityHolder<ContactDetail> ret = >> null; >> >> Long detailKey = Long.parseLong(detailId); >> >> for(AjaxFormLoopEntityHolder<ContactDetail> >> holder : details) { >> if(detailKey.equals(holder.getKey())) { >> ret = holder; >> break; >> } >> } >> >> return ret; >> >> } >> }; >> } >> >> On Tue, Apr 28, 2009 at 6:45 PM, Joost Schouten (mailing lists) >> <joost...@jsportal.com> wrote: >>> Here is the code related to my AjaxFormLoop which works (besides a few >>> non T5 related persistance issues in my own code ;-) >>> >>> >>> >>> ******************* java file ************** >>> >>> �...@property >>> �...@persist >>> private List<AjaxFormLoopEntityHolder<ContactDetail>> details; >>> >>> �...@property >>> private AjaxFormLoopEntityHolder<ContactDetail> contactDetailRow; >>> >>> �...@component(id = "contactDetailsAjaxLoop", parameters = >>> {"source=details", >>> >>> "value=contactDetailRow", >>> >>> "addRow=block:addRowBlock", >>> >>> "encoder=contactDetailEncoder"}) >>> private AjaxFormLoop contactDetailsAjaxLoop; >>> >>> �...@component(id = "contactDetailForm", parameters = >>> {"zone=contactDetailsZone", "context=legalEntity.id"}) >>> private Form contactDetailForm; >>> >>> �...@component(id = "addRowLink", parameters = >>> {"context=legalEntity.id"}) >>> private AddRowLink addRowLink; >>> >>> >>> �...@component(id = "contactDetailsSubmit", parameters = >>> {"value=message:jsportal.controls.save"}) >>> private Submit contactDetailsSubmit; >>> >>> �...@inject >>> �...@property >>> private Block addRowBlock; >>> >>> �...@onevent(value=EventConstants.ADD_ROW) >>> private Object handleAddRow() throws Exception { >>> this.setEdit(true); >>> >>> ContactDetail contactDetail = new >>> ContactDetail(); >>> contactDetail.setState(State.ACTIVE); >>> AjaxFormLoopEntityHolder detail = new >>> AjaxFormLoopEntityHolder<ContactDetail>(contactDetail, true, 0 - >>> System.currentTimeMillis()); >>> details.add(detail); >>> >>> return detail; >>> } >>> >>> �...@onevent(value=EventConstants.REMOVE_ROW) >>> private void handleRemoveRow(AjaxFormLoopEntityHolder detail) >>> throws Exception{ >>> >>> for(AjaxFormLoopEntityHolder<ContactDetail> holder : details) { >>> if(detail.getKey() == >>> holder.getKey()) { >>> detail.setDeleted(true); >>> } >>> } >>> } >>> >>> �...@onevent(component = "contactDetailForm", value = >>> EventConstants.PREPARE_FOR_SUBMIT) >>> private void handleContactDetailPrepare(Long >>> legalEntityId) throws Exception { >>> loadLegalEntity(legalEntityId); >>> } >>> >>> private void loadLegalEntity(Long legalEntityId) throws >>> Exception { >>> LegalEntityService service = >>> serviceProvider.getService(LegalEntityService.class); >>> legalEntity = (LegalEntity) >>> service.get(LegalEntity.class, legalEntityId); >>> } >>> >>> �...@onevent(component = "contactDetailForm", value = >>> EventConstants.SUCCESS) >>> private Object handleContactDetailSave() throws Exception >>> { >>> >>> //do the persisting >>> } >>> >>> >>> **************** AjaxFormLoopEntityHolder ****************** >>> >>> package com.joostschouten.common.http.tapestrybase.model; >>> >>> public class AjaxFormLoopEntityHolder<T> { >>> >>> private T entity; >>> private Long key; >>> private boolean newEntity = false; >>> private boolean deleted = false; >>> >>> public AjaxFormLoopEntityHolder(T entity, boolean >>> newEntity, Long key) { >>> this.entity = entity; >>> this.newEntity = newEntity; >>> this.key = key; >>> } >>> >>> public T getEntity() { >>> return entity; >>> } >>> >>> public void setEntity(T entity) { >>> this.entity = entity; >>> } >>> >>> public Long getKey() { >>> return key; >>> } >>> >>> public boolean isNew() { >>> return newEntity; >>> } >>> >>> public boolean setDeleted(boolean deleted) { >>> return this.deleted = deleted; >>> } >>> >>> public boolean isDeleted() { >>> return deleted; >>> } >>> >>> } >>> >>> >>> ******************* The tml file *********************** >>> >>> >>> <form t:id="contactDetailForm"> >>> >>> <div >>> class="entityDetails"> >>> <div >>> t:id="contactDetailsAjaxLoop"> >>> >>> <t:delegate to="detailBlock"/> >>> </div> >>> >>> </div> >>> >>> <ol class="formControls"> >>> <li class="next"> >>> <input >>> t:id="contactDetailsSubmit" >>> t:value="message:jsportal.controls.save"/> >>> </li> >>> </ol> >>> >>> </form> >>> </t:block> >>> >>> <t:block t:id="detailBlock"> >>> <div t:id="loopContactDetail">the >>> form fields, in my case they >>> come from a seperate component</div> >>> </t:block> >>> >>> <t:block id="addRowBlock"> >>> <div class="formControls"> >>> <div class="next"> >>> >>> ${message:components.entities.EntitiesContactDetails.addNewContactInfo} >>> </div> >>> </div> >>> </t:block> >>> >>> I hope this is of use to you. >>> >>> Cheers, >>> Joost >>> >>> On Tue, Apr 28, 2009 at 6:15 PM, zack1403 <zack.mann...@gmail.com> wrote: >>>> >>>> Hmm, the jumpstart example you gave uses t:submitnotifier as well as all >>>> examples (even nightly docs). The example you gave is running on >>>> 5.0.18. >>>> You are sure that example works on upgrade to 5.1.0.2? Even at the >>>> simplest >>>> form I am still getting my exception. The simplest possible form I >>>> could >>>> get down to is in my first post (page, tml, and exception). This is >>>> happening application-wide once I upgraded so it must be something that >>>> has >>>> changed internal to tapestry. Is there a new way to use AjaxFormLoop >>>> that I >>>> am missing. Does onAddRow still return an Object? >>>> >>>> Zack >>>> >>>> >>>> Joost Schouten (mailing lists) wrote: >>>>> >>>>> The example at >>>>> http://jumpstart.doublenegative.com.au:8080/jumpstart/examples/tables/ajaxformloop1 >>>>> which I used as a guide worked well for me on 5.1.0.3. >>>>> >>>>> In your examples you use the t:submitnotifier. I never really used it >>>>> but maybe you do some DOM alterations in those event methods that >>>>> Tapestry doesn't like. >>>>> >>>>> Cheers, >>>>> Joost >>>>> >>>>> On Tue, Apr 28, 2009 at 3:59 PM, zack1403 <zack.mann...@gmail.com> >>>>> wrote: >>>>>> >>>>>> Hey I hate to bump but this is a huge blocker for me. Is there more >>>>>> information I can give to try and help troubleshoot?? >>>>>> >>>>>> -- >>>>>> View this message in context: >>>>>> http://www.nabble.com/AjaxFormLoop-Exception-on-5.1.0.2-upgrade-tp23175801p23269752.html >>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com. >>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>>>>> For additional commands, e-mail: users-h...@tapestry.apache.org >>>>>> >>>>>> >>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>>>> For additional commands, e-mail: users-h...@tapestry.apache.org >>>>> >>>>> >>>>> >>>> >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/AjaxFormLoop-Exception-on-5.1.0.2-upgrade-tp23175801p23270804.html >>>> Sent from the Tapestry - User mailing list archive at Nabble.com. >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>>> For additional commands, e-mail: users-h...@tapestry.apache.org >>>> >>>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> >> > > -- > View this message in context: > http://www.nabble.com/AjaxFormLoop-Exception-on-5.1.0.2-upgrade-tp23175801p23271251.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org