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
Kondal Rao learnerKondal Rao learner 

hi regarding radio button (very urgent)

HI experts,

 

Plese anyone can tell me my requriment every radio button is selecting automatically i dont know why please correct my code.

 

vf page:-

 

<apex:page standardController="OrganizationHierarchyMaster__c" extensions="ActivityOrgrelationController" sidebar="true">
    <br />
    <br />
       <apex:pageMessages ></apex:pageMessages>
<apex:form >
<body> 
  <apex:pageBlock title="Activity Organization Alignment" id="pbid">
<table>
<tr>
<td style="width: 150px;">
<div style="height: 250px" class="bodyDiv" onclick="resizeFrame();">
        <c:OrgHierarchy currentId1="{!OrganizationHierarchyMaster__c.OrgName__c}" />
    </div>
  
</td>
<td>
<table>
<tr>
<td>
<div align="center" >
    <apex:selectRadio value="{!ind}" style="align:center">
    <apex:selectOption itemValue="0"  itemlabel="Parent Activity"/>
    <apex:selectOption itemValue="1"  itemlabel="Child Activity"/>
        <apex:actionSupport event="onchange" rerender="activityView" />
         </apex:selectRadio>
</div>
</td>
</tr>
<tr>
<td>
    <apex:outputPanel id="activityView">
    <apex:pageBlockTable value="{!ActivityList}" var="a" style="font-size:1.0em;">
 
    <apex:column width="70px" headerValue="Select">
                 <!--<input type="radio" name="group1" /> -->
     <apex:selectRadio value="{!a.selected}" rendered="{!ind=='0'}" > </apex:selectRadio>
                          <apex:inputCheckbox value="{!a.selected}" rendered="{!ind!='0'}" id="checkedone"/>
                        </apex:column>
                         <apex:column width="70px" headerValue="Code" >
                    <apex:outputText value="{!a.act.Code__c}"></apex:outputText>
                </apex:column>
                         <apex:column width="300px" headerValue="Name">
                    <apex:outputText value="{!a.act.Name}"></apex:outputText>
                </apex:column>
                                            
                          <apex:column width="400px" headerValue="Description" >
                    <apex:outputText value="{!a.act.Description__c}"></apex:outputText>
                </apex:column>
                    <apex:column width="120px" headerValue="Frequency" >
                    <apex:outputText value="{!a.act.Frequency__c}"></apex:outputText>
                </apex:column>
                    <apex:column width="120px" headerValue="Priority" >
                    <apex:outputText value="{!a.act.Priority__c}"></apex:outputText>
                </apex:column>
                          <apex:column width="120px" headerValue="Functional" >
                    <apex:outputText value="{!a.act.Functional__c}"></apex:outputText>
                </apex:column>
                           <apex:column width="120px"  headerValue="Time Zone" >
                    <apex:outputText value="{!a.act.Time_Zone__r.name}"></apex:outputText>
                </apex:column>
              
              </apex:pageBlockTable>
        </apex:outputPanel>
                 </td>
                  </tr>
                    <tr>
                     <td align="center">
     <apex:commandButton action="{!AssignActivities}"  value="Select" />
     <apex:commandButton action="{!UnAssignActivities}" value="Remove"/>
</td>
</tr>
</table>
</td>
<td style="width: 200px;">
          <b>Selected Parents:</b><br/>
          <apex:inputTextarea value="{!ParentList}" readonly="true" rows="4" /><br/>
          <b> Selected Childs: </b>
            <apex:inputTextarea value="{!ChildList}" readonly="true" rows="6" /><br/>
        </td>
       

</tr>
</table>

  </apex:pageBlock>
  </body> 
        </apex:form>
</apex:page>

 

Apex class:-

 

public class ActivityOrgrelationController{
    public String ParentList{set;get;}
    public String ChildList{set;get;}
    public ActivityOrgrelationController() {
idvalue= ApexPages.currentPage().getParameters().get('id');
        Orgname= ApexPages.currentPage().getParameters().get('Org');
    }

    // String orgid = ApexPages.currentPage().getParameters().get('id');
   String orgid;
    public list<Activity_Master__c> ActivityList ;
    public string idvalue {get;set;}
    public string Orgname {get;set;}
  
    public ActivityOrgrelationController(ApexPages.StandardController act)  
    {
     // idvalue= ApexPages.currentPage().getParameters().get('id');
      //  Orgname= ApexPages.currentPage().getParameters().get('Org');
    }
  
