Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputNumber: Number identified as non-decimal #11791

Closed
melloware opened this issue Apr 22, 2024 · 0 comments · Fixed by #11792
Closed

InputNumber: Number identified as non-decimal #11791

melloware opened this issue Apr 22, 2024 · 0 comments · Fixed by #11792
Assignees
Labels
🐞 defect Bug...Something isn't working
Milestone

Comments

@melloware
Copy link
Member

Describe the bug

a PRO reported an issue related to InputNumberRenderer.isIntegral method. Will we add decimal type checks for Number type?

// InputNumberRenderer.java
private boolean isIntegral(FacesContext context, InputNumber inputNumber, Object value) {
        if (value != null) {
            return value instanceof Long
                    || value instanceof Integer
                    || value instanceof Short
                    || value instanceof BigInteger
                    || value instanceof Byte;
        }

        Class<?> type = getTypeFromValueExpression(context, inputNumber);
        if (type == null) {
            return false;
        }

        return type.isAssignableFrom(Long.class)
                || type.isAssignableFrom(Integer.class)
                || type.isAssignableFrom(Short.class)
                || type.isAssignableFrom(BigInteger.class)
                || type.isAssignableFrom(Byte.class);
    }

As you know, java.lang.Number is a superclass of Integer, Long, Short, [...].
Since the upgrade from 11.0.7 to 13.0.8 we face the issue that p:inputNumber defaults to 0 decimalPlaces when using a java.lang.Number (initial value null) as value.
This seems to happen because the check for integral, with a null value, tests for "isAssignableFrom(Integer.class)" etc.
Thus, it returns true, even though java.lang.Number can have decimalPlaces.

Reproducer

private Number number;
<p:inputNumber value="#{testView.number}" />

Expected behavior

No response

PrimeFaces edition

Community

PrimeFaces version

13.0.8

Theme

No response

JSF implementation

Mojarra

JSF version

2.3

Java version

11

Browser(s)

No response

@melloware melloware added 🐞 defect Bug...Something isn't working ‼️ needs-triage Issue needs triaging and removed ‼️ needs-triage Issue needs triaging labels Apr 22, 2024
@melloware melloware self-assigned this Apr 22, 2024
@melloware melloware added this to the 13.0.9 milestone Apr 22, 2024
melloware added a commit to melloware/primefaces that referenced this issue Apr 22, 2024
melloware added a commit to melloware/primefaces that referenced this issue Apr 22, 2024
melloware added a commit that referenced this issue Apr 23, 2024
* Fix #11791: 13.0.9 InputNumber all Number.class to be decimal

* Update InputNumberTest.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 defect Bug...Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant