You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2017/04/04 19:34:41 UTC

[jira] [Commented] (WICKET-6350) setRequired checks for primitive type only when the FormComponent is NOT required

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

ASF subversion and git services commented on WICKET-6350:
---------------------------------------------------------

Commit c3e475e2e813165968c42f7f71969ba459e6740d in wicket's branch refs/heads/wicket-7.x from [~svenmeier]
[ https://git-wip-us.apache.org/repos/asf?p=wicket.git;h=c3e475e ]

WICKET-6350 corrected error message

> 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
>            Assignee: Sven Meier
>            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)