You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "David Rain (Jira)" <ji...@apache.org> on 2019/10/10 11:26:01 UTC

[jira] [Comment Edited] (WICKET-6707) Property setter parameter type is assumed to be equal to getter return type

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

David Rain edited comment on WICKET-6707 at 10/10/19 11:25 AM:
---------------------------------------------------------------

[~mgrigorov] I think it should have been changed here:
{code:java}
if (setMethod != null)
{
	// getMethod is always there and if the value will be set through a setMethod then
	// the getMethod return type will be its type. Else we have to look at the
	// parameters if the setter but getting the return type is quicker
	type = getMethod.getReturnType();
}
{code}
Because the type variable is also used during the convert call
{code:java}
if (type != null)
{
    converted = converter.convert(value, type);
{code}
And the convert method should also be called with the correct type of the setter parameter.


was (Author: davesman):
[~mgrigorov] I think I should have been changed here:
{code:java}
if (setMethod != null)
{
	// getMethod is always there and if the value will be set through a setMethod then
	// the getMethod return type will be its type. Else we have to look at the
	// parameters if the setter but getting the return type is quicker
	type = getMethod.getReturnType();
}
{code}
Because the type variable is also used during the convert call
{code:java}
if (type != null)
{
    converted = converter.convert(value, type);
{code}
And the convert method should also be called with the correct type of the setter parameter.

> Property setter parameter type is assumed to be equal to getter return type
> ---------------------------------------------------------------------------
>
>                 Key: WICKET-6707
>                 URL: https://issues.apache.org/jira/browse/WICKET-6707
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket-core
>    Affects Versions: 8.6.1
>            Reporter: David Rain
>            Assignee: Martin Tzvetanov Grigorov
>            Priority: Major
>             Fix For: 8.7.0, 9.0.0-M4, 7.16.0
>
>
> I am getting error: *Method [public boolean cz.kb.dcs.module_transaction.api.data_objects.cexi.TransactionFormItem.isInstantPayment()]. Can't convert null value to a primitive class: boolean*
> This is due to
> {code:java}
> if (setMethod != null) {
>     // getMethod is always there and if the value will be set through a setMethod then
>     // the getMethod return type will be its type. Else we have to look at the
>     // parameters if the setter but getting the return type is quicker
>     type = getMethod.getReturnType();
> }
> {code}
> I have this getter and setter:
> {code:java}
> public boolean isInstantPayment() {
>     return instantPayment == null ? false : instantPayment.booleanValue();
> }
> public void setInstantPayment(final Boolean instantPayment) {
>     this.instantPayment = instantPayment;
> }
> {code}
> So setting NULL *would be possible* (the property itself is object Boolean). Although it is not according to Java Beans specification.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)