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
ledap13ledap13 

When I press my list then it will be overwritten

Hi Friends,

 

can you help me?

 

 

<apex:page standardController="Contact" extensions="contactExtension" standardStylesheets="true">
<apex:pagemessages />
    <apex:sectionHeader title="Test für Trigger Quotes " subtitle="{!Contact.Name}" help="/help/doc/user_ed.jsp?loc=help"> </apex:sectionHeader>
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageBlockSection title="Accounts" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account Name" for="acc" />
                    <apex:selectList id="acc" value="{!optionacc}" size="1" title="Account">
                        <apex:selectOptions value="{!accts}"/>
                        <apex:actionSupport event="onchange" action="{!selectionAcc}"/>   
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                        <apex:selectList value="{!optioncon}" size="1" title="Account" >
                            <apex:selectOptions value="{!conts}" ></apex:selectOptions>
                        </apex:selectList>
                </apex:pageBlockSectionItem>                   
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Information" >
                <apex:dataTable value="{!listOpportunity}" var="item" >
                    <apex:column >
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.Name.label}</apex:facet>
                        <apex:inputfield value="{!item.Name} "></apex:inputfield>
                    </apex:column><apex:column >    
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.StageName.label}</apex:facet>                        
                        <apex:inputfield value="{!item.StageName}"></apex:inputfield>
                    </apex:column><apex:column >   
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.Probability .label}</apex:facet>                         
                        <apex:inputfield value="{!item.Probability }"></apex:inputfield>
                    </apex:column>
                </apex:dataTable>                            
            </apex:pageBlockSection>  
        </apex:pageBlock>
    </apex:form>
</apex:page>

Best Answer chosen by Admin (Salesforce Developers) 
digamber.prasaddigamber.prasad

Hi,

 

Looks like I found the solution. You have left 'rerender'  option in 'actionSupport' tab, assuming that you want to refresh 'Information' pageBlockSection,I have modified your vf page and its not more setting list of account to '-None-' after selectinng an account.

 

In below code snippet, I have marked the difference with red color.

 

 

 

<apex:page standardController="Contact" extensions="contactExtension" standardStylesheets="true">
	<apex:pagemessages />
    <apex:sectionHeader title="Test für Trigger Quotes " subtitle="{!Contact.Name}" help="/help/doc/user_ed.jsp?loc=help"> </apex:sectionHeader>
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageBlockSection title="Accounts" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account Name" for="acc" />
                    <apex:selectList id="acc" value="{!optionacc}" size="1" title="Account">
                        <apex:selectOptions value="{!accts}"/>
                        <apex:actionSupport event="onchange" action="{!selectionAcc}" rerender="idInformation"/>   
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                        <apex:selectList value="{!optioncon}" size="1" title="Account" >
                            <apex:selectOptions value="{!conts}" ></apex:selectOptions>
                        </apex:selectList>
                </apex:pageBlockSectionItem>                   
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Information"  id="idInformation">
                <apex:dataTable value="{!listOpportunity}" var="item" >
                    <apex:column >
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.Name.label}</apex:facet>
                        <apex:inputfield value="{!item.Name} "></apex:inputfield>
                    </apex:column><apex:column >    
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.StageName.label}</apex:facet>                        
                        <apex:inputfield value="{!item.StageName}"></apex:inputfield>
                    </apex:column><apex:column >   
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.Probability .label}</apex:facet>                         
                        <apex:inputfield value="{!item.Probability }"></apex:inputfield>
                    </apex:column>
                </apex:dataTable>                            
            </apex:pageBlockSection>  
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Let me know if it doesn't work for you.

 

Happy to help you!

 

Regards,

Digamber Prasad

 

 

All Answers

digamber.prasaddigamber.prasad

Hi,

 

Could you please share code of your extension?

 

Regards,

Digamber Prasad

ledap13ledap13

My Extension:

 

public class contactExtension {
    private final Contact c; //User sobject
    private Account oneopp {get;set;}
    public List<Opportunity> listOpportunity {get;set;}
    public List<Quote> listQuotes {get;set;}    
    public string optionacc{get;set;}
    public string optioncon{get;set;}
    private string accountid {get;set;}
    Boolean showSecvar = false;
    Boolean showListvar = false;
    
    //initializes the private member variable u by using the getRecord method from the standard controller
    public contactExtension(ApexPages.StandardController stdController) {
        this.c = (Contact)stdController.getRecord();
    }
    
