I have created a custom Visualforce component, and I want to include in my Visualforce page two times. I will be passing certain attributes using apex:attribute so that component will function accordingly, but its not working. When I embed component two times, the second time component works. My VF page
<apex:page >
<c:TreeView id="myj" rendered="true" objectName="Contact" toolTipField="FirstName">
</c:TreeView>
hello
<c:TreeView id="my" rendered="true" objectName="Account" toolTipField="Name">
</c:TreeView>
</apex:page>
My Component
<apex:component controller="treeController">
<apex:includeScript value="{!$Resource.Jquery}"/>
<apex:outputPanel id="JSRerender">
<script type="text/javascript">
var lazyHtml = "";
function completionMethod()
{
$('input[type=checkbox]').change(function(){
id = $(this).attr('id');
fetchByParent(id);
}
});
}
</script>
</apex:outputPanel>
<apex:form >
<apex:actionFunction name="fetch" action="{!fetchRecords}" reRender="JSRerender,treePanel" oncomplete="fetchComplete()"/>
</apex:form>
<apex:attribute name="objectName" assignTo="{!objectName}" type="String" required="true" description="object Name of which data to be shown"/>
</apex:component>
My Controller
public class treeController {
//it contains objects of which tree to be shown
public String objectName{get;set;}
//it contains comma sperated list of ToolTip shown on the node of a tree
public String toolTipField{get;set;}
public treeController(){
//fetchRecords();
}
/*
*it fetches all the records of objectName
*/
public void fetchRecords(){
//when i put system.debug(objectName)
//it prints Account as object name also it comes only once in this method while i have used two components so it should come twice
//i want once contact to be printed and once account
//where i am going wrong
}