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 <[email protected]> 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 <[email protected]>
> 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
>> 
>> 
>> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to