Hi Barry,

thanks for nice hint.
I cannot fix it so simply just by adding this one-line method but it shows the 
way to go anyway.

This pattern (form data groupped in DTO, simple initialization for POST 
requests in prepare for submit handler, more complex initialization for GET 
requests in prepare for render handler) is used about hundred times in our app 
but it produces this rare exception just in case of this form.

I wonder, how can such error occur anyway. I can even hardly think of some 
hypothesis that would explain such behavior.

Is it possible, that the parameter t:formdata is malformed in the POST request 
and "prepare for render" event is not triggered? However, I am in doubt whether 
this hypothesis makes  sense.

I have reproduced the issue in a very strange way. I have filled the form in 
the browser and submitted but I have also manually modified the POST request 
parameters before sending it to the server (via Firefox plugin Tamper Data). I 
have replaced the value of t:formdata (I know the parameter values of the 
request that caused the exception in production environment as our app reports 
exceptions via email in such case) and I have also removed the value of the 
parameter t:submit.

Jarda


> On May25, 2016, at 12:37, 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

Reply via email to