You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Ludovic Pénet (JIRA)" <de...@myfaces.apache.org> on 2013/08/12 14:13:48 UTC
[jira] [Commented] (MYFACES-3168) Bound attribute values resolve to
NULL during PreRenderViewEvent for nested composite components
[ https://issues.apache.org/jira/browse/MYFACES-3168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13736805#comment-13736805 ]
Ludovic Pénet commented on MYFACES-3168:
----------------------------------------
I also request a reopening of this issue. Without this issue solved (or a work around provided), one can not easily forge EL expressions for dynamic controls. I mean, controls dynamically instantiated on a PreRenderViewEvent.
To be able to forge "complex" EL expressions involving a variable passed as a parameter, I today use a klude that recursively resolve this variable to its "real" value :
public static String getValueExpressionExpression(ValueExpression valueExpression) {
return valueExpression.getExpressionString().replace("#{", "").replace("}", "");
}
public static String getMappedValueExpression(ValueExpression valueExpression) {
ContextAwareTagValueExpression ctxAware = (ContextAwareTagValueExpression)valueExpression;
if(ctxAware != null) {
return getMappedValueExpression((WrappedValueExpression)ctxAware.getWrapped());
}
return getValueExpressionExpression(valueExpression);
}
public static String getMappedValueExpression(WrappedValueExpression wrappedExpression) {
String exprString = wrappedExpression.getExpressionString().replace("#{", "").replace("}", "");
String ret = exprString;
try {
Field valueExpression = WrappedValueExpression.class.getDeclaredField("valueExpression");
valueExpression.setAccessible(true);
ValueExpressionImpl vei = (ValueExpressionImpl) valueExpression.get(wrappedExpression);
Field varMapper = ValueExpressionImpl.class.getDeclaredField("varMapper");
varMapper.setAccessible(true);
VariableMapperImpl vmi = (VariableMapperImpl) varMapper.get(vei);
if(vmi != null) {
String[] components = exprString.split("\\.");
components[0] = getMappedValueExpression(vmi.resolveVariable(components[0])); //.getExpressionString().replace("#{", "").replace("}", "");
ret = "";
for(int i = 0 ; i < components.length ; i++) {
if(i != 0) {
ret += ".";
}
ret += components[i];
}
}
} catch (Exception ex) {
logger.error("Exception lors du mapping de l'expression EL " + exprString, ex);
} finally {
return ret;
}
}
It would be great to have such functionnality available without naughty kludges like introspection... Maybe a myfaces extension would fit ?
Thanks in advance for your attention.
> Bound attribute values resolve to NULL during PreRenderViewEvent for nested composite components
> ------------------------------------------------------------------------------------------------
>
> Key: MYFACES-3168
> URL: https://issues.apache.org/jira/browse/MYFACES-3168
> Project: MyFaces Core
> Issue Type: Bug
> Components: General
> Affects Versions: 2.0.6, 2.1.0
> Environment: Windows 7 x64 Enterprise.
> JDK 1.6.0_25.
> Eclipse Version: Helios Service Release 2
> Build id: 20110218-0911
> Reporter: MAtthew Sweeney
> Assignee: Leonardo Uribe
> Attachments: ASF.LICENSE.NOT.GRANTED--screenshot-1.jpg, jsf-testing-2.zip, jsf-testing-myfaces.zip
>
>
> When nesting custom composite components, any data bound attributes (eg #{someValueExpression} ) will resolve to null during the PreRenderViewEvent. This only occurs on the second level or deeper nested component (the top-level component in the page works fine).
> This same issue occurs on JSF RI 2.0.4, 2.1.x, 2.2.x
> I have an eclipse project for upload that reproduces the problem.
> I have no cause for the issue at this time.
> Cheers,
> Matt
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira