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

One List depend on other in visuallforce page pageblocktable

i am creating a visualforce page in this visualforce page there is a pageblocktable in each table row there are two selectlist one depends on other.first select list contains list of standard objects and other contain list of fields related to that object.there are several rows each contains these two to change content of second list related to first please give some guideline.firstly i created a wrapper class


public with sharing class AW_RuleCriteriaController2{
public String hello{get;set;}
public List<wrapper> wrap1{get;set;}
public AW_RuleCriteriaController2(ApexPages.StandardController controller){
wrap1 =new List<wrapper>();
wrap1.add(new wrapper());
wrap1.add(new wrapper());

public class wrapper{

public List<SelectOption> objOption{get;set;}
public List<SelectOption> fieldOption;
public List<SelectOption> matchType;
public String hello{get;set;}
public wrapper(){
objOption = new List<SelectOption>();
Map<String, Schema.SObjectType> mapObj = Schema.getGlobalDescribe();

Rule__c rule = [select object__c from Rule__c where id=:Apexpages.currentPage().getParameters().get('Id')];

String objType = rule.object__c;
Schema.SObjectType sobj;
if(objType !=null){
sobj = mapObj.get(objType);
Schema.DescribeSObjectResult objinfo = null;

objinfo = sobj.GetDescribe();
List<Schema.ChildRelationship> listChild = sobj.getDescribe().getChildRelationships();

for(Schema.ChildRelationship child: listChild){
Schema.DescribeSObjectResult descRes = child.getChildSObject().getDescribe();
system.debug(' PGB Children ' + descRes.getName());
system.debug(' PGB Children ' + descRes.getLabel());
objOption.add(new SelectOption(descRes.getName(),descRes.getLabel()));
objOption.add(new SelectOption(objInfo.getName(), objInfo.getLabel()));



after this i added objOption this contain the list of available objects .its giving the correct list in visualforce page

<apex:page standardController="Rule__c" extensions="AW_RuleCriteriaController2">

<apex:form >
<apex:pageBlock title="Filter Criteria" >
<apex:pageBlockSection >

<apex:inputtext value="{! hello}" />

<apex:pageBlockTable value="{!wrap1}" var="item">

<apex:column >
<apex:selectList value="{! item.hello}" size="1">
<apex:selectOptions value="{! item.objOption}"></apex:selectOptions></apex:selectList></apex:column>




how to create a second selectlist in the pageblock table whose value changes with the selected value of the first selectlist.i hope i described well the please guideline how to accomplish this . 


Shiv ShankarShiv Shankar

1. Currently you have two picklist with you

     A. PickList ---------------------- Using Propery A

     B. Dependent Pick List.------------- Using Porperty B.

2. Now add Action Support for pick list A.

    What you do in that ?

    1. Call a method of controller which sets the value in Dependent picklist B according to value in pick List A.

    2. reRender the Dependent Pick List B.



For detail post your  code.