You need to sign in to do that
Don't have an account?
Giri Kumar B
when check box is check to add button click same page display value
when the check box is click one the record only That Record only display . But my code is when i check the check box select all the record after dispaly all record . i want only when which one check box click record that record only display
ApexClass:
public class SetExample{
public List<string> lNames{set;get;}
public List<string> rNames{set;get;}
public boolean flag{set;get;}
public SetExample(){
lNames= new List<string>{'satya','manu','reddy','peeri'};
rNames=new List<string>();
flag=false;
}
public void AddValues(){
for(integer i=0;i<lNames.size();i++)
{
string value;
if(flag==true)
{
value=lNames.get(i);
rNames.add(value);
}
system.debug(rNames);
}
}
}
Visual Force Page
<apex:page controller="SetExample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="add" action="{!AddValues}" reRender="one"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageblock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lNames}" var="n">
<apex:column >
<apex:inputCheckbox value="{!flag}"/>
</apex:column>
<apex:column value="{!n}" />
</apex:pageBlockTable>
<apex:pageBlockTable value="{!rNames}" var="r" id="one">
<apex:column value="{!r}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
{!flag}
</apex:page>
ApexClass:
public class SetExample{
public List<string> lNames{set;get;}
public List<string> rNames{set;get;}
public boolean flag{set;get;}
public SetExample(){
lNames= new List<string>{'satya','manu','reddy','peeri'};
rNames=new List<string>();
flag=false;
}
public void AddValues(){
for(integer i=0;i<lNames.size();i++)
{
string value;
if(flag==true)
{
value=lNames.get(i);
rNames.add(value);
}
system.debug(rNames);
}
}
}
Visual Force Page
<apex:page controller="SetExample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="add" action="{!AddValues}" reRender="one"/>
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageblock >
<apex:pageBlockSection >
<apex:pageBlockTable value="{!lNames}" var="n">
<apex:column >
<apex:inputCheckbox value="{!flag}"/>
</apex:column>
<apex:column value="{!n}" />
</apex:pageBlockTable>
<apex:pageBlockTable value="{!rNames}" var="r" id="one">
<apex:column value="{!r}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
{!flag}
</apex:page>
Andrew Echevarria
Try adding the line below to the beginning of the AddValues function, otherwise when it adds a value for one checkbox, it doesn't remove it and the value stays when it is not needed later.