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
prasanth kumarprasanth kumar 

wrapper class checkbox selcted rows are not displaying

After filling the rows if i select the specific checkboxes then click on displayvalues button then the data not showing in the 3rd pageblock table. please solve this.   User-added image
 
<apex:page controller="mytextboxwrapper">
    <Apex:form >
    <apex:pageblock >
        <apex:pageblocktable value="{!mt}" var="a" >
                    <apex:column ><apex:inputcheckbox value="{!a.value3}" /> </apex:column>

            <apex:column ><apex:inputtext value="{!a.value1}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.value2}" /> </apex:column>
            <apex:column ><apex:inputtext value="{!a.value3}" /> </apex:column>
        </apex:pageblocktable>
        <apex:commandButton value="display values"  />
        <apex:commandButton value="display values"  action="{!exactdata}"/>

        

        </apex:pageblock>
        
         <apex:pageblock title="output data" >
        <apex:pageblocktable value="{!mt}" var="a" >
            <apex:column ><apex:outputtext value="{!a.value1}" /></apex:column>
            <apex:column value="{!a.value2}" > </apex:column>
            <apex:column value="{!a.value3}" > </apex:column>
        </apex:pageblocktable>
        </apex:pageblock>
        
          <apex:pageblock title="Selected Data" >
        <apex:pageblocktable value="{!mtt}" var="a" >
            <apex:column ><apex:outputtext value="{!a.value1}" /></apex:column>
            <apex:column value="{!a.value2}" > </apex:column>
            <apex:column value="{!a.value3}" > </apex:column>
        </apex:pageblocktable>
        </apex:pageblock>
                  
    </Apex:form>
</apex:page>















public class mytextboxwrapper {

    public list<mytext> mt{set;get;}
        public list<mytext> mtt{set;get;}

    public mytextboxwrapper()
    {
        mt=new list<mytext>();
        
        for(integer i=0;i<5;i++)
        {
        mytext m1=new mytext();
        mt.add(m1);
        }
      }  
     public void exactdata()
     {
        mtt=new list<mytext>();
        
        for(mytext mtemp:mt)
        {
        if(mtemp.flag==true)
        {
            
             mtt.add(mtemp);
        }
        }
        
     }
    public class mytext {
        
        public string value1{Set;get;}
        public string value2{set;get;}
        public string value3{set;get;}
        public boolean flag{Set;get;}
    }    
}

 
Best Answer chosen by prasanth kumar
James LoghryJames Loghry
You're never setting the flag field, which you use to populate the mtt list. 

Replace the first column in your first page block:
 
<apex:column ><apex:inputcheckbox value="{!a.value3}" /> </apex:column>


with:
 
<apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>

Also, please learn how to read your own code, as this was an obvious issue that you could easily fix.

All Answers

James LoghryJames Loghry
You're never setting the flag field, which you use to populate the mtt list. 

Replace the first column in your first page block:
 
<apex:column ><apex:inputcheckbox value="{!a.value3}" /> </apex:column>


with:
 
<apex:column ><apex:inputcheckbox value="{!a.flag}" /> </apex:column>

Also, please learn how to read your own code, as this was an obvious issue that you could easily fix.
This was selected as the best answer
prasanth kumarprasanth kumar
U r aresome............  thank u bro.......... 
prasanth kumarprasanth kumar
hi bro, i want to add some javascript code to the above vf page  pageblocktable columns.  if i enter integer value in 1st and 2nd column then the result value should be displayes in 3rd column.   please help me.