    //builds a picklist of account names based on their account id
    public List<selectOption> getaccts() {
        List<selectOption> accts = new List<selectOption>();
            accts.add(new selectOption('', '- None -'));
            for (Account account : [SELECT Id, Name FROM Account]) {
            accts.add(new selectOption(account.id, account.Name));
        }
        return accts; //return the picklist options
    }
    
    public List<selectOption> getconts() {
        List<selectOption> conts = new List<selectOption>();
            conts.add(new selectOption('', '- None -'));
            for (Contact contact : [SELECT Id, Name FROM Contact where AccountId = :optionacc]) {
            conts.add(new selectOption(contact.id, contact.Name));
        }
        return conts; //return the picklist options
    }     
    
    //select von Auswahlliste Account    
    public pagereference selectionAcc(){
        ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info,'No Empty 1!!'+optionacc));     
        //showSection();
        optionacc = accountid;    
        return null;
    }
    
    //select von Auswahlliste Contact
    public pagereference selectionCon(){
        ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info,'No Empty 2!!'+optionacc));
        //showSection();
        optioncon = accountid;
        return null;
    }    

    public List<selectOption> getopps() {
        List<selectOption> opps= new List<selectOption>();
            opps.add(new selectOption('', '- None -'));
            for (Opportunity opportunity : [SELECT Id, Name FROM Opportunity where AccountId = :optionacc]) {
            opps.add(new selectOption(Opportunity.Id, Opportunity.Name));
        }
        return opps; //return the picklist options
    }

    public pagereference showlistopps(){
        ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info,'No Empty 2!!'+optionacc));
        oneopp = [SELECT Id, Name FROM Account WHERE name  = 'AMEH' LIMIT 1];
        listOpportunity = [SELECT ID,Name,StageName,Probability FROM Opportunity WHERE AccountId =:optionacc LIMIT 50000];
        showInfList();
        return null;
    }    

    public pagereference showlistqoutes(){
        ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.Info,'No Empty 3!!'+optionacc));
        listQuotes = [SELECT QuoteNumber, Name, Discount FROM Quote LIMIT 50000];
        showInfList();
        return null;
    }     
    public void showSection() {showSecvar = true;}
    public Boolean getSectionshow(){return showSecvar;}  
    
    public void showInfList(){showListvar = true;}
    public Boolean getInfListshow(){return showListvar;}   
}

digamber.prasaddigamber.prasad

Hi,

 

Looks like I found the solution. You have left 'rerender'  option in 'actionSupport' tab, assuming that you want to refresh 'Information' pageBlockSection,I have modified your vf page and its not more setting list of account to '-None-' after selectinng an account.

 

In below code snippet, I have marked the difference with red color.

 

 

 

<apex:page standardController="Contact" extensions="contactExtension" standardStylesheets="true">
	<apex:pagemessages />
    <apex:sectionHeader title="Test für Trigger Quotes " subtitle="{!Contact.Name}" help="/help/doc/user_ed.jsp?loc=help"> </apex:sectionHeader>
    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageBlockSection title="Accounts" >
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Account Name" for="acc" />
                    <apex:selectList id="acc" value="{!optionacc}" size="1" title="Account">
                        <apex:selectOptions value="{!accts}"/>
                        <apex:actionSupport event="onchange" action="{!selectionAcc}" rerender="idInformation"/>   
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                        <apex:selectList value="{!optioncon}" size="1" title="Account" >
                            <apex:selectOptions value="{!conts}" ></apex:selectOptions>
                        </apex:selectList>
                </apex:pageBlockSectionItem>                   
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Information"  id="idInformation">
                <apex:dataTable value="{!listOpportunity}" var="item" >
                    <apex:column >
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.Name.label}</apex:facet>
                        <apex:inputfield value="{!item.Name} "></apex:inputfield>
                    </apex:column><apex:column >    
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.StageName.label}</apex:facet>                        
                        <apex:inputfield value="{!item.StageName}"></apex:inputfield>
                    </apex:column><apex:column >   
                        <apex:facet name="header">{!$ObjectType.Opportunity.fields.Probability .label}</apex:facet>                         
                        <apex:inputfield value="{!item.Probability }"></apex:inputfield>
                    </apex:column>
                </apex:dataTable>                            
            </apex:pageBlockSection>  
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Let me know if it doesn't work for you.

 

Happy to help you!

 

Regards,

Digamber Prasad

 

 

This was selected as the best answer