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:;>
>
>

Reply via email to