• Mayank Rana
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Hi All,

I want the selected picklist value along with there domain(using <apex:param>) displayed in the below <apex:pageBlockSection> Title. I have two  picklist ,As I select the value from another picklist the previous count value and domain both must be updated. But In my case count value for the first picklist value displayed null, but the last picklist slected value in displayed fine. I didnt understand its behavior. I am sending VisualForce Page and Controller.. Please give the solution
soon please..
Thanks in advance.

VisualForce Page:
<apex:page controller="Custom_Picklist" tabStyle="Contact">
    <apex:form >
        <apex:pageBlock >
            <h1>Salesforce</h1>
            <apex:selectList size="1" value="{!count}">
                                <apex:selectOptions value="{!numberOfQuestions }"/>
                                    <apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
                                        <apex:param name="Domain" value="Salesforce" assignTo="{!Domain}" />
                                    </apex:actionSupport>
                             </apex:selectList>
                             
              <h1>PHP</h1>
            <apex:selectList size="1" value="{!count}">
                                <apex:selectOptions value="{!numberOfQuestions }"/>
                                    <apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
                                        <apex:param name="Domain" value="PHP" assignTo="{!Domain}" />
                                    </apex:actionSupport>
                             </apex:selectList>
        <apex:pageBlockSection title="{!message}" id="abcd">
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class Custom_Picklist
{
    public String count { get;set;}
    public String Domain { get; set; }
    public String message {get;set;}
    
    public List<SelectOption> numberOfQuestions {get;set;}
    public String selected {get;set;}
    public Custom_Picklist()
    {
        message='';
        this.getnumberOfQuestions();     
    }
    
    public List<SelectOption> getnumberOfQuestions()
    {
        numberOfQuestions = new List<SelectOption>();
        numberOfQuestions.add(new SelectOption('','--None--'));
        numberOfQuestions.add(new SelectOption('5','5'));
        numberOfQuestions.add(new SelectOption('10','10'));
        numberOfQuestions.add(new SelectOption('20','20'));
        numberOfQuestions.add(new SelectOption('30','30'));
        
        return  numberOfQuestions;
    }
    
    public void showQuestions()
    {
        message=Domain+'_'+count;
    }
}
public class BikeController
{

    public BikeController() {}

    public Sell_Your_Bike__c bike{set;get;}
 
    public BikeController(ApexPages.StandardController std)
    {
        this.bike=(Sell_Your_Bike__c)std.getRecord();
    }
    
    public Sell_Your_Bike__c saveRecord()
    {
        Sell_Your_Bike__c bike=new Sell_Your_Bike__c
        (
            Registration_Number__c=bike.Registration_Number__c,
            Owner_Name__c=bike.Owner_Name__c,
            Model__c=bike.Model__c,
            Mileage__c=bike.Mileage__c,
            Cubic_Capicity__c=bike.Cubic_Capicity__c,
            Fuel_Capacity__c=bike.Fuel_Capacity__c,
            Speedometer__c=bike.Speedometer__c,
            Disk_Brake__c=bike.Disk_Brake__c,
            Tubeless_Tyres__c=bike.Tubeless_Tyres__c,
            Alloys__c=bike.Alloys__c,
            Price__c=bike.Price__c,
            Contact_Number__c=bike.Contact_Number__c
        );
        
        Insert bike;
        return bike;
    }
    
    public PageReference save()
    {    
        Sell_Your_Bike__c bike= this.saveRecord();
        PageReference pg=null;
        if(!bike.Id.equals(NULL))
        {
            pg=new PageReference('/apex/Bike_SuccessPage?ID='+bike.Id+'&NAME='+bike.Owner_Name__c);
            pg.setRedirect(true);
            return pg;
        }
        else
        {
            pg=Page.Bike_FailurePage;
            pg.setRedirect(true);
            return pg;
        }
    }
    
    public PageReference save_new()
    {
        Sell_Your_Bike__c bike= this.saveRecord();
        PageReference pg=null;
        if(!bike.Id.equals(NULL))
        {
            pg=new PageReference('/apex/VFP_BikeSell');
            pg.setRedirect(true);
        }
        return pg;        
    }
    
    public PageReference cancel()
    {
        PageReference pg=new PageReference('/apex/VFP_BikeSell');
        pg.setRedirect(true);
        return pg;
    }
    
}
public class BikeController
{

    public BikeController() {}

    public Sell_Your_Bike__c bike{set;get;}
 
    public BikeController(ApexPages.StandardController std)
    {
        this.bike=(Sell_Your_Bike__c)std.getRecord();
    }
    
    public Sell_Your_Bike__c saveRecord()
    {
        Sell_Your_Bike__c bike=new Sell_Your_Bike__c
        (
            Registration_Number__c=bike.Registration_Number__c,
            Owner_Name__c=bike.Owner_Name__c,
            Model__c=bike.Model__c,
            Mileage__c=bike.Mileage__c,
            Cubic_Capicity__c=bike.Cubic_Capicity__c,
            Fuel_Capacity__c=bike.Fuel_Capacity__c,
            Speedometer__c=bike.Speedometer__c,
            Disk_Brake__c=bike.Disk_Brake__c,
            Tubeless_Tyres__c=bike.Tubeless_Tyres__c,
            Alloys__c=bike.Alloys__c,
            Price__c=bike.Price__c,
            Contact_Number__c=bike.Contact_Number__c
        );
        
        Insert bike;
        return bike;
    }
    
