You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by D Tim Cummings <ti...@triptera.com.au> on 2014/11/17 12:39:25 UTC
5.4 beta 22 - Select component secure="auto" throws exception: model is bound to null.
I am trying to understand the new attribute "secure" of the "select" component. This is either a bug or I don’t understand the attribute. I am running Tapestry 5.4 beta 22.
I have copied the code from the Jumpstart7 AJAX filtered grid example where firstInitials is a List<String> created in the setupRender() method.
http://jumpstart.doublenegative.com.au/jumpstart7/examples/ajax/filteredgrid <http://jumpstart.doublenegative.com.au/jumpstart7/examples/ajax/filteredgrid>
The example uses secure="never" and works. However if I use secure="auto" as in
<t:select t:id="firstInitial" model="firstInitials" onchange="document.getElementById('filterSubmit').click()" secure="auto" />
then I get the error message
org.apache.tapestry5.ioc.internal.util.TapestryException
Parameter 'model' of component Contact:firstinitial is bound to null. This parameter is not allowed to be null.
with stack trace
Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException: Parameter 'model' of component Contact:firstinitial is bound to null. This parameter is not allowed to be null. [at classpath:au/com/createng/job/pages/Contact.tml, line 8]
at org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:275)
at org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
at org.apache.tapestry5.corelib.components.Select.conduit_get_model(Select.java)
at org.apache.tapestry5.corelib.components.Select.toValue(Select.java:292)
at org.apache.tapestry5.corelib.components.Select.processSubmission(Select.java:200)
at org.apache.tapestry5.corelib.base.AbstractField.processSubmission(AbstractField.java:260)
at org.apache.tapestry5.corelib.base.AbstractField.access$100(AbstractField.java:41)
at org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:103)
at org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:97)
at org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:739)
... 100 more
This is a really bad error message because it took me ages to realise it was because of the change I had made to the secure attribute (which I had removed thinking that it was something to do with https). I get the same exception if I leave the attribute out completely. Yet looking at the source code for Select.java, the default should be select="auto" and allow the model to be null.
/**
* Controls whether the submitted value is validated to be one of the values in
* the {@link SelectModel}. If "never", then no such validation is performed,
* theoretically allowing a selection to be made that was not presented to
* the user. Note that an "always" value here requires the SelectModel to
* still exist (or be created again) when the form is submitted, whereas a
* "never" value does not. Defaults to "auto", which causes the validation
* to occur only if the SelectModel is present (not null) when the form is
* submitted.
*
* @since 5.4
*/
@Parameter(value = BindingConstants.SYMBOL + ":" + ComponentParameterConstants.VALIDATE_WITH_MODEL, defaultPrefix = BindingConstants.LITERAL)
private SecureOption secure;
This appears to be related to the bug
https://issues.apache.org/jira/browse/TAP5-2204 <https://issues.apache.org/jira/browse/TAP5-2204> Select component fails if SelectModel doesn't exist on submit
which was resolved in November last year.
Regards
Tim
Re: 5.4 beta 22 - Select component secure="auto" throws exception:
model is bound to null.
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 17 Nov 2014 19:59:52 -0200, D Tim Cummings <ti...@triptera.com.au>
wrote:
> Thanks Charlouze. This sums up the problem nicely. I have added your
> comment to https://issues.apache.org/jira/browse/TAP5-2204
> <https://issues.apache.org/jira/browse/TAP5-2204> which was supposed to
> resolve this issue but hasn’t. Someone needs to reopen this jira issue.
I've reopened it.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.4 beta 22 - Select component secure="auto" throws exception:
model is bound to null.
Posted by Charlouze <me...@charlouze.com>.
I ran into this problem this morning too. I did my investigation in order
to post a mail later but I found yours first.
2014-11-17 22:59 GMT+01:00 D Tim Cummings <ti...@triptera.com.au>:
> Thanks Charlouze. This sums up the problem nicely. I have added your
> comment to https://issues.apache.org/jira/browse/TAP5-2204 <
> https://issues.apache.org/jira/browse/TAP5-2204> which was supposed to
> resolve this issue but hasn’t. Someone needs to reopen this jira issue.
>
> Tim
>
>
>
> > On 18 Nov 2014, at 03:14, Charlouze <me...@charlouze.com> wrote:
> >
> > I agree with Tim. Documentation says that the default is auto and does
> not
> > require the model to be set in order to pass the submission process.
> >
> > I think it's a bug. As you can see in the select component code
> > <
> https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java#L284-306
> >
> > (line
> > 292), if the secure option is set to AUTO and the model is null then the
> > form doesn't validate the options against the select model. But the
> problem
> > is that the model parameter
> > <
> https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java#L107-108
> >
> > doesn't allow null value. That's also why the error is confusing, it
> cannot
> > reach line 300 in the toValue method which would throw a much clearer
> error.
> >
> > 2014-11-17 17:44 GMT+01:00 Thiago H de Paula Figueiredo <
> thiagohp@gmail.com>
> > :
> >
> >> On Mon, 17 Nov 2014 10:41:20 -0200, D Tim Cummings <tim@triptera.com.au
> >
> >> wrote:
> >>
> >> Thanks. That wasn’t my question but it does help me. With
> >>> secure="always", I would need the model for render and form
> submission. So
> >>> according to what you are saying I could init the model in
> onActivate() OR
> >>> onPrepare() OR (onPrepareForSubmit() AND setupRender()).
> >>>
> >>
> >> I'd use onPrepare(), as it's the only one that always gets invoked when
> >> rendering and before handling form submissions.
> >>
> >> Or just have a getter that inits and returns the model. That's what I
> >> usually do.
> >>
> >> My actual question is why do I need to init the model in one of these
> >>> methods for secure="auto" or the default secure attribute (which is
> >>> supposed to be backward compatible)?
> >>>
> >>
> >> This is done so Select never gives a value to your edited property that
> >> isn't in the list of valid value (SelectModel).
> >>
> >> --
> >> Thiago H. de Paula Figueiredo
> >> Tapestry, Java and Hibernate consultant and developer
> >> http://machina.com.br
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
>
>
Re: 5.4 beta 22 - Select component secure="auto" throws exception: model is bound to null.
Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks Charlouze. This sums up the problem nicely. I have added your comment to https://issues.apache.org/jira/browse/TAP5-2204 <https://issues.apache.org/jira/browse/TAP5-2204> which was supposed to resolve this issue but hasn’t. Someone needs to reopen this jira issue.
Tim
> On 18 Nov 2014, at 03:14, Charlouze <me...@charlouze.com> wrote:
>
> I agree with Tim. Documentation says that the default is auto and does not
> require the model to be set in order to pass the submission process.
>
> I think it's a bug. As you can see in the select component code
> <https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java#L284-306>
> (line
> 292), if the secure option is set to AUTO and the model is null then the
> form doesn't validate the options against the select model. But the problem
> is that the model parameter
> <https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java#L107-108>
> doesn't allow null value. That's also why the error is confusing, it cannot
> reach line 300 in the toValue method which would throw a much clearer error.
>
> 2014-11-17 17:44 GMT+01:00 Thiago H de Paula Figueiredo <th...@gmail.com>
> :
>
>> On Mon, 17 Nov 2014 10:41:20 -0200, D Tim Cummings <ti...@triptera.com.au>
>> wrote:
>>
>> Thanks. That wasn’t my question but it does help me. With
>>> secure="always", I would need the model for render and form submission. So
>>> according to what you are saying I could init the model in onActivate() OR
>>> onPrepare() OR (onPrepareForSubmit() AND setupRender()).
>>>
>>
>> I'd use onPrepare(), as it's the only one that always gets invoked when
>> rendering and before handling form submissions.
>>
>> Or just have a getter that inits and returns the model. That's what I
>> usually do.
>>
>> My actual question is why do I need to init the model in one of these
>>> methods for secure="auto" or the default secure attribute (which is
>>> supposed to be backward compatible)?
>>>
>>
>> This is done so Select never gives a value to your edited property that
>> isn't in the list of valid value (SelectModel).
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
Re: 5.4 beta 22 - Select component secure="auto" throws exception:
model is bound to null.
Posted by Charlouze <me...@charlouze.com>.
I agree with Tim. Documentation says that the default is auto and does not
require the model to be set in order to pass the submission process.
I think it's a bug. As you can see in the select component code
<https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java#L284-306>
(line
292), if the secure option is set to AUTO and the model is null then the
form doesn't validate the options against the select model. But the problem
is that the model parameter
<https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Select.java#L107-108>
doesn't allow null value. That's also why the error is confusing, it cannot
reach line 300 in the toValue method which would throw a much clearer error.
2014-11-17 17:44 GMT+01:00 Thiago H de Paula Figueiredo <th...@gmail.com>
:
> On Mon, 17 Nov 2014 10:41:20 -0200, D Tim Cummings <ti...@triptera.com.au>
> wrote:
>
> Thanks. That wasn’t my question but it does help me. With
>> secure="always", I would need the model for render and form submission. So
>> according to what you are saying I could init the model in onActivate() OR
>> onPrepare() OR (onPrepareForSubmit() AND setupRender()).
>>
>
> I'd use onPrepare(), as it's the only one that always gets invoked when
> rendering and before handling form submissions.
>
> Or just have a getter that inits and returns the model. That's what I
> usually do.
>
> My actual question is why do I need to init the model in one of these
>> methods for secure="auto" or the default secure attribute (which is
>> supposed to be backward compatible)?
>>
>
> This is done so Select never gives a value to your edited property that
> isn't in the list of valid value (SelectModel).
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: 5.4 beta 22 - Select component secure="auto" throws exception: model is bound to null.
Posted by D Tim Cummings <ti...@triptera.com.au>.
> On 18 Nov 2014, at 02:44, Thiago H de Paula Figueiredo <th...@gmail.com> wrote:
>
> On Mon, 17 Nov 2014 10:41:20 -0200, D Tim Cummings <ti...@triptera.com.au> wrote:
>
>> Thanks. That wasn’t my question but it does help me. With secure="always", I would need the model for render and form submission. So according to what you are saying I could init the model in onActivate() OR onPrepare() OR (onPrepareForSubmit() AND setupRender()).
>
> I'd use onPrepare(), as it's the only one that always gets invoked when rendering and before handling form submissions.
>
> Or just have a getter that inits and returns the model. That's what I usually do.
Thanks Thiago. I will follow this advice.
>
>> My actual question is why do I need to init the model in one of these methods for secure="auto" or the default secure attribute (which is supposed to be backward compatible)?
>
> This is done so Select never gives a value to your edited property that isn't in the list of valid value (SelectModel).
I can understand this for secure="always". It doesn’t make sense for secure="auto"
Tim
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.4 beta 22 - Select component secure="auto" throws exception:
model is bound to null.
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 17 Nov 2014 10:41:20 -0200, D Tim Cummings <ti...@triptera.com.au>
wrote:
> Thanks. That wasn’t my question but it does help me. With
> secure="always", I would need the model for render and form submission.
> So according to what you are saying I could init the model in
> onActivate() OR onPrepare() OR (onPrepareForSubmit() AND setupRender()).
I'd use onPrepare(), as it's the only one that always gets invoked when
rendering and before handling form submissions.
Or just have a getter that inits and returns the model. That's what I
usually do.
> My actual question is why do I need to init the model in one of these
> methods for secure="auto" or the default secure attribute (which is
> supposed to be backward compatible)?
This is done so Select never gives a value to your edited property that
isn't in the list of valid value (SelectModel).
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: 5.4 beta 22 - Select component secure="auto" throws exception: model is bound to null.
Posted by D Tim Cummings <ti...@triptera.com.au>.
Thanks. That wasn’t my question but it does help me. With secure="always", I would need the model for render and form submission. So according to what you are saying I could init the model in onActivate() OR onPrepare() OR (onPrepareForSubmit() AND setupRender()).
My actual question is why do I need to init the model in one of these methods for secure="auto" or the default secure attribute (which is supposed to be backward compatible)?
Tim
> On 17 Nov 2014, at 22:25, Chris Poulsen <ma...@nesluop.dk> wrote:
>
> If you init your model in setupRender it will be null upon form submit (as
> it is not a render request) - You can use onActivate, onPrepareForSubmit or
> onPrepare to init the model prior to form submission.
>
> --
> Chris
>
> On Mon, Nov 17, 2014 at 12:39 PM, D Tim Cummings <ti...@triptera.com.au>
> wrote:
>
>> I am trying to understand the new attribute "secure" of the "select"
>> component. This is either a bug or I don’t understand the attribute. I am
>> running Tapestry 5.4 beta 22.
>>
>> I have copied the code from the Jumpstart7 AJAX filtered grid example
>> where firstInitials is a List<String> created in the setupRender() method.
>>
>>
>> http://jumpstart.doublenegative.com.au/jumpstart7/examples/ajax/filteredgrid
>>
>> The example uses secure="never" and works. However if I use secure="auto"
>> as in
>>
>> <t:select t:id="firstInitial" model="firstInitials" onchange=
>> "document.getElementById('filterSubmit').click()" secure="auto" />
>>
>> then I get the error message
>> org.apache.tapestry5.ioc.internal.util.TapestryException
>>
>> *Parameter 'model' of component Contact:firstinitial is bound to null.
>> This parameter is not allowed to be null.*
>> with stack trace
>>
>> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
>> Parameter 'model' of component Contact:firstinitial is bound to null. This
>> parameter is not allowed to be null. [at
>> classpath:au/com/createng/job/pages/Contact.tml, line 8]
>> at
>> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:275)
>> at
>> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
>> at
>> org.apache.tapestry5.corelib.components.Select.conduit_get_model(Select.java)
>> at org.apache.tapestry5.corelib.components.Select.toValue(Select.java:292)
>> at
>> org.apache.tapestry5.corelib.components.Select.processSubmission(Select.java:200)
>> at
>> org.apache.tapestry5.corelib.base.AbstractField.processSubmission(AbstractField.java:260)
>> at
>> org.apache.tapestry5.corelib.base.AbstractField.access$100(AbstractField.java:41)
>> at
>> org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:103)
>> at
>> org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:97)
>> at
>> org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:739)
>> ... 100 more
>>
>>
>> This is a really bad error message because it took me ages to realise it
>> was because of the change I had made to the secure attribute (which I had
>> removed thinking that it was something to do with https). I get the same
>> exception if I leave the attribute out completely. Yet looking at the
>> source code for Select.java, the default should be select="auto" and allow
>> the model to be null.
>>
>> /**
>> * Controls whether the submitted value is validated to be one of the
>> values in
>> * the {@link SelectModel}. If "never", then no such validation is
>> performed,
>> * theoretically allowing a selection to be made that was not
>> presented to
>> * the user. Note that an "always" value here requires the
>> SelectModel to
>> * still exist (or be created again) when the form is submitted,
>> whereas a
>> * "never" value does not. Defaults to "auto", which causes the
>> validation
>> * to occur only if the SelectModel is present (not null) when the
>> form is
>> * submitted.
>> *
>> * @since 5.4
>> */
>> @Parameter(value = BindingConstants.SYMBOL + ":" +
>> ComponentParameterConstants.VALIDATE_WITH_MODEL, defaultPrefix =
>> BindingConstants.LITERAL)
>> private SecureOption secure;
>>
>> This appears to be related to the bug
>>
>> https://issues.apache.org/jira/browse/TAP5-2204 Select component fails if
>> SelectModel doesn't exist on submit
>>
>> which was resolved in November last year.
>>
>> Regards
>>
>> Tim
>>
>>
>>
Re: 5.4 beta 22 - Select component secure="auto" throws exception:
model is bound to null.
Posted by Chris Poulsen <ma...@nesluop.dk>.
If you init your model in setupRender it will be null upon form submit (as
it is not a render request) - You can use onActivate, onPrepareForSubmit or
onPrepare to init the model prior to form submission.
--
Chris
On Mon, Nov 17, 2014 at 12:39 PM, D Tim Cummings <ti...@triptera.com.au>
wrote:
> I am trying to understand the new attribute "secure" of the "select"
> component. This is either a bug or I don’t understand the attribute. I am
> running Tapestry 5.4 beta 22.
>
> I have copied the code from the Jumpstart7 AJAX filtered grid example
> where firstInitials is a List<String> created in the setupRender() method.
>
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/ajax/filteredgrid
>
> The example uses secure="never" and works. However if I use secure="auto"
> as in
>
> <t:select t:id="firstInitial" model="firstInitials" onchange=
> "document.getElementById('filterSubmit').click()" secure="auto" />
>
> then I get the error message
> org.apache.tapestry5.ioc.internal.util.TapestryException
>
> *Parameter 'model' of component Contact:firstinitial is bound to null.
> This parameter is not allowed to be null.*
> with stack trace
>
> Caused by: org.apache.tapestry5.ioc.internal.util.TapestryException:
> Parameter 'model' of component Contact:firstinitial is bound to null. This
> parameter is not allowed to be null. [at
> classpath:au/com/createng/job/pages/Contact.tml, line 8]
> at
> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.readFromBinding(ParameterWorker.java:275)
> at
> org.apache.tapestry5.internal.transform.ParameterWorker$3$1.get(ParameterWorker.java:381)
> at
> org.apache.tapestry5.corelib.components.Select.conduit_get_model(Select.java)
> at org.apache.tapestry5.corelib.components.Select.toValue(Select.java:292)
> at
> org.apache.tapestry5.corelib.components.Select.processSubmission(Select.java:200)
> at
> org.apache.tapestry5.corelib.base.AbstractField.processSubmission(AbstractField.java:260)
> at
> org.apache.tapestry5.corelib.base.AbstractField.access$100(AbstractField.java:41)
> at
> org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:103)
> at
> org.apache.tapestry5.corelib.base.AbstractField$ProcessSubmission.execute(AbstractField.java:97)
> at
> org.apache.tapestry5.corelib.components.Form.executeStoredActions(Form.java:739)
> ... 100 more
>
>
> This is a really bad error message because it took me ages to realise it
> was because of the change I had made to the secure attribute (which I had
> removed thinking that it was something to do with https). I get the same
> exception if I leave the attribute out completely. Yet looking at the
> source code for Select.java, the default should be select="auto" and allow
> the model to be null.
>
> /**
> * Controls whether the submitted value is validated to be one of the
> values in
> * the {@link SelectModel}. If "never", then no such validation is
> performed,
> * theoretically allowing a selection to be made that was not
> presented to
> * the user. Note that an "always" value here requires the
> SelectModel to
> * still exist (or be created again) when the form is submitted,
> whereas a
> * "never" value does not. Defaults to "auto", which causes the
> validation
> * to occur only if the SelectModel is present (not null) when the
> form is
> * submitted.
> *
> * @since 5.4
> */
> @Parameter(value = BindingConstants.SYMBOL + ":" +
> ComponentParameterConstants.VALIDATE_WITH_MODEL, defaultPrefix =
> BindingConstants.LITERAL)
> private SecureOption secure;
>
> This appears to be related to the bug
>
> https://issues.apache.org/jira/browse/TAP5-2204 Select component fails if
> SelectModel doesn't exist on submit
>
> which was resolved in November last year.
>
> Regards
>
> Tim
>
>
>