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
Varun AnnadataVarun Annadata 

Apex:repeat tag passing multiple values of input field to the list in apex controller

Vf Page
<apex:page standardcontroller="Program_Member_MVN__c" extensions="ProgramMemberCaseAttachment" showHeader="false" >
 <head>
        <apex:includescript value="//code.jquery.com/jquery-1.11.1.min.js" / >
        <apex:includescript value="//cdn.datatables.net/1.10.4/js/jquery.dataTables.min.js" />
        <apex:stylesheet value="//cdn.datatables.net/1.10.4/css/jquery.dataTables.css" />
        <script>
            j$ = jQuery.noConflict();
            j$(document).ready( function () {
                var contactTable = j$('[id$="accounttable"]').DataTable({
                    
                });
            });
        </script>
 </head>
              
            
 
            <apex:form >
            
            <body>
            <table id="accounttable" class="display"  >
            <thead>
                <tr>
                    <th>Save</th>
                    <!--<th>ID</th>-->
                    <th>Type</th>
                    <th>Case Number/PM Number</th>
                    <th>Attachment</th>
                    <th>LastModifiedDate</th>
                    <th>CreatedBy</th>
                    <th>Description</th>
                </tr>
            </thead>
            <tbody>  
            
                    
            
                <apex:variable var="index" value="{!1}"/>
            
                <apex:repeat value="{!wrapAttachmentList}" var="N"> 
                
                    <!--<apex:form>
                
                    <apex:pageBlock>
                
                    <apex:pageBlockTable value="{!PMTyperesults}" var="dimension2">
                    
                    <apex:column value="{!dimension2.Type__c}"/>
                    
                    </apex:pageBlockTable>
                    
                    </apex:pageBlock>
                    
                    </apex:form>-->
                
                    
                    
                       <tr>
            
                        <td><apex:commandLink value="save" action="{!processSelected}">
                        
                        <apex:param name="Attid" value="{!N.At.id}" assignTo="{!Attid}"/>
                        
                        <apex:variable var="index" value="{!index+1}"/>
                                                
                        </apex:commandLink>
                        
                        </td>
                        
                        
                        
                        <td><apex:inputField value="{!N.Att.Type__c}">
                    
                    
                    
                    <!--<apex:param name="AttType" value="{!N.Att.Type__c}" assignTo="{!AttType1}"/>-->
                                                     
                        </apex:inputField> 
                         
                        </td>
                         

                    
                    <!--<td><apex:outputtext value="{!Attid}"/></td>-->
                 
                    
                    <td><apex:outputLink value="/{!N.At.ParentId}" target="_blank">{!N.At.Parent.Name}</apex:outputLink></td> 
                    
                       
                                         
                    <td><apex:outputLink value="/{!N.At.id}" target="_blank">{!N.At.Name}</apex:outputLink></td>
                   
                    <td>{!N.At.LastModifiedDate}</td>
                   
                    <td><apex:outputLink value="/{!N.At.CreatedById}" target="_blank">{!N.At.CreatedBy.Name}</apex:outputLink></td>
                   
                    <td>
                    <apex:outputField value="{!N.At.Description}"/></td>

                    </tr>    
                                                                       
                </apex:repeat>
            </tbody>
            </table>
            </body>
            </apex:form>
</apex:page>

Apex Class
 
/**
 *  ProgramMemberCaseAttachment
 *  Created By:     Varun 
 *  Created On:     11/07/2017
 *  Description:    This class is responsible for displaying Attachment Details
                     Under Each Program Member
 *                  
 **/
public with sharing class ProgramMemberCaseAttachment{

    //public List<Attachment_Type__c> Type{get;set;}

    public string AttType{get;set;}

    public Id Attid{get;set;}

    public List<wrapAttachment> wrapAttachmentList {get; set;}
    
    public List<Attachment> PMresults{get;set;}
    
    public List<Attachment_Type__c> PMTyperesults{get;set;}
    
    public Program_Member_MVN__c cs;
    
    public ProgramMemberCaseAttachment(ApexPages.StandardController controller)
    {
    
    wrapAttachmentList = new List<wrapAttachment>();
    
    cs=(Program_Member_MVN__c)controller.getRecord();
        
    List<case> Test = new List<case>([select id from case where Program_Member_MVN__c =: cs.id]);
    
    System.debug('Test:'+Test);
    
    PMresults = [select CreatedBy.Name,OwnerId,ParentId,Parent.Name,Id,Name,LastModifiedById,CreatedById,LastModifiedDate, Description from Attachment where parentid =: cs.id OR parentid IN:Test ];
    
    for(Attachment a : PMresults) {
            wrapAttachmentList.add(new wrapAttachment(a));
        }

    
    /*PMTyperesults = new List<Attachment_Type__c>();
    
    for(Attachment_Type__c b : PMTyperesults) {
            wrapAttachmentList.add(new wrapAttachment(b));
        }*/

    }
    
    
    
    public void processSelected(){
    
    List<Attachment_Type__c> PMType = new List<Attachment_Type__c>();
    
    Attachment_Type__c At1 = new Attachment_Type__c ();
    
    for(wrapAttachment Wp : wrapAttachmentList ){
    
    if(Wp.Att.Type__c != null){
    
    At1 = [select Type__c from Attachment_Type__c where Attachment_Id__c =: Attid];
    
    if(At1.Type__c  != null){
    
    At1.Type__c  = Wp.Att.Type__c;
    
    }
    
    }
    
    }
    
    PMType.add(At1);
 
          set<Attachment_Type__c> dedupSet = new set<Attachment_Type__c>();
          dedupSet.addAll(PMType);
          List<Attachment_Type__c> dedupList = new List<Attachment_Type__c>();
          dedupList.addAll(dedupSet);
          System.debug('dedupList'+dedupList);
          Update dedupList;
          
          At1 = new Attachment_Type__c();
          
    //update PMType;
    }
     public class wrapAttachment {
        public Attachment At {get; set;}
        public Attachment_Type__c Att{get; set;}
        public string AttType1{get;set;}
 
        public wrapAttachment(Attachment a) {
        
            At = a;
            
            Att = new Attachment_Type__c();
        }
    }
}
I am passing the input field value from vf page to a list in apex class.But the apex:repeat tag is making all the values on the all the rows to get passed into the List in Apex Controller.How can i make value on the row which i select to only get passed?


My Vf page

User-added image