   //public PageReference dosomething()    
  //  {
  //      system.debug('test');
   //     string idvalue= ApexPages.currentPage().getParameters().get('id');
   //     system.debug(idvalue);
   //     return null;
   // }
   public String ind {get;set;}
   {
   ind= '1';
   }
    public List<activitywrapper> getActivityList()
    {  
      
        OrgStructure orgs = new OrgStructure();
        orgid = orgs.temporgId;
        Cookie orgCookie;
        orgCookie = ApexPages.currentPage().getCookies().get('Orgid');
        if(idvalue != null)
        {
           // orgid = orgCookie.getValue();
            orgid = idvalue;
            //ind = '0';
            Orgname = 'Choosed Organisation : ' + Orgname;
        }
     
        if(orgid != null)
        {
            if(ind == '0')
            {
             
                actList.clear();
                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c
                            where Status__c = 'Active' and id in (Select Activity_Name__c from CT_Org_Activity_Mapping__c
                                                                     WHERE Organisation_Level_Name__c = :orgid)])
                 {
                    actList.add(new activitywrapper(a));
                 }
            }
            else
            {
                actList.clear();
                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c
                            where Status__c = 'Active' and id not in (Select Activity_Name__c from CT_Org_Activity_Mapping__c
                                                                     WHERE Organisation_Level_Name__c = :orgid)])
                 {
                    actList.add(new activitywrapper(a));
                 }  
            }
        }
        else
        {
            if(ind == '0')
            {
          
                actList.clear();
                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c
                            where Status__c = 'Active' and id  in (Select Activity_Name__c from CT_Org_Activity_Mapping__c)])
                 {
                    actList.add(new activitywrapper(a));
                 } 
            }
            else
            {
           // ind = '1';
                 actList.clear();
                for(Activity_Master__c a : [Select id,Code__c,Name,Description__c,Frequency__c,Priority__c,Functional__c,Time_Zone__r.name FROM Activity_Master__c
                            where Status__c = 'Active' and id not in (Select Activity_Name__c from CT_Org_Activity_Mapping__c)])
                 {
                    actList.add(new activitywrapper(a));
                 } 
            }
        }
       return actList;
    }
        //public List<Activity_Master__c> getAlignedActivityList()
  //  {  
  //  system.debug('orgid : ' + orgid );
   //     ActivityList=[Select id,Code__c,Name,Description__c,Frequency__c,Functional__c,Priority__c,Time_Zone__r.name FROM Activity_Master__c
  //                      where Status__c = 'Active' and id not in (Select Activity_Name__c from CT_Org_Activity_Mapping__c
   //                                                              WHERE Organisation_Level_Name__c = :orgid)];       
   //    return ActivityList;
   // }
     List<activitywrapper> actList = new List<activitywrapper>();
    
     public PageReference AssignActivities()
    {
    try
    {
       // ActivityList.clear();
       if(ind =='0'){
       for(activitywrapper actwrapper : actList)
              {
                if(actwrapper.selected == true)
                {
                     Parentlist = actwrapper.act.Name;
               
              
               }
              }
      }
      else{
              ChildList= '';
           for(activitywrapper actwrapper : actList)
              {
                if(actwrapper.selected == true)
                {
             //   ActivityList.add(actwrapper.act);
                  ChildList += actwrapper.act.Name + '\n';
               
               
               }
              }
     
      }
      }
    catch(Exception e)
        {
            ApexPages.addMessages(e);
        }
       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Activities assigned successfully'));
       
     return null;
    }
      public PageReference UnAssignActivities()
    {
    try
    {
       // ActivityList.clear();
        system.debug(actList.size());
       for(activitywrapper actwrapper : actList)
      {
        if(actwrapper.selected == true)
        {       
        
         List<CT_Org_Activity_Mapping__c> orgactmapping = [SELECT Id From CT_Org_Activity_Mapping__c where Activity_Name__c = :actwrapper.act.id
                                                                             AND Organisation_Level_Name__c = :orgid];
            delete orgactmapping ;
         
       }
      }
      }
    catch(Exception e)
        {
            ApexPages.addMessages(e);
        }
       ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Activities Un-assigned successfully'));
       
     return null;
    }
    public class activitywrapper
    {
    
         public Activity_Master__c act{get; set;}
        public Boolean selected {get; set;}
        public activitywrapper(Activity_Master__c a)
        {
            act = a;
            selected = false;
        }
    }
   
    }

 

 

Thanks in advance

bob_buzzardbob_buzzard

You've set the value of 'ind' to '1' in your controller - that means that when the selectradio with a value of '{!ind}' is rendered, the button with the value of '1' will be automatically selected.