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

Standardize how to retrieve ui:param from Backing Bean / FaceletContext #1818

Open
volosied opened this issue Jun 9, 2023 · 3 comments
Open

Comments

@volosied
Copy link
Contributor

volosied commented Jun 9, 2023

Mojarra supports the following:

FaceletContext faceletContext = (FaceletContext)FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
Object p1 = faceletContext.getAttribute("someParam");
String param = (String)p1;

However, the code above does not always work in MyFaces. One workaround is to use c:set instead, but it would nice to have something spec defined.

Additional Information:

@BalusC
Copy link
Member

BalusC commented Jun 18, 2023

Agreed. There are indeed real world use cases where this is really useful. The technical problem is that FaceletContext is essentially volatile and is tied to the current Facelet being being processed. The implementation in Mojarra is actually not entirely correct (ui:param is leaking outside Facelet). Ultimately we would need a helper something like FaceletContext.getIncludeParam(faceletPath, paramName).

@BalusC
Copy link
Member

BalusC commented Jul 22, 2023

There is another difficulty. A single include file can be included multiple times in same view. How do we know which one we want to obtain the param from? By index will do it but is pretty brittle when dev decides to rearrange layout and forgets to adjust index to obtain param.

@BalusC
Copy link
Member

BalusC commented Jul 23, 2023

We could give <ui:include>/<ui:decorate> something like an id attribute but it should not be confused with those of UIComponent.

@volosied volosied changed the title Stanardize how to retrieve ui:param from Backing Bean / FaceletContext Standardize how to retrieve ui:param from Backing Bean / FaceletContext Oct 3, 2024
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