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

Extend Attribute annotation to support boolean attributes #1850

Open
stefanuebe opened this issue Jan 17, 2025 · 1 comment
Open

Extend Attribute annotation to support boolean attributes #1850

stefanuebe opened this issue Jan 17, 2025 · 1 comment

Comments

@stefanuebe
Copy link

stefanuebe commented Jan 17, 2025

The @Attribute annotation allows TB elements to specify the query by specific attributes. Unfortunately it does not support boolean attributes, like for instance has-value on fields or similar. Setting "true" or the attribute name itself as value does not work.

Therefore the request is, that there should be a new parameter value "booleanValue", that has a type of a new enum BooleanAttributeValue.

That enum consists of the items

  • UNUSED
  • TRUE
  • FALSE

The value UNUSED is the default and marks that parameter as "ignore me", like the other parameter defaults do. Using TRUE or FALSE instead will mark the parameter as set and thus ignore the other parameters value and contains.

Depending on TRUE or FALSE the respective attribute will be interpreted as "is explicitly set" or "is explicitly not set", like ElementQuery#withAttribute(String) / withoutAttribute(String) would do.

A use case we have: find all grids, that are not tree grids and vice versa. (but I assume, there are many many more out there)

@Attribute(name = "hierarchical", booleanValue = TRUE) 
public class CustomGridElement extends GridElement
@Attribute(name = "hierarchical", booleanValue = FALSE) 
public class CustomTreeGridElement extends TreeGridElement
@stefanuebe
Copy link
Author

Our current workaround is to write the boolean value as a string and then interprete that string. But that leads to ugly html and does not cover the case of "the attribute is explicitly not set".

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

1 participant