Passing bean instance as param to a facelet
jrachev Nov 19, 2010 11:44 AMHello,
I have this problem. In a facelet composition I have declare some links that should certain action from a bean, which bean I want to specify from another facelet which uses the composition. Here is my code.
The Composition paging.xhtml:
....
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
<table>
<tr>
<td align="center">
<s:link action="#{bean.getPage()}" disabled="#{bean.getPage()==0}">
<h:graphicImage value="/img/FirstPage.gif" rendered="#{bean.getPage()!=0}" />
<h:graphicImage value="/img/FirstPage_Disabled.gif" rendered="#{bean.getPage()==0}" />
</s:link>
<s:link action="#{bean.getPage()}" disabled="#{bean.getPage()==0}">
<h:graphicImage value="/img/PreviousPage.gif" rendered="#{bean.getPage()!=0}" />
<h:graphicImage value="/img/PreviousPage_Disabled.gif" rendered="#{bean.getPage()==0}" />
</s:link>
<s:link action="#{bean.isNextPageAvailable()}" disabled="#{!bean.isNextPageAvailable()}">
<h:graphicImage value="/img/NextPage.gif" rendered="#{bean.isNextPageAvailable()}" />
<h:graphicImage value="/img/NextPage_Disabled.gif" rendered="#{!bean.isNextPageAvailable()}" />
</s:link>
<s:link action="#{bean.isNextPageAvailable()}" disabled="#{!bean.isNextPageAvailable()}">
<h:graphicImage value="/img/LastPage.gif" rendered="#{bean.isNextPageAvailable()}" />
<h:graphicImage value="/img/LastPage_Disabled.gif" rendered="#{!bean.isNextPageAvailable()}" />
</s:link>
</td>
</tr>
</table>
</ui:composition>
.....
and the client page client.xhtml
.....
<table>
<tr><td align="center">
<ui:include src="/layout/paging.xhtml">
<ui:param name="bean" value="#{NewElectronicStatementsAction}" />
</ui:include>
</td></tr>
</table>
.....
It is strange because when there are no more pages the relevant links becomes disabled and and the images do change, but when I any of the links(which are not disabled of course) an exception rises:
Exception during request processing:
Caused by javax.el.PropertyNotFoundException with message: Target Unreachable, identifier 'bean' resolved to null
So why comes that my code works for the state of the links, but does not for the action invocation? And how should I fix it?
Thanks in advance.