You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Volodymyr Siedlecki (Jira)" <de...@myfaces.apache.org> on 2022/07/13 18:21:00 UTC

[jira] [Comment Edited] (MYFACES-4438) Clarify FaceletContext.getAttribute() (Retrieving ui:param from bean)

    [ https://issues.apache.org/jira/browse/MYFACES-4438?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17566016#comment-17566016 ] 

Volodymyr Siedlecki edited comment on MYFACES-4438 at 7/13/22 6:20 PM:
-----------------------------------------------------------------------

Attached an app (WITH the c:set workaround). Try it out on Tomcat (un-comment correct dependencies)


was (Author: volosied):
Attached an app. Try it out on Tomcat (un-comment correct dependencies)

> 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: 2.0.24, 2.2.15, 2.3.10, 3.0.2
>            Reporter: Volodymyr Siedlecki
>            Priority: Minor
>         Attachments: MYFACES4438.zip
>
>
> {color:#0e101a}I have a scenario with the following code where retrieving "dataId{color}" from the FaceletContext return null.
>  
> index.xhtml:
> {quote}{color:#808080}<{color}{color:#569cd6}ui:composition{color}{color:#d4d4d4} {color}{color:#9cdcfe}template{color}{color:#d4d4d4}={color}{color:#ce9178}"layout.xhtml"{color}{color:#808080}>{color}{color:#d4d4d4} {color}{color:#808080}<{color}{color:#569cd6}ui:param{color}{color:#d4d4d4} {color}{color:#9cdcfe}name{color}{color:#d4d4d4}={color}{color:#ce9178}"dataId"{color}{color:#d4d4d4} {color}{color:#9cdcfe}value{color}{color:#d4d4d4}={color}{color:#ce9178}"foo"{color}{color:#808080} /></{color}{color:#569cd6}ui:composition{color}{color:#808080}>{color}
> {quote}
> {color:#0e101a}Managed Bean:{color}
> {quote}{color:#d4d4d4} {color}{color:#4ec9b0}FaceletContext{color}{color:#d4d4d4} {color}{color:#9cdcfe}faceletContext{color}{color:#d4d4d4} = ({color}{color:#4ec9b0}FaceletContext{color}{color:#d4d4d4}){color}{color:#9cdcfe}FacesContext{color}{color:#d4d4d4}.{color}{color:#dcdcaa}getCurrentInstance{color}{color:#d4d4d4}().{color}{color:#dcdcaa}getAttributes{color}{color:#d4d4d4}().{color}{color:#dcdcaa}get{color}{color:#d4d4d4}({color}{color:#9cdcfe}FaceletContext{color}{color:#d4d4d4}.{color}{color:#9cdcfe}FACELET_CONTEXT_KEY{color}{color:#d4d4d4});{color}
> {color:#9cdcfe} faceletContext{color}{color:#d4d4d4}.{color}{color:#dcdcaa}getAttribute{color}{color:#d4d4d4}({color}{color:#ce9178}"dataId"{color}{color:#d4d4d4}){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) returns null {color}
>  
> {color:#0e101a}MyFaces 2.2.0 and higher: faceletContext.getAttribute("dataId"); returns null{color}
>  
>  
> {color:#0e101a}In some old posts [1], BalusC mentioned that FaceletContext is only available at build time (restore view phase). (And he also said FaceletContext is not supported in MyFaces but then again it's a post from 2012). Is this still true for 2.2/2.3 and newer? Should getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY) also return null as it did in 2.0.x?  It doesn't seem to be nulled out in 2.2. {color}
> {color:#0e101a}I think BalusC is correct 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}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}Any guidance is appreciated. {color}
>  
> {color:#0e101a}Old discussion here: {color}
> 1) [{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)