Skip to content

Commit

Permalink
Fix #2015: add FaceletContext#getCurrentInstance() convenience methods
Browse files Browse the repository at this point in the history
  • Loading branch information
BalusC committed Mar 1, 2025
1 parent 82adda8 commit 0956438
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions api/src/main/java/jakarta/faces/view/facelets/FaceletContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,30 @@ public abstract class FaceletContext extends ELContext {
*/
public static final String FACELET_CONTEXT_KEY = "jakarta.faces.FACELET_CONTEXT".intern();

/**
* <p class="changed_added_5_0">
* Returns the current {@link FaceletContext} instance from the attributes of {@link FacesContext#getCurrentInstance()}.
* </p>
*
* @return the current {@link FaceletContext} instance from the attributes of {@link FacesContext#getCurrentInstance()}.
* @since 5.0
*/
public static FaceletContext getCurrentInstance() {
return getCurrentInstance(FacesContext.getCurrentInstance());
}

/**
* <p class="changed_added_5_0">
* Returns the current {@link FaceletContext} instance from the attributes of the given {@link FacesContext} instance.
* </p>
*
* @return the current {@link FaceletContext} instance from the attributes of the given {@link FacesContext} instance.
* @since 5.0
*/
public static FaceletContext getCurrentInstance(FacesContext context) {
return (FaceletContext) context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
}

/**
* <p class="changed_added_2_0">
* The current FacesContext bound to this "request". Must not be <code>null</code>.
Expand Down

0 comments on commit 0956438

Please sign in to comment.