I've a grid view for adding multiple leads with controller and helper class, it works Ok, but I need to add the same value for the whole list, that value will be added by the user into the rich textarea, I added preview button to render the added text into outputText but it didn't work ! I copied the input and output fields only to new visualforce page and it worked, but in this page didn't. By the way what I'm trying to do is, add the value of the textarea input for all leads I need to add the value in Additional_email_notes__c field I added it in hidden input into table. how can I pass the value from textarea in it.

<apex:inputHidden id="hiddenemailnotes"


public with sharing class AddMultipleLeadCLS {
    public String additionalText {set;get;}

    public PageReference SaveMultipleLeads() {
     return null;

     public List<WrapperpaLeadList> waAccList {get;set;}
     public Integer rowToRemove {get;set;}

     public AddMultipleLeadsCLS(){
      waAccList = new List<WrapperpaLeadList>();
     public void removeRowFromAccList() {
      waAccList = AddMultipleAccountHelperCLS.removeRowToLeadList(rowToRemove, waAccList);


     public void addNewRowToAccList(){
         waAccList = AddMultipleLeadHelperCLS.addNewRowToAccList(waAccList);

     public class WrapperpaLeadList {
            public Integer index {get;set;}
            public Lead record {get;set;}

Helper Class

public class AddMultipleLeadHelperCLS {

    public static List<AddMultipleLeadCLS.WrapperpaLeadList> addNewRowToAccList(List<AddMultipleLeadCLS.WrapperpaLeadList> waAccObjList){
        AddMultipleLeadCLS.WrapperpaLeadList newRecord = new AddMultipleLeadCLS.WrapperpaLeadList();
        Lead newLeadRecord = new Lead();     
        newRecord.record = newLeadRecord;
        newRecord.index = waAccObjList.size();
        return waAccObjList;

     public static List<AddMultipleLeadCLS.WrapperpaLeadList> removeRowToLeadList(Integer rowToRemove, List<AddMultipleLeadCLS.WrapperpaLeadList> waLeadList){
        return waLeadList;

    public static void save(List<AddMultipleLeadCLS.WrapperpaLeadList> waAccList) {
        List<Lead> leadRecordsToBeInserted = new List<Lead>();
        if(waAccList !=null && !waAccList.isEmpty()){
            for(AddMultipleLeadCLS.WrapperpaLeadList eachRecord : waAccList ){
                Lead accTemp = eachRecord.record;

       insert leadRecordsToBeInserted;

Visualforce Page

 <apex:pageblock id="thePB" title="Creating Multiple Leads">

  <apex:outputPanel id="leadHead">
  <apex:variable value="{!0}" var="rowNum"/>  

   <apex:pageBlockSection title="Adding Multiple Leads" id="thePbs"> 

     <apex:pageBlockTable value="{!waAccList}" var="eachRecord"> 

      <apex:column headerValue="Action">
        <apex:commandLink value="Remove"
                          rendered="{!rowNum > 0}"
                          immediate="true" >
            <apex:param value="{!rowNum}"
         <apex:variable var="rowNum" value="{!rowNum + 1}"/>

      <apex:column headerValue="First Name">
          <apex:inputField value="{!eachRecord.record.firstname}"/>

      <apex:column headerValue="Email">
          <apex:inputField value="{!eachRecord.record.email}"/>
       <apex:inputHidden id="hiddenemailnotes" value="{!eachRecord.record.Additional_email_notes__c}"/>

   <apex:commandButton value="Add More" action="{!addNewRowToAccList}" rerender="leadHead" immediate="true" />


  <apex:commandButton styleClass="sbmtbtn" value="Save list" action="{!SaveMultipleLeads}"/>

   <apex:pageBlockSection columns="1" title="Additional Email Notes" collapsible="False">
       <apex:inputTextarea value="{!additionalText}" richText="true" rows="8"/>
       <apex:commandButton immediate="true"

       <apex:outputText value="{!additionalText}" id="previewadded"></apex:outputText>


In your save method do this.

List<Lead> leadRecordsToBeInserted = new List<Lead>();
        if(waAccList !=null && !waAccList.isEmpty()){
            for(AddMultipleLeadCLS.WrapperpaLeadList eachRecord : waAccList ){
                Lead accTemp = eachRecord.record;
                acctemp.Additional_email_notes__c  = additionalText;

       insert leadRecordsToBeInserted;

It will store the addittional text are field to all records.

  • Ok thanks it works after I passed the additionalText with the list to save method. but If you've an Idea why the value not re rendered into output text when click on preview button ?? Jan 21 '16 at 12:15
  • @user3003810 not sure but maybe because you are using immediate="true" attribute. Also if it solve your problem you can accept this answer and mark it close. Jan 21 '16 at 12:45
  • Hummm, I removed it and issue still there, I have no idea about this problem why occur in this page. but thanks for your answer it solved my main issue. Jan 21 '16 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.