문제

e.g.

class TestAction
{
    @Getter @Setter
    Boolean enabled;// null for both
}

HTML

<input type='radio' name="enabled" value='true'> enabled
<input type='radio' name="enabled" value='false'> disabled
<input type='radio' name="enabled" value='null'> both
<!-- value=null will convert to false -->

How can I pass null for Boolean ?

UPDATE

Answer is impossible. I use another way below.

도움이 되었습니까?

해결책

My way to around this.

@Data // Generate all setter and getter.
public class UserSearchCondition implements ISearchCondition
{
    private String enabled = null;

    public Boolean isEnabled()
    {
        if (Strings.isNullOrEmpty(enabled) || enabled.toLowerCase().equals("null"))
            return null;
        return Boolean.valueOf(enabled);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top