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

Qute: Incorrect behaviour with complex expressions #23286

Closed
kucharzyk opened this issue Jan 30, 2022 · 2 comments · Fixed by #23301
Closed

Qute: Incorrect behaviour with complex expressions #23286

kucharzyk opened this issue Jan 30, 2022 · 2 comments · Fixed by #23301
Assignees
Labels
area/qute The template engine kind/bug Something isn't working
Milestone

Comments

@kucharzyk
Copy link
Contributor

Describe the bug

I've created bean Validation for validation purposes

@RequestScoped
@Named("Validation")
public class Validation {

    public boolean hasViolations(String field) {
       // implementation details
    }

    public List<String> getViolations(String field) {
       // implementation details
    }
}

I've tried to use method getViolations in my tag

{@java.lang.String field}
{#if inject:Validation.hasViolations(field)}
    <div class="mb-3 alert alert-danger d-flex align-items-center" role="alert">
        <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Danger:">
            <use xlink:href="#exclamation-triangle-fill"/>
        </svg>
        {#each inject:Validation.getViolations(field)}
        <div>{it}</div>
        {/each}
    </div>
{/if}

And I've got the following exception:

io.quarkus.qute.TemplateException: Found template problems (1):
[1] Incorrect expression found: {field}
        - Unsupported iterable type found: java.lang.String
        - at tags/validation.html:8

It works only with small workaround (define local variable using let)

{@java.lang.String field}
{#if inject:Validation.hasViolations(field)}
    <div class="mb-3 alert alert-danger d-flex align-items-center" role="alert">
        <svg class="bi flex-shrink-0 me-2" width="24" height="24" role="img" aria-label="Danger:">
            <use xlink:href="#exclamation-triangle-fill"/>
        </svg>
        {#let violations=inject:Validation.getViolations(field)}
        {#each violations}
        <div>{it}</div>
        {/each}
        {/let}
    </div>
{/if}

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@kucharzyk kucharzyk added the kind/bug Something isn't working label Jan 30, 2022
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 30, 2022

/cc @mkouba

@quarkus-bot quarkus-bot bot added the area/qute The template engine label Jan 30, 2022
@mkouba mkouba self-assigned this Jan 31, 2022
@mkouba mkouba added this to the 2.8 - main milestone Jan 31, 2022
mkouba added a commit to mkouba/quarkus that referenced this issue Jan 31, 2022
@mkouba
Copy link
Contributor

mkouba commented Jan 31, 2022

@kucharzyk this PR should fix the problem.

@gsmet gsmet modified the milestones: 2.8 - main, 2.7.1.Final Jan 31, 2022
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/qute The template engine kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants