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

UIData: do not limit children to be UIColumn only #1905

Open
Rapster opened this issue Mar 8, 2024 · 1 comment
Open

UIData: do not limit children to be UIColumn only #1905

Rapster opened this issue Mar 8, 2024 · 1 comment

Comments

@Rapster
Copy link

Rapster commented Mar 8, 2024

According to the spec:

Only children of type UIColumn should be processed by renderers associated with this component.

But why stop there? When what makes this component quite powerful is the "saving state per row algorithm"... It's gonna be a repeat of #1837, but in PrimeFaces we had to create a custom UIData to support other kind of children (like p:columns). Also, UIRepeat seem very similar to UIData and yet are two different component

IMO, the spec should "allow" UIData to have more children than just UIColumn so they can be processed. Also, it should handle cases where children is also UIData (that would solve this problem #1837 I think).

As a quick example what it could look like in UIData:

    private boolean visitColumnsAndColumnFacets(VisitContext context, VisitCallback callback, boolean visitRows) {
        if (visitRows) {
            setRowIndex(-1);
        }
        if (getChildCount() > 0) {
            for (UIComponent column : getChildren()) {
                if(column instanceof UIData) {
                    UIData child = (UIData) column;
                    for (int j = 0; j < child.getRowCount(); j++) {
                        child.setRowIndex(j);
                        boolean value = visitColumnFacets(context, callback, child);
                        if (value) {
                            child.setRowIndex(-1);
                            return true;
                        }
                    }
                    child.setRowIndex(-1);
                }
                else if (isEligibleChildren(column)) {
                    if (visitColumnFacets(context, callback, column)) {
                        return true;
                    }
                }
            }
        }

        return false;
    }

Where UIData#isEligibleChildren() returns whether or not children should be visited/processed etc. (where this method is protected and can be overrided)

WDYT?

@BalusC
Copy link
Member

BalusC commented May 18, 2024

UIData should also have a reusable superclass in API which is also shared with UIRepeat etc #963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants