[ 
http://issues.apache.org/jira/browse/MYFACES-856?page=comments#action_12358326 
] 

Simon Kitching commented on MYFACES-856:
----------------------------------------

Sigh. It looks like AliasBean just won't work with component bindings. At least 
I can't see any way to do it.

The issue with AliasBean when the view is being created is solvable by adding 
doStartTag/doEndTag methods to AliasBeanTag.

However when restoring an existing view, the bindings are executed by 
LifecycleImpl.recursivelyHandleComponentReferencesAndSetValid. And this method 
doesn't delegate the operation to the actual component, but instead breaks 
encapsulation by evaluating the component's binding itself. This means there is 
no way to execute "before" and "after" operations around the rebinding of the 
child components.

I've therefore just added a comment on AliasBean.java stating that bindings are 
not supported. I will update the wiki too.

Well, there *might* be a way to do it, by having AliasBean create a dummy first 
and last child, and catch calls to getValueBinding("binding") on them or some 
such nasty hack. I don't think that's worth doing though.

Mario's approach above does work, but by effectively promoting all AliasBean so 
that their alias is visible over the whole view tree. That's a fair solution 
for specific sites but I don't think it's a good general solution. For a start, 
it makes it impossible to reuse the same block of components twice in the same 
page bound to different real beans. And anyway as far as I can see, it's just 
equivalent to putting the aliasbean directly after the f:view and enclosing the 
entire page in it. Mario, have I missed something?

I'll leave this issue open for a few days just in case someone smarter than me 
comes up with a proper solution.

> t:aliasBean + binding + panelGrid causes exception
> --------------------------------------------------
>
>          Key: MYFACES-856
>          URL: http://issues.apache.org/jira/browse/MYFACES-856
>      Project: MyFaces
>         Type: Bug
>     Reporter: Simon Kitching

>
> The following use of t:aliasBean causes an exception:
> ==== including page
> <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk"; prefix="t"%>
> <f:view>
>   <h:panelGrid>
>     <t:aliasBean alias="#{target}" value="#{someBean}">
>       <jsp:include page="included.jsp"/>
>     </t:aliasBean>
>   </h:panelGrid>
> </f:view>
> ==== included page
> <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk"; prefix="t"%>
> <f:subview id="foo">
>     <h:inputText binding="#{target.input}"/>
> </f:subview>
> The thrown exception is:
> javax.faces.el.PropertyNotFoundException: Base is null: target
>         at 
> org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(ValueBindingImpl.java:457)
>         at 
> org.apache.myfaces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:245)
>         at 
> org.apache.myfaces.application.ApplicationImpl.createComponent(ApplicationImpl.java:434)
> I believe the problem is that panelGrid renders its children. This means that 
> the components are first created, then the panelGrid iterates over them to 
> render them. However the alias bean hasn't set up the alias at the time the 
> components are being created. And ApplicationImpl.createComponent(binding, 
> context, componentType) is immediately evaluating the binding expression, 
> resulting in the target bean for the binding not being found.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to