You need to sign in to do that
Don't have an account?
jonathanrico.
ListView inside tabPanel refreshing whole page...
Hello everyone
I'm having problems with a listview inside a tab panel. I've created two tabs inside the panel, the first one contains a form and the second one a listview. The problem is that once I enter to the second tab (the one with the list view) and click for example a letter in the list view to see only records that start with that letter, the whole VF page is refreshed and I get back to the first tab, the second tab now contains only the records that start with the letter I selected, however since the page was refreshed I landed in the default tab, which is the first one.
I've already tried passing the selected tab name to the controller and setting a String with this name in order to use it in the value property of the tabpanel component:
Any help will be very appreciated, thank you very much.
Message Edited by jonathan rico on 09-01-2008 12:34 PM
I'm having problems with a listview inside a tab panel. I've created two tabs inside the panel, the first one contains a form and the second one a listview. The problem is that once I enter to the second tab (the one with the list view) and click for example a letter in the list view to see only records that start with that letter, the whole VF page is refreshed and I get back to the first tab, the second tab now contains only the records that start with the letter I selected, however since the page was refreshed I landed in the default tab, which is the first one.
I've already tried passing the selected tab name to the controller and setting a String with this name in order to use it in the value property of the tabpanel component:
Code:
<script> function updateTab(tabname){ switchTab(tabname); } </script> <apex:form > <apex:actionFunction name="switchTab" action="{!switchTab}" immediate="true"> <apex:param name="tabvalue" value="" /> </apex:actionFunction> </apex:form> <apex:tabPanel id="tabcontainer" value="{!selectedTab}"> <apex:tab id="tab_1" name="tab_1" ontabenter="updateTab('tab_1');"/> <apex:tab id="tab_2" name="tab_2" ontabenter="updateTab('tab_2');"> <apex:listViews type="theObject__c" </apex:tab> And the controller: public String selectedTab{get;set;} public void switchTab(){ selectedTab = System.currentPageReference().getParameters().get('tabvalue'); }
Any help will be very appreciated, thank you very much.
Message Edited by jonathan rico on 09-01-2008 12:34 PM
Yes, I've already tried using selectedTab attribute, the problem is that apparently once the page is refreshed my variables in the controller are reset. So even if I changed succesfully a variable to point to the selectedTab once the listview refreshed the page I lose this information. :smileyindifferent:
Will declaring the string that i'm changing in the controller as transient will help here? I tried but still no luck maybe i'm doing something wrong.
I'm open to ideas, thank you.
I did a similar thing (although I store my tab selection in a field at the moment) and it seemed to work.
Message Edited by XactiumBen on 09-04-2008 03:34 AM
Lal
It's not a perfect solution, but I ended up making a custom object (Page_State__c) that held a user (or user id) and the currently selected tab (mentioned in http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=16883) . Also note that I had to use the recordSelectedTabNeeded variable because DML is not allowed in getters/setters. Here is the code...
<apex:page controller="ThisController">
<apex:tabPanel id="tabPanel" value="{!selectedTabName}">
<apex:tab label="1" id="Object1">
<apex:ListViews type="Object1__c" />
</apex:tab>
<apex:tab label="2" id="Object2" >
<apex:ListViews type="Object1__c" />
</apex:tab>
</apex:tabPanel>
<apex:form >
<apex:actionFunction name="recordSelectedTabFunction" action="{!recordSelectedTab}" reRender="false"/>
</apex:form>
<script type="text/javascript">
if ({!recordSelectedTabNeeded}){
recordSelectedTabFunction();
}
</script>
</apex:page>
public with sharing class ThisController {
String selectedTabName = null;
Id currentUserId;
Boolean recordSelectedTabNeeded = false;
String defaultSelectedTabName = 'Object1';
public ThisController(){
this.currentUserId = UserInfo.getUserId();
}
public String getSelectedTabName() {
if (this.selectedTabName != null){
return this.selectedTabName;
}
Page_State__c pageState = findPageState(this.currentUserId);
if (pageState == null || pageState.SelectedTab__c == null){
return defaultSelectedTabName;
}else{
return pageState.SelectedTab__c;
}
}
public void setSelectedTabName(String currentTabName) {
this.selectedTabName = currentTabName;
this.recordSelectedTabNeeded = true;
}
public Boolean getRecordSelectedTabNeeded(){
return this.recordSelectedTabNeeded;
}
public void recordSelectedTab(){
Page_State__c pageState = findPageState(this.currentUserId);
if (pageState == null){
pageState = new Page_State__c();
pageState.UserId__c = this.currentUserId;
pageState.SelectedTab__c = this.selectedTabName;
insert pageState;
}else{
pageState.SelectedTab__c = this.selectedTabName;
update pageState;
}
this.recordSelectedTabNeeded = false;
}
private Page_State__c findPageState(Id userId){
List<Page_State__c> pageStatelist =
[Select p.UserId__c, p.SelectedTab__c, p.IsDeleted, p.Id, p.Name
From Page_State__c p
Where p.IsDeleted = false
and p.userId__c = :userId];
if (pageStatelist.size() == 1){
return pageStatelist.get(0);
}else{
return null;
}
}
}
Hi rfanning,
I'm digging up an old thread here, but I was wondering if this is the only way to get around the tab focus problem. Have any updates addressed this issue? I implemented this solution and it wasn't working for me. It looks like my debugs show the recordSelectedTabNeeded Bool never gets set to True unless I initialize it to True.
Also, enhanced lists don't have this issue, but there is a maximum number of those per page allowed, whereas regular lists don't appear to have a maximum, so a solution to this would be awesome.
Thank you for your help