Volodymyr Siedlecki created MYFACES-4438:
--------------------------------------------
Summary: Clarify FaceletContext.getAttribute() (Retrieving
ui:param from bean)
Key: MYFACES-4438
URL: https://issues.apache.org/jira/browse/MYFACES-4438
Project: MyFaces Core
Issue Type: Bug
Affects Versions: 3.0.2, 2.3.10, 2.0.24, 2.2.15
Reporter: Volodymyr Siedlecki
{color:#0e101a}I have a scenario with the following code where retrieving
"{{{}{color:#0e101a}dataId{color}{}}}" return null.
{color}
{color:#0e101a}index.xhtml:{color}
{quote}{{{color:#0e101a}<ui:composition
template="layout.xhtml">{color}}}{{{}{color:#0e101a} <ui:param name="dataId"
value="foo" />{color}{}}}{{{}{color:#0e101a}</ui:composition>{color}{}}}
{quote}
{color:#0e101a}Managed Bean:{color}
{quote}{{{}{color:#0e101a} FaceletContext faceletContext =
(FaceletContext)FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);{color}{}}}{{{}{color:#0e101a}faceletContext.getAttribute("{{{}{color:#0e101a}dataId{color}{}}}");{color}{}}}
{quote}
{color:#0e101a} {color}
{color:#0e101a}I found that this code above works in Mojarra 2.2.x but not in
MyFaces. I also found some variation in behavior between versions in
MyFaces.{color}
{color:#0e101a}Myfaces 2.0.25:
FacesContext.getCurrentInstance().getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY)
return null {color}
{color:#0e101a}MyFaces 2.2.15 and higher:
faceletContext.getAttribute("viewId"); returns null{color}
{color:#0e101a}In some old posts, BalusC mentioned that FaceletContext is only
available at build time (restore view phase) in MyFaces. Is that still true for
2.2/2.3 and newer? Should
getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY) then return null as in
2.0.x? {color}
{color:#0e101a}What's the correct behavior here? The implementation is quite
confusing as the FaceletContext.FACELET_CONTEXT_KEY value within the attribute
map is set and restored numerous times.{color}
{color:#0e101a}I believe it is because when I use c:set (also build time), the
faceletContext attribute map did contain the "dataId" value during the
@PostConstruct method of the bean. {color}
{color:#0e101a}Any guidance is appreciated. {color}
{color:#0e101a}Old discussion here: {color}
[{color:#4a6ee0}https://stackoverflow.com/questions/13930629/uiinclude-using-faceletscontext{color}]{color:#0e101a}
{color}
[{color:#4a6ee0}https://stackoverflow.com/questions/14745259/how-to-create-uiinclude-tag-programmatically{color}]{color:#0e101a}
{color}
{color:#0e101a} Issues which touch on FaceletContext: {color}
{color:#0e101a}- {color}{color:#4a6ee0}
https://issues.apache.org/jira/browse/MYFACES-3246{color}
{color:#0e101a}-
{color}{color:#4a6ee0}https://issues.apache.org/jira/browse/MYFACES-3848{color}{color:#0e101a}
{color}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)