I am writing a Facelet tag file in JSF 1.2. I want to be able to reference the parent container. In JSF 2.0, I could make this a composite component and use #{cc.parent} . But is there a similar JSF 1.2 method?
taglib.xml
<?xml version="1.0"?> <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "facelet-taglib_1_0.dtd"> <facelet-taglib> <namespace>http://company.com/jsf</namespace> <tag> <tag-name>parentid</tag-name> <source>../components/parentid.xhtml</source> </tag> </facelet-taglib>
parentid.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:ui="http://java.sun.com/jsf/facelets"> <h:outputText binding="#{obj}" value="Parent id is: #{obj.parent.id}" /> </ui:composition>
testpage.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:test="http://company.com/jsf" xmlns:ui="http://java.sun.com/jsf/facelets"> ... <a:form id="form1"> <test:parentid /> </a:form> <a:form id="form2"> <test:parentid /> </a:form> ... </ui:composition>
I edited this to include information from the BalusC link, and I'm almost there.
In this example, it works fine if there is only form1. But adding form2 is the result I get:
Parent id is: form2 Parent id is: form2
I want:
Parent id is: form1 Parent id is: form2
Thus, the binding in the composition is overwritten with any last binding. I tried to use the card and get attached to it, but it did not work. How can i solve this?
source share