function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramadhar MishraRamadhar Mishra 

Tab Panel not working as expected

Hi , I have following Vf page there I have tab panel with 5 different tabs While click on first 'Language' tab it i not displaying the Selected items in Selected Panel section in right hand side but while selecting Last tab 'Others' it is displaying the selected items. Can any one suggest what wrong I am doing. VF code as follows.....................

 

VF Page ####

<apex:page controller="ctlr_Checkbox_Class" Tabstyle="Account" sidebar="false" showHeader="true">

<style type="text/css">

.customPopup{
background-color: white;
border-style: solid;
border-width: 2px;
left: 50%;
padding:1px;
position: absolute;
z-index:9;
/* These are the 3 css properties you will need to tweak so the pop
up displays in the center of the screen. First set the width. Then set
margin-left to negative half of what the width is. You can also add
the height property for a fixed size pop up.*/
width: 800px;
margin-left: -400px;
top:100px;
}

.customNewPopup{
background-color: white;
border-style: solid;
border-width: 1px;
left: 50%;
padding:5px;
position: absolute;
z-index: 9;
/* These are the 3 css properties you will need to tweak so the pop
up displays in the center of the screen. First set the width. Then set
margin-left to negative half of what the width is. You can also add
the height property for a fixed size pop up.*/
width: 700px;
margin-left: -350px;
top:100px;
}

.popupBackground{
background-color:black;
opacity: 0.20;
filter: alpha(opacity = 50);
position:absolute;
width: 95%;
height: 95%;
top: 0;
left: 0;
z-index:8;

}
.buttonStyle{
text-align: right;
}

.customNewPopupRelative{
background-color: white;
border-style: solid;
border-width: 1px;
left: 50%;
padding:5px;
position: relative;
z-index: 9;
/* These are the 3 css properties you will need to tweak so the pop
up displays in the center of the screen. First set the width. Then set
margin-left to negative half of what the width is. You can also add
the height property for a fixed size pop up.*/
width: 700px;
margin-left: -350px;
top:10px;
}


</style>

<script language="javascript">
function DummyHold() {
// Dummy Empty Method
}
</script>

<apex:form >
<apex:pageBlock >
Test1: :::::{!Selected2}
Test2: :::::{!Selected}
<apex:pageBlockSection Title="List of Available Templates" collapsible="false">
<apex:tabPanel switchType="client" value="{!selectTab}" selectedTab="name1" id="theTabPanel" width="100%" tabClass="activeTab" inactiveTabClass="inactiveTab" title="List of Available Templates">
<!--
<apex:tab label="Language" name="name1" id="tabOne">
<apex:PageblockTable value="{!AccountsforLanguage}" var="a1" cellpadding="4" border="1">
<apex:column >
<apex:facet name="header"> <apex:inputCheckbox >
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>
</apex:inputCheckbox></apex:facet>
<apex:inputCheckbox value="{!a1.selected}" id="checkedone1">
<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS"/>
</apex:inputCheckbox>
</apex:column>

<apex:column headervalue="Template Name" value="{!a1.acc.Template_Library_Name__c}" width="1000"/>
<apex:column headervalue="Template ID" value="{!a1.acc.Name}" width="250" />
<apex:column headervalue="Record Type" value="{!a1.acc.RecordType.Name}" width="200"/>

</apex:PageblockTable>
</apex:tab>

--->


<apex:tab label="Language" name="name1" id="tab1">
<apex:PageblockTable value="{!accountsforlanguage}" var="a" cellpadding="4" border="1">
<apex:column >
<apex:facet name="header">
<apex:inputCheckbox >
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" reRender="Selected_PBS" id="first"/>
</apex:inputCheckbox>
</apex:facet>
<apex:inputCheckbox value="{!a.selected}" id="checkedone1">
<apex:actionSupport event="onclick" action="{!GetSelected2}" reRender="Selected_PBS" id="second"/>
</apex:inputCheckbox></apex:column>
<apex:column headervalue="Template ID" value="{!a.acc.Name}" width="200" />
<apex:column headervalue="Template Name" value="{!a.acc.Template_Library_Name__c}" width="1000"/>
<apex:column headervalue="Record Type" value="{!a.acc.RecordType.Name}" width="400"/>

</apex:PageblockTable>
</apex:tab>


<apex:tab label="Insurance" name="name2" id="tab2">
<apex:PageblockTable value="{!AccountsforInsurance}" var="a" cellpadding="4" border="1">
<apex:column >
<apex:facet name="header"> <apex:inputCheckbox >
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>
</apex:inputCheckbox></apex:facet>
<apex:inputCheckbox value="{!a.selected}" id="checkedone2">
<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS,form"/>
</apex:inputCheckbox></apex:column>
<apex:column headervalue="Template ID" value="{!a.acc.Name}" width="200" />
<apex:column headervalue="Template Name" value="{!a.acc.Template_Library_Name__c}" width="1000"/>
<apex:column headervalue="Record Type" value="{!a.acc.RecordType.Name}" width="400"/>

</apex:PageblockTable>
</apex:tab>

