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

Revert or fix #5417 and release a new 4.0.x version #5460

Closed
filipeferraz opened this issue Jul 15, 2024 · 1 comment
Closed

Revert or fix #5417 and release a new 4.0.x version #5460

filipeferraz opened this issue Jul 15, 2024 · 1 comment
Milestone

Comments

@filipeferraz
Copy link

filipeferraz commented Jul 15, 2024

Describe the bug

The change implemented in jakarta.faces-4.0.7.jar broke reading the default attribute value in composite components with default value in xhtml template.

Reading UIComponentBase.getAttributes().get("attribute") returns null if the attribute is not redefined at the xhtml page with componente usage (always need to redefine, ignores the default value defined in custom componente template).

To Reproduce

Steps to reproduce the behavior:

  1. Create a composite component with a basic property:
    <cc:attribute name="customRole" required="false" default="user" type="java.lang.String" />
  2. Use in a xhtml page without configuring customRole.
  3. Try to read in java class of the component this.getAttributes().get("customRole").
  4. See error

Expected behavior

It's expected to get the default value for the attribute.

Screenshots

Desktop (please complete the following information):

  • OS: Manjaro Linux
  • Browser: Chrome
  • Version: 126.0.6478.126

Additional context

Bug found using Wildfly 32.0.1.Final. Rolling back to jakarta.faces-4.0.6.jar keeps the component working.

customComponent.xhtml:

<ui:component
	    xmlns="http://www.w3.org/1999/xhtml"
		xmlns:h="jakarta.faces.html"
		xmlns:ui="jakarta.faces.facelets"
	    xmlns:cc="jakarta.faces.composite"
		xmlns:f="jakarta.faces.core">
    <cc:interface componentType="customComponent">
		<cc:attribute name="customRole" required="false" default="user" type="java.lang.String" />
    </cc:interface>
    <cc:implementation>
        <h:outputText value="Role"/>
		<h:commandButton action="#{cc.action}" value="Action"/>
    </cc:implementation>
</ui:component>

CustomComponent.java:

import jakarta.faces.component.FacesComponent;
import jakarta.faces.component.UINamingContainer;

import java.util.ArrayList;
import java.util.List;

@FacesComponent("customComponent")
public class CustomComponent extends UINamingContainer {	

	public List<String> action() {
		System.out.println(getAttributes().get("customRole"));
		return new ArrayList<>();
	}
}
@filipeferraz
Copy link
Author

Tested with a compiled version of the branch mojarra_issue_5460 and the fix works (replaced the Widlfly 32.0.1.Final module jar).

It's possible to include in 4.0.8 milestone?

Thanks @BalusC

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