+ Start a Discussion
pupilstuffpupilstuff 

editing rows in pageblock table

Hello,

 

I am badly stuck in one requirement

 

1. in table I have 5 colum named edit(button) , native attribute , webservice attribute , save, cancel

 

2. save and cancel button are invisble at page load

 

2. when user click on edit on particular row the webserive attribute should be replace by picklist ,and save and cancel should be visible

 

Problem

 

when user click on edit for particular row..save , cancel and picklist are getting visible for every row.

 

I just wantto upadte single row not all one

 

VF page

 

 

<apex:page controller="DataMapperControllerTestMay" showHeader="True" sidebar="True">
    <apex:form id="theForm">
       <apex:pageBlock title="Data Mappings">
            <apex:pageBlockSection columns="1" >
                <apex:messages />
            </apex:pageBlockSection>

            <apex:pageBlockTable id="pbt" value="{!Mappings}" var="mapp">
   
                <apex:column headerValue="" >
                    <apex:outputPanel id="Edit" >
                        <apex:commandLink action="{!editActivity}" value="Edit"/> 
                        <apex:param assignTo="{!saveFlag}" value="Edit"/>
      
                    </apex:outputPanel>
                </apex:column>
               
                <apex:column headerValue="Webservice Attributes" value="{!mapp.Source_Name__c}"/>
                <apex:column headerValue="Native Attributes">
                    <apex:outputText value="{!mapp.Source_Name__c}" rendered="{!(!saveFlag)}"/>
                   
                    <apex:outputPanel id="NativeAtt" rendered="{!saveFlag}">                   
                        <apex:pageBlock id="block2" >
                      
                            <apex:outputPanel Id="objList">
                                <apex:pageblocksection >
                                    <apex:selectList id="Test" value="{!selectedObjectStr}" size="1">
                                        <apex:selectOptions value="{!objectNamesList}"/>
                                        <apex:actionSupport event="onchange" rerender="objList,fieldList" action="{!initFieldNamesRef}"/>      
                                    </apex:selectList>
                                       
                                </apex:pageblocksection>      
                            </apex:outputPanel>
                           
                            <apex:outputPanel id="fieldList">
                                <apex:pageblocksection rendered="{!not(isnull(selectedObjectStr))}">
                                    <apex:selectList value="{!selectedFieldStr}" size="1">
                                        <apex:selectOptions value="{!fieldNamesList}"/>
                                    </apex:selectList>
                                </apex:pageblocksection>
                            </apex:outputPanel>
   
                        </apex:pageBlock>
                    </apex:outputPanel>                   

                </apex:column>
               
                <apex:column headerValue="" >
                    <apex:outputPanel id="save" rendered="{!saveFlag}"   >
                        <apex:commandLink action="{!saveActivity}" reRender="objList" value="Save"/>        
                    </apex:outputPanel>
                </apex:column>
               
               
                <apex:column headerValue="" >
                    <apex:outputPanel id="cancel" rendered="{!cancelFlag}" >
                        <apex:commandLink action="{!cancelActivity}" value="Cancel"/>        
                    </apex:outputPanel>
                </apex:column>
               
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

Controller

 

 

public class DataMapperControllerTestMay {
   
    public boolean saveFlag {get;set;}
    public boolean cancelFlag {get;set;}
   
    // Describe
    public Map  <String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    public List <SelectOption> objectNamesList{public get; private set;}
    public String selectedObjectStr {get; set;}
   
    public List <SelectOption> fieldNamesList {get; set;}
    public String selectedFieldStr {get; set;}
   
    // Describe
   
    public PageReference cancelActivity() {
        return null;
    }


    public PageReference saveActivity() {
       
        String targetStr = selectedObjectStr +':'+ selectedFieldStr ;
        System.debug('@@targetStr '+targetStr);

        System.debug('@@GE_B2B_WSDL_Definition__c.getAll()'+GE_B2B_WSDL_Definition__c.getAll());
        B2BFieldMapperManager.addUpdate(Mappings[0].Source_Name__c ,targetStr);
        return null;
    }


    public PageReference editActivity() {
        saveFlag = true;
        cancelFlag = true;
        return null;
    }
       
    public DataMapperControllerTestMay(){
       
        //Describer
        objectNamesList = initObjNames();
        fieldNamesList = new List<SelectOption>();

        //Describer

       Mappings=loadMappings();
    }

    public List<GE_B2B_Field_Mapper__c> Mappings {get;set;}
    public List<GE_B2B_Field_Mapper__c> Vals;
            
    public List<GE_B2B_Field_Mapper__c> loadMappings() {
        Vals = [Select Source_Name__c, Target_Attribute__c, Target_Object__c from GE_B2B_Field_Mapper__c];
        return Vals;
    }
  
   // Describer
  
    private List<SelectOption> initObjNames() {
        List<SelectOption> objNamesList = new List<SelectOption>();
        List<String> entitiesList = new List<String>(schemaMap.keySet());
        entitiesList.sort();
        for(String nameStr : entitiesList)
            objNamesList.add(new SelectOption(nameStr,nameStr));
            return objNamesList;
    }
   
    public pageReference initFieldNamesRef(){
      initFieldNames();
      return null;
    }
   
    public List<SelectOption> initFieldNames() {
        Map <String, Schema.SObjectField> fieldMap = schemaMap.get(selectedObjectStr).getDescribe().fields.getMap();
        fieldNamesList.clear();
        for(String nameFieldStr : fieldMap.keyset()){
            fieldNamesList.add(new SelectOption(nameFieldStr ,nameFieldStr));
        }
            return fieldNamesList;
    }
   
   // Describer
 
}