<apex:tab label="Diversity" name="name3" id="tab3">
<apex:PageblockTable value="{!AccountsforDiversity}" var="a" cellpadding="4" border="1">
<apex:column >
<apex:facet name="header"> <apex:inputCheckbox >
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>
</apex:inputCheckbox></apex:facet>
<apex:inputCheckbox value="{!a.selected}" id="checkedone3">
<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS,form"/>
</apex:inputCheckbox></apex:column>
<apex:column headervalue="Template ID" value="{!a.acc.Name}" width="200" />
<apex:column headervalue="Template Name" value="{!a.acc.Template_Library_Name__c}" width="1000"/>
<apex:column headervalue="Record Type" value="{!a.acc.RecordType.Name}" width="400"/>

</apex:PageblockTable>
</apex:tab>

<apex:tab label="Document" name="name4" id="tab4">
<apex:PageblockTable value="{!accounts}" var="d" cellpadding="4" border="1">
<apex:column >
<apex:facet name="header"> <apex:inputCheckbox >
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>
</apex:inputCheckbox></apex:facet>
<apex:inputCheckbox value="{!d.selected}" id="checkedone4">
<apex:actionSupport event="onclick" action="{!GetSelected2}" rerender="Selected_PBS,form"/>
</apex:inputCheckbox></apex:column>
<apex:column headervalue="Template ID" value="{!d.acc.Name}" width="200" />
<apex:column headervalue="Template Name" value="{!d.acc.Template_Library_Name__c}" width="1000"/>
<apex:column headervalue="Record Type" value="{!d.acc.RecordType.Name}" width="400"/>

</apex:PageblockTable>
</apex:tab>


<apex:tab label="Others" name="name5" id="tab5">
<apex:PageblockTable value="{!accountsforOthers}" var="a" cellpadding="4" border="1">
<apex:column >
<apex:facet name="header"> <apex:inputCheckbox >
<apex:actionSupport event="onclick" action="{!GetSelected}" onsubmit="checkAll(this)" rerender="Selected_PBS"/>
</apex:inputCheckbox></apex:facet>
<apex:inputCheckbox value="{!a.selected}" id="checkedone5">
<apex:actionSupport event="onclick" action="{!GetSelected2}" rerender="Selected_PBS"/>
</apex:inputCheckbox></apex:column>
<apex:column headervalue="Template ID" value="{!a.acc.Name}" width="200" />
<apex:column headervalue="Template Name" value="{!a.acc.Template_Library_Name__c}" width="1000"/>
<apex:column headervalue="Record Type" value="{!a.acc.RecordType.Name}" width="400"/>

</apex:PageblockTable>
</apex:tab>


</apex:tabPanel>
<!-- </apex:pageBlockSection> -->


<apex:outputPanel id="Selected_PBS" title="Selected Templates" layout="block">

<!-- <table> <tr><td style="font-weight: bold"> Selected Templates </td></tr></table> --->
<!-- <apex:sectionHeader title="Selected Templates" /> --->
<apex:pageBlock title="Selected Templates">


<!-- <apex:pageBlockSection Title="Selected Templates" id="Selected_PBS"> --->
<apex:PageBlockTable value="{!SelectedAccounts}" var="s" columnswidth="350px,350px" cellpadding="4" border="1" >
<!--- <apex:outputLink value="{$!s.Name}" rendered="{$!s.Name}" >{$!s.Name}</apex:outputLink> --->

<apex:column headervalue="Template Name" value="{!s.Template_Library_Name__c}" />
<apex:column headervalue="Record Type" value="{!s.RecordType.Name}" />
<apex:column width="350px!important">
<apex:facet name="header" > Edit and Save </apex:facet>
<!--
<apex:outputPanel styleClass="customNewPopup" layout="block" rendered="{!displaypopup1}">
<apex:pageBlock >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Save" style="vertical-align:middle;width:80px;height:20px;"/>
<apex:commandButton value="Cancel" action="{!closepopup1}" style="vertical-align:middle;width:80px;height:20px;"/>
</apex:pageBlockButtons>

</apex:pageBlock>
</apex:outputPanel>
-->


<apex:outputLink rendered="true" onclick="window.open('/apex/NewTemplateRequirementTL?templId={!s.Id}&progId={!progId}','myWindow','width=800,height=410,toolbar=0,status=1,scrollbars=1,resizable=yes,getCall(this)'); return false;"> Edit </apex:outputLink>
<apex:outputLink rendered="false" onclick="window.open('/apex/NewTemplateRequirementTL?templId={!s.Id}&progId={!progId}','myWindow','width=800,height=410,toolbar=0,status=1,scrollbars=1,resizable=yes'); return false;"> Modify/Delete </apex:outputLink>
</apex:column>
</apex:pageblocktable>

</apex:pageBlock>
<br/>
<table align="right"> <tr><td style="font-weight: bold" > <apex:commandButton value="Submit"/> </td></tr></table>
</apex:outputPanel>
</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

<!-- </apex:pageBlock> --->


