[ 
https://issues.apache.org/jira/browse/WICKET-6350?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15947630#comment-15947630
 ] 

ASF GitHub Bot commented on WICKET-6350:
----------------------------------------

GitHub user JoachimRohde opened a pull request:

    https://github.com/apache/wicket/pull/217

    [Fix] setRequired checked for primitive type only when the FormCompon…

    …ent was NOT required
    See https://issues.apache.org/jira/browse/WICKET-6350

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/JoachimRohde/wicket master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/wicket/pull/217.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #217
    
----
commit e0805a6e4c413875409e0301811e5097714be5ad
Author: JoachimRohde <[email protected]>
Date:   2017-03-29T16:17:52Z

    [Fix] setRequired checked for primitive type only when the FormComponent 
was NOT required

----


> setRequired checks for primitive type only when the FormComponent is NOT 
> required
> ---------------------------------------------------------------------------------
>
>                 Key: WICKET-6350
>                 URL: https://issues.apache.org/jira/browse/WICKET-6350
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 8.0.0-M4
>            Reporter: Joachim Rohde
>            Priority: Minor
>
> I was tinkering around with Kotlin and Wicket and had the following snippet:
>     val housenumbervalue: Int?  = null
>     val housenumberModel: IModel<Int> = Model<Int>()
>     val housenumber = TextField<Int>("housenumberModel", housenumberModel, 
> Int::class.java)
>     val form: Form<Unit> = object : Form<Unit>("adressForm") {}
>     override fun onInitialize() {
>         super.onInitialize()
>         form.add(housenumber.setRequired(false))
>         form.add(object : SubmitLink("submit") {
>             override fun onSubmit() {
>                 super.onSubmit()
>                 println(housenumberModel.`object`)
>             }
>         })
>         add(form)
>     }
> This code resulted in 
> org.apache.wicket.WicketRuntimeException: FormComponent can't be required 
> when the type is primitive class: [TextField [Component id = 
> housenumberModel]]
>      at 
> org.apache.wicket.markup.html.form.FormComponent.setRequired(FormComponent.java:1052)
>      at com.mycompany.test.web.pages.Test.onInitialize(Test.kt:28)
> Turns out that setRequired was checking only if the FormComponent was *not* 
> required. It should be the other way round. I opened a pull request.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to