    public PageReference save()
    {    
        Sell_Your_Bike__c bike= this.saveRecord();
        PageReference pg=null;
        if(!bike.Id.equals(NULL))
        {
            pg=new PageReference('/apex/Bike_SuccessPage?ID='+bike.Id+'&NAME='+bike.Owner_Name__c);
            pg.setRedirect(true);
            return pg;
        }
        else
        {
            pg=Page.Bike_FailurePage;
            pg.setRedirect(true);
            return pg;
        }
    }
    
    public PageReference save_new()
    {
        Sell_Your_Bike__c bike= this.saveRecord();
        PageReference pg=null;
        if(!bike.Id.equals(NULL))
        {
            pg=new PageReference('/apex/VFP_BikeSell');
            pg.setRedirect(true);
        }
        return pg;        
    }
    
    public PageReference cancel()
    {
        PageReference pg=new PageReference('/apex/VFP_BikeSell');
        pg.setRedirect(true);
        return pg;
    }
    
}
Hi All,

I want the selected picklist value along with there domain(using <apex:param>) displayed in the below <apex:pageBlockSection> Title. I have two  picklist ,As I select the value from another picklist the previous count value and domain both must be updated. But In my case count value for the first picklist value displayed null, but the last picklist slected value in displayed fine. I didnt understand its behavior. I am sending VisualForce Page and Controller.. Please give the solution
soon please..
Thanks in advance.

VisualForce Page:
<apex:page controller="Custom_Picklist" tabStyle="Contact">
    <apex:form >
        <apex:pageBlock >
            <h1>Salesforce</h1>
            <apex:selectList size="1" value="{!count}">
                                <apex:selectOptions value="{!numberOfQuestions }"/>
                                    <apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
                                        <apex:param name="Domain" value="Salesforce" assignTo="{!Domain}" />
                                    </apex:actionSupport>
                             </apex:selectList>
                             
              <h1>PHP</h1>
            <apex:selectList size="1" value="{!count}">
                                <apex:selectOptions value="{!numberOfQuestions }"/>
                                    <apex:actionSupport event="onchange" action="{!showQuestions}" reRender="abcd">
                                        <apex:param name="Domain" value="PHP" assignTo="{!Domain}" />
                                    </apex:actionSupport>
                             </apex:selectList>
        <apex:pageBlockSection title="{!message}" id="abcd">
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller:
public class Custom_Picklist
{
    public String count { get;set;}
    public String Domain { get; set; }
    public String message {get;set;}
    
    public List<SelectOption> numberOfQuestions {get;set;}
    public String selected {get;set;}
    public Custom_Picklist()
    {
        message='';
        this.getnumberOfQuestions();     
    }
    
    public List<SelectOption> getnumberOfQuestions()
    {
        numberOfQuestions = new List<SelectOption>();
        numberOfQuestions.add(new SelectOption('','--None--'));
        numberOfQuestions.add(new SelectOption('5','5'));
        numberOfQuestions.add(new SelectOption('10','10'));
        numberOfQuestions.add(new SelectOption('20','20'));
        numberOfQuestions.add(new SelectOption('30','30'));
        
        return  numberOfQuestions;
    }
    
    public void showQuestions()
    {
        message=Domain+'_'+count;
    }
}
public class BikeController
{

    public BikeController() {}

    public Sell_Your_Bike__c bike{set;get;}
 
    public BikeController(ApexPages.StandardController std)
    {
        this.bike=(Sell_Your_Bike__c)std.getRecord();
    }
    
    public Sell_Your_Bike__c saveRecord()
    {
        Sell_Your_Bike__c bike=new Sell_Your_Bike__c
        (
            Registration_Number__c=bike.Registration_Number__c,
            Owner_Name__c=bike.Owner_Name__c,
            Model__c=bike.Model__c,
            Mileage__c=bike.Mileage__c,
            Cubic_Capicity__c=bike.Cubic_Capicity__c,
            Fuel_Capacity__c=bike.Fuel_Capacity__c,
            Speedometer__c=bike.Speedometer__c,
            Disk_Brake__c=bike.Disk_Brake__c,
            Tubeless_Tyres__c=bike.Tubeless_Tyres__c,
            Alloys__c=bike.Alloys__c,
            Price__c=bike.Price__c,
            Contact_Number__c=bike.Contact_Number__c
        );
        
        Insert bike;
        return bike;
    }
    
    public PageReference save()
    {    
        Sell_Your_Bike__c bike= this.saveRecord();
        PageReference pg=null;
        if(!bike.Id.equals(NULL))
        {
            pg=new PageReference('/apex/Bike_SuccessPage?ID='+bike.Id+'&NAME='+bike.Owner_Name__c);
            pg.setRedirect(true);
            return pg;
        }
        else
        {
            pg=Page.Bike_FailurePage;
            pg.setRedirect(true);
            return pg;
        }
    }
    
    public PageReference save_new()
    {
        Sell_Your_Bike__c bike= this.saveRecord();
        PageReference pg=null;
        if(!bike.Id.equals(NULL))
        {
            pg=new PageReference('/apex/VFP_BikeSell');
            pg.setRedirect(true);
        }
        return pg;        
    }
    
    public PageReference cancel()
    {
        PageReference pg=new PageReference('/apex/VFP_BikeSell');
        pg.setRedirect(true);
        return pg;
    }
    
}
difference between "Trigger.New" and "Trigger.old".