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

Parameterized Includes fails for granite:hide #3349

Open
3 tasks
HitmanInWis opened this issue May 29, 2024 · 2 comments
Open
3 tasks

Parameterized Includes fails for granite:hide #3349

HitmanInWis opened this issue May 29, 2024 · 2 comments

Comments

@HitmanInWis
Copy link
Contributor

Required Information

  • AEM Version, including Service Packs, Cumulative Fix Packs, etc: AEM Cloud Service
  • ACS AEM Commons Version: 6.6.0
  • Reproducible on Latest? yes

Expected Behavior

When I use the Parameterized Include feature (https://adobe-consulting-services.github.io/acs-aem-commons/features/parameterized-namespace-include/subpages/parameter-example.html) I expect to be able to use variables for the granite:hide property so that the parent dialog that is including a dialog snippet can signal to hide certain fields.

Actual Behavior

Putting a variable of ${{myvar}} into the granite:hide attribute causes the dialog to fail to load, with a stack trace that looks like the following.

javax.el.ELException: Failed to parse the expression [${{hideLinkText}}]
	at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:146) [com.adobe.granite.ui.commons:5.10.36]
	at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:172) [com.adobe.granite.ui.commons:5.10.36]
	at org.apache.el.lang.ExpressionBuilder.createValueExpression(ExpressionBuilder.java:218) [com.adobe.granite.ui.commons:5.10.36]
	at org.apache.el.ExpressionFactoryImpl.createValueExpression(ExpressionFactoryImpl.java:68)
	at com.adobe.granite.ui.components.impl.el.ExpressionResolverImpl.resolve(ExpressionResolverImpl.java:128) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.ExpressionHelper.get(ExpressionHelper.java:144) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.ExpressionHelper.get(ExpressionHelper.java:123) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.ExpressionHelper.getBoolean(ExpressionHelper.java:83) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.FilteringResourceWrapper.isVisible(FilteringResourceWrapper.java:158) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.FilteringResourceWrapper.access$000(FilteringResourceWrapper.java:85) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.FilteringResourceWrapper$2.evaluate(FilteringResourceWrapper.java:115) [com.adobe.granite.ui.commons:5.10.36]
	at com.adobe.granite.ui.components.FilteringResourceWrapper$2.evaluate(FilteringResourceWrapper.java:112) [com.adobe.granite.ui.commons:5.10.36]
	at org.apache.commons.collections4.iterators.FilterIterator.setNextObject(FilterIterator.java:176) [org.apache.commons.commons-collections4:4.4.0]
	at org.apache.commons.collections4.iterators.FilterIterator.hasNext(FilterIterator.java:86) [org.apache.commons.commons-collections4:4.4.0]
	at org.apache.commons.collections4.iterators.TransformIterator.hasNext(TransformIterator.java:74) [org.apache.commons.commons-collections4:4.4.0]
	at org.apache.commons.collections4.iterators.FilterIterator.setNextObject(FilterIterator.java:174) [org.apache.commons.commons-collections4:4.4.0]
	at org.apache.commons.collections4.iterators.FilterIterator.hasNext(FilterIterator.java:86) [org.apache.commons.commons-collections4:4.4.0]
	at org.apache.commons.collections4.iterators.TransformIterator.hasNext(TransformIterator.java:74) [org.apache.commons.commons-collections4:4.4.0]
	at org.apache.commons.collections.iterators.FilterIterator.setNextObject(FilterIterator.java:183) [org.apache.commons.collections:3.2.2]
	at org.apache.commons.collections.iterators.FilterIterator.hasNext(FilterIterator.java:94) [org.apache.commons.collections:3.2.2]
	at org.apache.commons.collections.iterators.TransformIterator.hasNext(TransformIterator.java:76) [org.apache.commons.collections:3.2.2]
	at org.apache.commons.collections4.iterators.ListIteratorWrapper.hasNext(ListIteratorWrapper.java:114) [org.apache.commons.commons-collections4:4.4.0]
	at libs.granite.ui.components.foundation.layouts.container.container__002e__jsp._jspService(container__002e__jsp.java:145) [aem-precompiled-scripts:1.0.20240418]

It appears that the granite:hide attribute is evaluated prior to com.adobe.acs.commons.granite.ui.components.NamespacedTransformedResourceProvider#transformResourceWithNameSpacing getting a chance to transform the variables. I validated this in a debugger, where the function is not called at all for my field when a parameterized var is in granite:hide. I also hacked the value of granite:hide from NamespacedTransformedResourceProvider via the debugger with "true" and my field was still not hidden, further backing the theory that granite:hide is processed prior to NamespacedTransformedResourceProvider executing to transform variables.

Steps to Reproduce

Simply use a parameterized variable in a child dialog snippet within the granite:hide property of a dialog field.

cc: @niekraaijmakers

@HitmanInWis
Copy link
Contributor Author

FWIW seems similar issues exist trying to use parameterized vars within granite:class and granite:data attributes as well.

@HitmanInWis
Copy link
Contributor Author

For modern versions of AEM, I wonder if this feature could/should be reworked to use ExpressionCustomizer?

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