+ Start a Discussion
MktdevMktdev 

Loading Detail page with the help of combox selection ID

public class myclass
{
   List<SelectOption> VIEW_DEPARTMENT;

   public List<SelectOption> getDepartments()
   {
      VIEW_DEPARTMENT=new List<SelectOption>();
      VIEW_DEPARTMENT.add(new SelectOption('0', 'All Departments'));

      for (Specialization__c spec : [select Name from Specialization__c]) 
      {
         VIEW_DEPARTMENT.add(new SelectOption(spec.Name, spec.Name));
      }

      return VIEW_DEPARTMENT;
   }
}

Above is the class which is pulling data from database.and same has been used in below page under combo box.I  got ID of the select data in the combox and want to pass that as query string to show a detail page.Can anyone guide me?

 

I knwo we can do if we place as list and user can click on it and the detail section will be displayed with {!currentpage.parameters..}.

 

But I want as sson as the user select the data detail page automatically loads. 

  

<apex:outputText value="Department"/>
<apex:selectList value="{!viewDepartmentName}"id="departmentViews" size="1" required="true">
<apex:selectOptions value="{!DepartmentViewNames}"/>

 

 

 

 

rmehrmeh

Hi,

 

You can make use of <apex:actionSupport> to help you to redirect to a detail page.

here is a small code snippet which can help you:

 

 

========================== VisualForce Page==============================
<apex:outputPanel >
<apex:outputLabel value="Department"/>
<apex:selectList value="{!viewDepartmentName}"id="departmentViews" size="1" required="true">
<apex:selectOptions value="{!DepartmentViewNames}"/>
<apex:actionSupport event="onchange" action="{!RedirectTodetail}" rerender="opdummy"/>
</apex:selectList>
</apex:outputPanel>
<apex:outputPanel id="opdummy"/>
========================================================================

======================= Apex Controller=================================
public List<SelectOption> getDepartments()
{
VIEW_DEPARTMENT=new List<SelectOption>();
VIEW_DEPARTMENT.add(new SelectOption(' ', 'All Departments'));

for (Specialization__c spec : [select Name from Specialization__c])
{
VIEW_DEPARTMENT.add(new SelectOption(spec.Id, spec.Name));
}

return VIEW_DEPARTMENT;
}

public PageReference RedirectTodetail()
{
if(viewDepartmentName!= null && viewDepartmentName!= '')
{
PageReference pr = new PageReference('/' +viewDepartmentName);
// if custom detail page
PageReference pr = new PageReference('/apex/PageName?someparameter=' +viewDepartmentName);

pr.setRedirect(true);
return pr;
}
else
{
return null;
}
}
========================================================================

 I hope i have anwered your query.