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
ezdhanhussainezdhanhussain 

Radio button onselect open new window with selected record details

I have a list of  recordswhich are associated with radio buttons individually, when i select radio button of any one record it should redirect me to a new page displaying all the details of that record ? Any ideas will be greatly appreciated..

Best Answer chosen by Admin (Salesforce Developers) 
ezdhanhussainezdhanhussain

yes. i got it..

<apex:column >
    <apex:actionsupport action="{!open_win}" event="onclick" rerender="pb">  
     <input type="radio" />                    
     <apex:param name="idselected" value="{!c.Id}"></apex:param></apex:actionsupport>  

 </apex:column>

//action method
    public pageReference open_win(){
        String accid = System.currentPagereference().getParameters().get('idselected');

    pageReference pg = new pageReference('https://c.ap1.visual.force.com/apex/accountpopupdisplay?id='+accid);
    return pg;
    }

 

All Answers

ezdhanhussainezdhanhussain

i got records and radio buttons and i am able to successfully redirect it to a new page, but i am unable to get id of selected record in second page url. Provinding my code, plz suggest any corrections in it so that i can refer id in url

<apex:page standardController="Account"  extensions="accountpopup">
 <apex:form >
 <apex:pageBlock >
   <apex:pageBlockTable value="{!Accountlist}" var="a"> 
    <apex:column >
    <apex:outputField value="{!a.name}"/>
    </apex:column>
    <apex:column >
    <apex:actionsupport action="{!open_win}" event="onclick" immediate="true"  >  
    <apex:SelectRadio value="{!a.id}"  /> {!a.name}
    <apex:param name="conid" value="{!a.id}" >
    </apex:param>               
    </apex:actionsupport>                            
    </apex:column>
   </apex:pageBlockTable> 
  </apex:pageBlock>
 </apex:form>
</apex:page>

 

//controller class
public with sharing class accountpopup {
 public list<Account> acc1 = new list<account>();
 public string selected{set;get;}
public id con;
 public string selectconid;
    public accountpopup(ApexPages.StandardController controller) {
    
    }
    public pageReference goto(){
    return page.accountpopupdisplay;
    }
    public List<Account> getAccountlist(){
    acc1 = [select id,name from account ];    
    return acc1;
   }

 public void passid(){
 string selectconid = System.currentPagereference().getParameters().get('conid');
 con = [Select Id from Account where id =:selectconid limit 1].id;

 }
    public pageReference open_win(){
    pageReference pg = new pageReference('https://c.ap1.visual.force.com/apex/accountpopupdisplay?id='+con);
    return pg;
    }
}

 I am getting url like this

https://c.ap1.visual.force.com/apex/accountpopupdisplay?id=null

if i hard code the soql query then i am getting url with id like this

https://c.ap1.visual.force.com/apex/accountpopupdisplay?id=0019000000dAmVu

bob_buzzardbob_buzzard

Your action support is outside your selectradio - is that really how you code looks?  My experience is that apex:param often doesn't work unless there is a rerender attribute in the containing component - actionsupport in this case.  The problem then would be that you can't redirect to a new page.

 

Given that you are simply redirecting to that record, why not handle the onchange event and set the window location accordingly - something like:

 

<apex:SelectRadio value="{!a.id}" onchange="window.location='/apex/accountpopupdisplay?id={!a.id}';"/>
ezdhanhussainezdhanhussain

 Hi bob thanks for the reply. i applied your suggestion in my code, i am able to redirect my page but still i am not getting id in my url.

ezdhanhussainezdhanhussain

yes. i got it..

<apex:column >
    <apex:actionsupport action="{!open_win}" event="onclick" rerender="pb">  
     <input type="radio" />                    
     <apex:param name="idselected" value="{!c.Id}"></apex:param></apex:actionsupport>  

 </apex:column>

//action method
    public pageReference open_win(){
        String accid = System.currentPagereference().getParameters().get('idselected');

    pageReference pg = new pageReference('https://c.ap1.visual.force.com/apex/accountpopupdisplay?id='+accid);
    return pg;
    }

 

This was selected as the best answer