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
sowjisowji 

UI issue of Visual force tab

Hi friends,

 

I am newbie to sales force. I created an apex page and attached it to a vf tab. But when the vf tab is selected, the selection is not showing in display.

In apex page (book vehicle),

<apex:page standardController="Vehicle__c"></apex:page>

 

On selection of book vehicle apex page, the Vehicle tab is shown as selected page. Vehicle is a tab attached to vehicle custom object.

 

Please let me know where I am going wrong.

 

Thanks,

Sowjanya

 

 

Best Answer chosen by Admin (Salesforce Developers) 
rohitsfdcrohitsfdc

in the <apex:page> tag, set tabStyle attribute to the name of the VFTABNAME__tab

<apex:page tabStyle="VFTABNAME__tab" >

as in your case, it would be bookvehicle__tab.

 

 

THanks,

Rohit

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 



All Answers

rohitsfdcrohitsfdc

can u please post the code of the VF page

sowjisowji

Hi, Thanks for reply

Pls find the code.

 

<apex:page standardcontroller="Vehicle__c" extensions="VehicleSearch" >
<!-- Javascript function to check all rows in the table -->
<script>
function checkAll(cb)
{
   var inputElem = document.getElementsByTagName("input");
   for(var i=0;i<inputElem.length;i++)
     {
             if(inputElem[i].id.indexOf("selectLine1")!=-1)
                   inputElem[i].checked = cb.checked;
     }
}
</script>
<!-- End of Javascript function -->
<apex:form >
<apex:sectionHeader title="Step 1" subtitle="Select a vehicle to book"/>
<apex:pageblock >
<apex:pageBlockSection title="Search Vehicles" columns="1"></apex:pageBlockSection>

<!-- Div to give a colored box effect -->

<div style="border-width:2px;border-style:solid;border-color:orange;">

    <!-- Panel grid to display boxes o accept user input values -->
    <apex:panelGrid columns="2">
        <apex:outputLabel style="font-weight:bold;" value="Vehicle Stock id" ></apex:outputLabel>
        <apex:inputText value="{!userinput}"/>
        <apex:outputLabel style="font-weight:bold;" value="Vehicle Reg No" ></apex:outputLabel>
        <apex:inputText value="{!userinp}"/>
    </apex:panelGrid>
    <!-- End of panelgrid -->
    <!-- Div to position the commandbutton appropriately -->
        <div style="position:relative;left:75px;">
             <apex:commandButton value="Search" action="{!contactsearch}" />
        </div>
    <!-- End of div -->
        <br/>
</div>

<!-- End of colored box div -->
    <br/>
<!-- Display error message -->
<apex:pagemessage strength="2" title="Error!!" severity="error" detail="Please select a vehicle to proceed" rendered="{!errormsg}"/>
<!-- End of error message -->

<!-- Display search results -->
<apex:pageblocksection columns="1" title="Search results" rendered="{!NOT(ISNULL(results))}" >
  <apex:outputpanel id="Carlist">
        <apex:pageBlockTable value="{!results}" var="car">
             <apex:column >
                 <apex:inputCheckbox value="{!car.selected}" id="selectLine1"/>
             </apex:column>
            <apex:column headervalue="Stock No">
                <apex:outputtext value="{!car.con.Stock_Number__c}"/>
            </apex:column>
            <apex:column headervalue="Reg.No">
                <apex:outputtext value="{!car.con.Registration_number__c}"/>
            </apex:column>
            <apex:column headervalue="Availability">
                <apex:outputtext value="{!car.con.Availability__c}"/>
            </apex:column>
        </apex:pageBlockTable>  <br/><br/>

    </apex:outputpanel>
</apex:pageblocksection>
<!-- End of search results -->

<!-- Commandbutton to proceed to next screen -->
  <div style="position:relative;left:75px;">
      <apex:commandButton value="Book" action="{!processSelected}"/>
      <apex:commandbutton value="Cancel" action="{!Cancel}"/>
  </div>
<!-- End of Commandbutton -->
</apex:pageblock>
</apex:form>
</apex:page>

rohitsfdcrohitsfdc

please attach the code for Extention class VehicleSearch. and it would b really helpful if you give the screenshot of your problem.

 

THanks,

Rohit

sowjisowji

UI Issue

 

The apex page Book Vehicle(VF tab) is selected actually, But in UI it is seen as Vehicle tab(Custom object tab) is selected.

 

Please find my extension class (Vehicle search)

 

public class VehicleSearch{

public VehicleSearch(ApexPages.StandardController controller)
{
 stockid=System.currentPageReference().getParameters().get('id');
}
/* Variable declarations */
Public String stockid;                                                           
public List<cVehicle> vehicleList{get; set;}                                
public Boolean selectAllCheckbox {get; set;}                                 
public boolean errormsg=false;                                               
String userinput;                                                            
String userinp;                                                              

Public boolean displayboxes;

Public List<Vehicle__c> results = new List<Vehicle__c>();                                    
Public List<Vehicle__c> selectedContactsstep2 = new List<Vehicle__c>();            
/* End of Variable declarations */

/* Getter and setter methods for getting the user input from the UI */

public String getuserinput(){return userinput;}
public void setuserinput(String userinp){this.userinput=userinp;}
public String getuserinp(){return userinp;}
public void setuserinp(String userinp){this.userinp=userinp;}


/*End of Getter and Setter methods */



/* Method to Search the */
public List<Contact> contactsearch()
{
     errormsg=false;
     vehicleList= new List<cVehicle>();
     for(Vehicle__c c : [select Stock_Number__c,Registration_number__c,Availability__c from Vehicle__c where Stock_Number__c like :+'%'+userinput+'%' and Registration_number__c like :+'%'+userinp+'%'])
     {
         vehicleList.add(new cVehicle(c));
     }

 return null;
}
/* End of method */


public List<cVehicle> getresults()
{

 return vehicleList;

}


public class cVehicle
{
 public Vehicle__c con {get; set;}
 public Boolean selected {get; set;}

 public cVehicle(Vehicle__c c)
 {
     con = c;
     selected = false;
 }
}

/* Method to fetch the selected records and show booking page*/
public PageReference processSelected()
{

  List<Vehicle__c> selectedContacts = new List<Vehicle__c>();
  if (vehicleList!= null)
  {
     for(cVehicle cCon : getresults()){
        if(cCon.selected == true){
             selectedContacts.add(cCon.con);
         }
     }

     selectedContactsstep2=selectedContacts;
  }
  if (selectedcontacts.size()==0)
 {
     errormsg=true;
     return null;
 }
 else
 {
     errormsg=false;
     String id=System.currentpagereference().getparameters().get('id');
     String stocknum;
     for (Vehicle__c c: selectedcontacts){
         stocknum = c.Stock_Number__c;
     }
     Pagereference p=new Pagereference ('/apex/getDetails_booking?val='+stocknum);
    
     return p;
 }

}
public List<SelectOption> getItems()
{
 List<SelectOption> options = new List<SelectOption>();
 options.add(new SelectOption('YES','YES'));
 options.add(new SelectOption('NO','NO'));
 return options;
}


public boolean geterrormsg()
{
 return errormsg;
}


public Pagereference Cancel()
{
        Pagereference p =new Pagereference('/'+stockid);
        return p;
}
      

}

 

 

 

 

rohitsfdcrohitsfdc

in the <apex:page> tag, set tabStyle attribute to the name of the VFTABNAME__tab

<apex:page tabStyle="VFTABNAME__tab" >

as in your case, it would be bookvehicle__tab.

 

 

THanks,

Rohit

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 



This was selected as the best answer
sowjisowji

Many thanks :-)