• madhavi21.3966038613070422E12
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
public Component.Apex.InputCheckbox createchkbox()
{
Component.Apex.InputCheckbox chk=new Component.Apex.InputCheckbox();

Component.Apex.InputCheckbox test=new Component.Apex.InputCheckbox();
        
            String str=NULL;
      String type= 'FieldObject__c';  // Say,this is my object
      Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
      Schema.SObjectType leadSchema = schemaMap.get(type);
      Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();
          
      


  
        for (String fieldName: fieldMap.keySet())
       
             { 
                  String mylabel;
                      //It provides to get the object fields label.
                  mylabel = fieldMap.get(fieldName).getDescribe().getLabel();
                  
                 Schema.DisplayType myType=fieldMap.get(fieldName).getDescribe().getType();
                  
                   
       
       
                             if (myType == Schema.DisplayType.BOOLEAN)
                                
                             {
                           
                                
                                             if(fieldName.endsWith('__c'))
                                             {
                                              
                                          str='\'{!'+type+'.'+fieldName+'}\'';
                                           
                                             }
                            }
  
  
                    }
   
       
       
        chk.expressions.value=str;
        return chk;
       
       
      

}

Above is my code in which I am trying to the string str as a expression value to checkbox. As I am trying to do this, I am getting the error 
"System.VisualforceException: Value assigned to expression field is not valid for <apex:inputCheckbox value>"

Kindly help me out.