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
Sunil mSunil m 

Not able to get pageBlockTable values

Hi all ,

I have List<SelectOption> , By using PageBlockTable I displayed all values of List<SelectOption> in a InputText because I need to edit all values and when I click on button it should save in same List.So now my problem is I am able to display values but not able to get modified values and save . 

please help me in doing this ..

Dhaval PanchalDhaval Panchal
Can you please copy your vf page and controller code here?
Sunil mSunil m

<apex:page standardController="Request__c" extensions="Test">

<apex:form>
<apex:pageBlockTable value="{!possibleValues}" var="v">
<apex:inputText value="{!v.value}"/>

</apex:pageBlockTable>
<apex:commandLink action="{!addValue}" value ="add"/>//this is to add new entry
<apex:commandButton action="saveValues" value="save"/>
</apex:form>

</apex:page>

 

controller
---------
public with sharing class Test {
public List<SelectOption> possibleValues {get;set;}
public Test(ApexPages.StandardController controller){
possibleValues = new List<SelectOption>() ;
possibleValues.add(new SelectOption('xyz','xyz');
possibleValues.add(new SelectOption('abc','abc');
}
public void addValue(){
possibleValues.add(new SelectOption('',''));

}
public PageReference saveValues(){
//Logic to get values from PageBlockTable and save in possibleValues
return null;

}

Dhaval PanchalDhaval Panchal
see below line

<apex:commandButton action="saveValues" value="save"/>

change it to

<apex:commandButton action="{!saveValues}" value="save"/>
Sunil mSunil m

<apex:form>
<apex:pageBlockTable value="{!possibleValues}" var="v">
<apex:column>
<apex:inputText value="{!v.value}"/>
</apex:column>
</apex:pageBlockTable>
<apex:commandLink action="{!addValue}" value ="add"/>//this is to add new entry
<apex:commandButton action="{!saveValues}" value="save"/>
</apex:form>

controller
---------
public with sharing class Test {
public List<SelectOption> possibleValues {get;set;}
public Test(ApexPages.StandardController controller){
possibleValues = new List<SelectOption>() ;
possibleValues.add(new SelectOption('xyz','xyz');
possibleValues.add(new SelectOption('abc','abc');
}
public void addValue(){
possibleValues.add(new SelectOption('',''));

}
public PageReference saveValues(){
//Logic to get values from PageBlockTable and save in possibleValues
return null;

}

 

still not able todo

 

 

 

 

Dhaval PanchalDhaval Panchal
Are you inserting these values to any object? Why are you using SelectOption? you can use object directly. Please give some more detail.
Sunil mSunil m

I must store in SelectOption List because this SelectOption List can be passed as input to check boxes ,selectList,SelectRadio depends on condition . 

Dhaval PanchalDhaval Panchal
I am not getting your actual requirement. Please describe how you want to store record (what it your object structure)