public class ControllerClass { public boolean cbvalue{get;set;} public ControllerClass() { if(name.equals('SomeString') cbvalue=true; else cbvalue=false; } }
My code is as below. I want to change the value of Required__c based on the Role__c and i already have one standard controller in the class.i am using it for other purpose.as you suggested to add the boolean method but it is giving an error for sobject so also i am using input field and not checkbox.
public with sharing class DetailController { public List<Appr__c> appr; public Detail__c Detail {get; set;}
public DetailController (ApexPages.StandardController pCon) { Detail =(Detail__c)pCon.getRecord(); Detail = [SELECT Id, Name FROM Detail__c WHERE ID = :Detail.Id]; }
In the constructor of your VFpage's Controller class, you have to set the value field of checkbox according to the name.
That's all.
If there is getter setter for the checkbox . assign the value to the them in the Constructor ..
Constructor (){
inputcheckbox = true ;
}
You can perform the same thing with the Java script too .
Thank you both!
Can you guys please provide an example so that i can get some idea?
I am new to it..
Class
public class ControllerClass
{
public boolean cbvalue{get;set;}
public ControllerClass()
{
if(name.equals('SomeString')
cbvalue=true;
else
cbvalue=false;
}
}
Visualforce Page
<apex:page controller="ControllerClass">
<apex:form>
<apex:inputCheckBox value="{!cbvalue}"/>
</apex:form>
</apex:page>
This may solve your issue.
Thanks
Hi Anil,
Thanks for quick response.
My code is as below. I want to change the value of Required__c based on the Role__c and i already have one standard controller in the class.i am using it for other purpose.as you suggested to add the boolean method but it is giving an error for sobject so also i am using input field and not checkbox.
Can you please guide? Thanks for all your help.
<apex:page standardController="Detail__c"
extensions="DetailController" >
<apex:repeat value="{!appr}" var="item">
<apex:pageBlockSection title="{!item.Role__c}" id="ItemBlock" columns="2">
<apex:inputField value="{!item.Required__c}" /></br>
public with sharing class DetailController {
public List<Appr__c> appr;
public Detail__c Detail {get; set;}
public DetailController (ApexPages.StandardController pCon) {
Detail =(Detail__c)pCon.getRecord();
Detail = [SELECT Id, Name FROM Detail__c
WHERE ID = :Detail.Id];
}
Hi
Rajashri
First of all u have used public List<Appr__c> appr in page.But you i dont see any assignmet to that list in class.please assign objects to that list
Thanks
ANil
<apex:page standardController="Detail__c" extensions="DetailController" >
<apex:repeat value="{!appr}" var="item">
<apex:pageBlockSection title="{!item.Role__c}" columns="2">
<apex:inputField value="{!item.Required__c}" />
</apex:pageBlockSection>
</apex:repeat>
</apex:page>
What is the field type of Required__c in sobject? Checkbox or Text.
Hi Anil,
I have already assign the objects to list and it works fine.
Also Required__c object has the datatype checkbox.
Can you please guide me how to proceed?
If it is possible send me your complete new code of page and class in private message.
Ok!! Sending