<script>
function checkAll(cb){
var inputElem = document.getElementsByTagName("input");
for(var i=0; i<inputElem.length; i++){
//if(inputElem[i].id.indexOf("checkedone")!=-1)
inputElem[i].checked = cb.checked;
}
var tabname=getSelectedTabName();
alert('This is the tab selected....'+tabname);
}

function getSelectedTabName() {
if (RichFaces) {
var tabs = RichFaces.panelTabs['p:f:tp'];
for (var i = 0; i < tabs.length; i++) {
var tab = tabs[i];
if (RichFaces.isTabActive(tab.id + '_lbl')) {

return tab.name;
}
}
}
return null;
}


</script>

</apex:page>

 

 

 

Apex Class ###

 

 

public class ctlr_Checkbox_Class
{
/*
* This source code was written by Kumar Narasimha.

*/

List<accountwrapper> accountListIns = new List<accountwrapper>();
List<accountwrapper> accountListDoc = new List<accountwrapper>();
List<accountwrapper> accountListDiv = new List<accountwrapper>();
List<accountwrapper> accountListLangOther = new List<accountwrapper>();
List<accountwrapper> accountList = new List<accountwrapper>();

List<Template_Library__c> selectedAccounts = new List<Template_Library__c>();

// Map will store the records those are finally ready for insert in database
Map <ID,Template_Library__c> mapModifiedAccounts=new Map <ID,Template_Library__c>();


public String progId {get; set;}

public boolean linktype{get;set;}

public string selectTab{get; set; }



public ctlr_Checkbox_Class() {
progId = ApexPages.currentPage().getParameters().get('progId');
}

public List<accountwrapper> getAccounts()
{
accountList = new List<accountwrapper>();

for(Template_Library__c a : [select Id, Name, RecordType.Name, Template_Library_Name__c from Template_Library__c where RecordType.Name='Document' order by Name Desc])
accountList.add(new accountwrapper(a));
return accountList;
}



public List<accountwrapper> getAccountsforDiversity()
{
accountList = new List<accountwrapper>();

for(Template_Library__c a : [select Id, Name, RecordType.Name, Template_Library_Name__c from Template_Library__c where RecordType.Name='Diversity' order by Name Desc])
accountList.add(new accountwrapper(a));
return accountList;
}



public List<accountwrapper> getAccountsforInsurance()
{
accountList = new List<accountwrapper>();
for(Template_Library__c a : [select Id, Name, RecordType.Name, Template_Library_Name__c from Template_Library__c where RecordType.Name='Insurance' order by Name Desc])
accountList.add(new accountwrapper(a));
return accountList;
}


public List<accountwrapper> getAccountsforLanguage()
{
accountList = new List<accountwrapper>();

for(Template_Library__c a : [select Id, Name, RecordType.Name, Template_Library_Name__c from Template_Library__c where RecordType.Name='Language' order by Name Desc])
accountList.add(new accountwrapper(a));
return accountList;
}


public List<accountwrapper> getAccountsforOthers()
{

accountList = new List<accountwrapper>();

for(Template_Library__c a : [select Id, Name, RecordType.Name, Template_Library_Name__c from Template_Library__c where RecordType.Name='COI' OR RecordType.Name='Contractor Validation Worksheet' order by Name Desc])

accountList.add(new accountwrapper(a));
return accountList;
}

public PageReference getSelected()
{
selectedAccounts.clear();
for(accountwrapper accwrapper : accountList)
if(accwrapper.selected == true)
selectedAccounts.add(accwrapper.acc);

System.debug('These are the selected Records...................................................................');
for(Template_Library__c con : selectedAccounts) {
system.debug(con.Name);
}
return null;
}

public PageReference getSelected2()
{
selectedAccounts.clear();
for(accountwrapper accwrapper : accountList)
if(accwrapper.selected == true){
selectedAccounts.add(accwrapper.acc);
}
return null;
}

public Map<ID,Template_Library__c> getModifiedAccounts(){
if(selectedAccounts.size()>0){
for(Template_Library__c con : selectedAccounts){
system.debug(con.Name);
mapModifiedAccounts.put(con.ID,con);
}
return mapModifiedAccounts;
}
return null;
}

public List<Template_Library__c> GetSelectedAccounts()
{
if(selectedAccounts.size()>0)
return selectedAccounts;
else
return null;
}



public class accountwrapper
{
public Template_Library__c acc{get; set;}
public Boolean selected {get; set;}
public accountwrapper(Template_Library__c a)
{
acc = a;
selected = false;
}
}


// ---------------------------- POP UP Junk -------------------------

public Boolean displayPopup1 {get; set;}

public void showpopup1(){
displayPopup1 = true ;
}

public void closepopup1(){
displayPopup1 = false ;
}

// -------------------------------------------------------------------

}

HariDineshHariDinesh

Hi,

 

Can you provide your VFP and Apex Class Codes in proper aligned order so that everyone can understand and someone can help you.

(Use Insert Code Option at the top tool Bar.)

Ramadhar MishraRamadhar Mishra
Please find aligned code. Can you please help me.