jakartaee / faces

Jakarta Faces
Other
109 stars 55 forks source link

HTML link element rendered attribute is not applied if no identifying attributes exist #1790

Open codylerum opened 1 year ago

codylerum commented 1 year ago

The following works fine in JSF 2.3

<div jsf:rendered="#{false}">div NOT rendered</diiv>

<div jsf:rendered="#{true}">div IS rendered</diiv>

<p jsf:rendered="#{false}">p NOT rendered</diiv>

<p jsf:rendered="#{true}">p IS rendered</diiv>

<button type="button" jsf:rendered="#{false}">button NOT rendered</button>

<button type="button" jsf:rendered="#{true}">button is RENDERED</button>

However if the element is an <a> then the jsf:rendered is not applied if the element does not have something like an jsf:outcome or jsf:action for example:

<a href="http://www.google.com" jsf:rendered="#{false}" target="_blank">Renders</a>

<a jsf:outcome="foo" href="http://www.google.com" jsf:rendered="#{false}" target="_blank">Does not render</a>

Expected behavior

Would expect that the jsf:rendered attribute is applied to any html element. It appears that the <a> element is being treated differently.

https://github.com/eclipse-ee4j/mojarra/issues/5212 was opened on this and it was determined that is is because the <a> could be handled by multiple components (h:link, h:commandButton, etc) and since there is no identifying attribute (jsf:action or jsf:outcome for example).

I would propose that if no identifying attribute is found then it should be treated like any other html element (like a div) and the jsf:rendered should still be considered. Otherwise this is confusing and can lead to elements being rendered to the user unexpectedly.

BalusC commented 1 year ago

+1