Hi, there are just two assignments to formData:
@OnEvent(value = EventConstants.PREPARE_FOR_RENDER, component = "searchForm") void prepareForRender() { formData = new ServiceSearchFormData(); // more initialization here, i.e. calling setters like formData.setCity(DEFAULT_CITY_NAME); } ... @OnEvent(value = EventConstants.PREPARE_FOR_SUBMIT, component = "searchForm") void prepareForSubmit() { formData = new ServiceSearchFormData(); } Cheers Jarda > On May25, 2016, at 13:51, Cezary Biernacki <cezary...@gmail.com> wrote: > > Hi, > @Barry, yes, your solution should fix null pointer exception, but probably > it would break the application. A better way: > > public SearchFormData getFormData() { > if (formData == null) { > formData = new SearchFormData(); > } > return formData; > } > > However, it is still interesting that formData is null (assuming that there > is no other code explicitly assigning a value to this field). > > On Wed, May 25, 2016 at 12:37 PM, Barry Books <trs...@gmail.com> wrote: > >> It's difficult to say why it might be null but changing the code to >> >> public SearchFormData getFormData() { >> return new SearchFormData(); >> } >> >> should fix it >> >> On Monday, May 23, 2016, Jaroslav Ciml <jaroslav.c...@jpower8.cz> wrote: >> >>> Hi, >>> >>> I am getting a strange exception during submit of a Tapestry form that I >>> cannot explain. It happens just rarely (but regularily) in the production >>> environment. I cannot even reproduce the exception. >>> >>> I have a form in tml file of a Tapestry component. >>> >>> ... >>> <t:form t:id="searchForm" clientValidation="none"> >>> .... >>> <t:select t:id="globalSport" model="globalSportModel" >>> value="formData.globalSportId" blankOption="never"/> >>> .... >>> </t:form> >>> .. >>> >>> And here is the important part of corresponding Java file: >>> >>> ... >>> @Property(read = true, write = false) >>> private ServiceSearchFormData formData; >>> ... >>> @OnEvent(value = EventConstants.PREPARE_FOR_SUBMIT, component = >>> "searchForm") >>> void prepareForSubmit() >>> { >>> formData = new ServiceSearchFormData(); >>> } >>> ... >>> >>> It seems to be pretty straightforward. ServiceSearchFormData is a DTO >> with >>> few attributes and getter / setter methods. It encapsulates data >> submitted >>> in the form. An instance is created on "prepare for submit" event. >>> >>> The exception occurs in scope of a POST request that submits data to this >>> form. The exception message states: >>> >>> Failure writing parameter 'value' of component >>> MyPortal:portalindex.portalsearchform.globalsport: Property 'formData' >>> (within property expression 'formData.globalSportId', of >>> cz.ftm.fitsoftware.webapp.components.PortalSearchForm@3262579e) is null. >>> >>> I have no idea how this happens. How can the property formData be >>> uninitialized? It seems that the method prepareForSubmit is not called. >>> >>> Thanks for help. >>> Jarda >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> <javascript:;> >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> <javascript:;> >>> >>> >> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org