+ Start a Discussion
Vijay Kumar Rebbala 11Vijay Kumar Rebbala 11 

not showing results on a tab2 unless I enter input data on tab1

Unless I select any options on tab "Student", i could'nt search any on Tab "Attendence"
Why is this happening?
Visualforce page:

<apex:page standardController="Teacher__c" action="{!fetchFailingPage}" extensions="RGMTeacherController" sidebar="false" showHeader="false">
    <style>
        .activeTab {background-color: #236FBD; color:white; background-image:none}
        .inactiveTab { background-color: lightgrey; color:black; background-image:none}
    </style>
          
      <apex:form id="loginForm" forceSSL="true">
       
            <apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="Information">
                
                <apex:tab id="home" label="Home" title="Home">                   
                </apex:tab>
                
                <apex:tab label="Information" name="Information" id="InformationTab" >                                         
                </apex:tab>

                <apex:tab id="student" label="Student" title="Student">
                    <apex:pageBlock >
                        <apex:selectList label="Standard" id="choosestandard" required="true"  alue="{!standard}" >
                            <apex:selectOptions value="{!standarditems}" id="standarditem" />                           
                        </apex:selectList> 
                        <apex:selectList label="Section" id="choosesection" required="true" value="{!section}" >
                            <apex:selectOptions value="{!sectionitems}" id="sectionitem" />                           
                        </apex:selectList>
                        <apex:selectList label="Subject" id="choosesubject" required="true" value="{!subject}" >
                            <apex:selectOptions value="{!subjectitems}" id="subjectitem" />                           
                        </apex:selectList>
                        <apex:commandButton action="{!studentsearch}" value="Search" reRender="stulistid" />               
                    
                    
                        <apex:outputPanel id="stulistid" >
                        <apex:pageblocktable value="{!studentlist}" var="a" id="pbTable" >
                            <apex:column value="{!a.Name}"/>
                            <apex:column value="{!a.Roll_Number__c}"/>
                            <apex:column value="{!sfUrl}{!a.Id}"/>
                            <apex:column ><apex:outputLink value="{!URLFOR($Action.Student__c.View, a.id)}">{!a.name}</apex:outputLink></apex:column>
                        </apex:pageblocktable>
                        </apex:outputPanel>
                    </apex:pageBlock>
                </apex:tab>
                
                <apex:tab id="event" label="Events" title="Events">              
                </apex:tab>
                
                <apex:tab id="attendence" label="Attendence" title="Attendence">              
                    
                    <apex:pageBlock title="Make Attendence">                       
                            <apex:pageBlockSection >
                                <apex:selectList label="Standard" id="stustandard" value="{!stanatt}" >
                                    <apex:selectOption itemValue="L.K.G" itemLabel="L.K.G"/>
                                    <apex:selectOption itemValue="U.K.G" itemLabel="U.K.G"/>
                                    <apex:selectOption itemValue="I" itemLabel="I"/>
                                    <apex:selectOption itemValue="II" itemLabel="II"/>                        
                                </apex:selectList>
                                <apex:selectList label="Section" id="stusec" value="{!secatt}" >
                                    <apex:selectOption itemValue="A" itemLabel="A"/>
                                    <apex:selectOption itemValue="B" itemLabel="B"/>                       
                                </apex:selectList>
                            </apex:pageBlockSection>
                            <apex:pageBlockButtons location="Top">
                            <apex:commandButton action="{!makatt}" value="Search" reRender="xyz"/>
                        </apex:pageBlockButtons>
                    </apex:pageBlock>
                    <apex:outputPanel id="xyz">
                    <apex:pageBlock title="Attendence List">                   
                        <apex:pageBlockTable value="{!studentattlist}" var="itr">
                            <apex:column value="{!itr.Name}"/>
                            <apex:column value="{!itr.Roll_Number__c}"/>
                        </apex:pageBlockTable>
                        
                        <apex:pageBlockButtons >
                            <apex:commandButton action="{!saveatt}" value="Save" />
                        </apex:pageBlockButtons>
                    </apex:pageBlock>
                    </apex:outputPanel>              
                </apex:tab>
                
            </apex:tabPanel>
      </apex:form>
       
</apex:page>


Controller:

public class RGMTeacherController {
    public string username {get;set;}
    public string password {get;set;}
    public Boolean showRecords{get;set;}
    public Boolean attbool{get;set;}
    public List<Student__c> studentlist{get;set;}
    public List<Student__c> studentattlist{get;set;}
    public string standard{get;set;}
    public string section{get;set;}
    public string subject{get;set;}
    public string stanatt{get;set;}
    public string secatt{get;set;}
    public string[] sections;
    public string[] standards;
    public string[] subjects;
    public String sfUrl {get;set;}
    public String failingPageResponse { get; set; }

     
    public RGMTeacherController(ApexPages.StandardController controller) {
        attbool = false;
        sfUrl = 'https://c.na34.salesforce.com/';
        Teacher__c TeacherId = [SELECT Id, Name, Email__c, Section__c, Standard__c, Subject__c, Contact_Number__c FROM Teacher__c WHERE Username__c =: username AND Password__c =: password LIMIT 1];
        ApexPages.currentPage().getParameters().put('id', TeacherId.Id);
        sections = TeacherId.Section__c.split(';', 7);
        standards = TeacherId.Standard__c.split(';', 7);
        subjects = TeacherId.Subject__c.split(';', 7);
    }
    public List<SelectOption> getstandarditems() {
        List<SelectOption> standardoptions = new List<SelectOption>();
         for(Integer i=0; i < standards.size(); i++) {
             standardoptions.add(new SelectOption(standards[i], standards[i]));
         }
        return standardoptions;
    }
    
    public String getstandard() {
        return standard;
    }
            
    public void setstandard(String standard) {
        this.standard = standard;
    }
    
    public void fetchFailingPage() {
       try {
           // Make a call to failing sites page here
           failingPageResponse = Page.RGM_Teachers_Page.getContent().toString();
       } catch (Exception e) {
           failingPageResponse = e.getTypeName() + ' : ' + e.getMessage() ;
       }       
    }   
    
    public List<SelectOption> getsectionitems() {
        List<SelectOption> sectionoptions = new List<SelectOption>();
        for(Integer i=0; i < standards.size(); i++) {
             sectionoptions.add(new SelectOption(sections[i], sections[i]));
         }
        return sectionoptions;
    }
    
    public String getsection() {
        return section;
    }
            
    public void setsection(String section) {
        this.section = section;
    }
    
    public List<SelectOption> getsubjectitems() {
        List<SelectOption> subjectoptions = new List<SelectOption>();
        for(Integer i=0; i < subjects.size(); i++) {
             subjectoptions.add(new SelectOption(subjects[i], subjects[i]));
         }
        return subjectoptions;
    }
    
    public String getsubject() {
        return subject;
    }
            
    public void setsubject(String subject) {
        this.subject = subject;
    }
    
    public String getsfurll() {
        return sfURL;      
    }

    public void studentsearch() {
        system.debug('*********************************'+standard);
        studentlist = [SELECT Id, Name, Roll_Number__c FROM Student__c WHERE Standard__c =: standard AND Section__c =: section];
        system.debug('*********************************'+studentlist);
        
    } 
    
    public void makatt() {
        system.debug('***************96******************');
        studentattlist = [SELECT Id, Name, Roll_Number__c FROM Student__c WHERE Standard__c =: stanatt AND Section__c =: secatt];
        system.debug('*********************************'+studentattlist);
        attbool = true;    
    }
    
    public void saveatt() {
              
    }   
    
}
Best Answer chosen by Vijay Kumar Rebbala 11
pconpcon
So if you do not do step 6 do the results appear?  Does simply changing the tab cause them to "appear"?

If so then modifying your page to have this should work.
 
<apex:commandButton action="{!makatt}" value="Search" reRender="xyz" event="onclick"/>

And if that doesn't work, you may want to wrap your apex:outputPanel with an apex:actionRegion to make it more explicit

All Answers

pconpcon
Let me make sure I understand what is happening and what your problem is.
  1. You load the page
  2. Click on the Attendence tab
  3. Click search button
  4. Nothing appears
  5. Click on the Student tab
  6. Choose something
  7. Click on the Attendence tab
  8. Results appear?
If this is the case, it's probably because you are not re-rendering the results list section of your Visualforce page.  If you do the steps above but skip step 6, do the results appear?
Vijay Kumar Rebbala 11Vijay Kumar Rebbala 11
You said right. I'm trying to figure out how to skip the step:6. Did you find any problem in my code?
pconpcon
So if you do not do step 6 do the results appear?  Does simply changing the tab cause them to "appear"?

If so then modifying your page to have this should work.
 
<apex:commandButton action="{!makatt}" value="Search" reRender="xyz" event="onclick"/>

And if that doesn't work, you may want to wrap your apex:outputPanel with an apex:actionRegion to make it more explicit
This was selected as the best answer