Display Visualforce page Names as dropdown or picklist in visualforce Page
ApexClass: DisplayVFNamesDropDownController
Public class DisplayVFNamesDropDownController {
public String selectedVF {get;set;}
public DisplayVFNamesDropDownController() {
}
public List<SelectOption> getVisualforcePages() {
List<SelectOption> lstVFPage = new List<SelectOption>();
lstVFPage.add(new SelectOption('' , 'Select'));
for(ApexPage objPage:[Select id,name from ApexPage]) {
lstVFPage.add(new SelectOption(objPage.Name , objPage.Name));
}
return lstVFPage;
}
public void getSelectedValue() {
}
}
Visualforce Page: DisplayVFNamesDropDown
<apex:page controller="DisplayVFNamesDropDownController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!selectedVF}" size="1" multiselect="false" onchange="{!SelectedValue}" >
<apex:selectOptions value="{!VisualforcePages}" />
<apex:actionSupport event="onchange" reRender="selectedPageId" action="{!getSelectedValue}"/>
</apex:selectList>
</apex:pageBlockSection>
<apex:pageBlockSection id="selectedPageId">
Selected Page: {!selectedVF}
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Output:
ApexClass: DisplayVFNamesDropDownController
Public class DisplayVFNamesDropDownController {
public String selectedVF {get;set;}
public DisplayVFNamesDropDownController() {
}
public List<SelectOption> getVisualforcePages() {
List<SelectOption> lstVFPage = new List<SelectOption>();
lstVFPage.add(new SelectOption('' , 'Select'));
for(ApexPage objPage:[Select id,name from ApexPage]) {
lstVFPage.add(new SelectOption(objPage.Name , objPage.Name));
}
return lstVFPage;
}
public void getSelectedValue() {
}
}
Visualforce Page: DisplayVFNamesDropDown
<apex:page controller="DisplayVFNamesDropDownController">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:selectList value="{!selectedVF}" size="1" multiselect="false" onchange="{!SelectedValue}" >
<apex:selectOptions value="{!VisualforcePages}" />
<apex:actionSupport event="onchange" reRender="selectedPageId" action="{!getSelectedValue}"/>
</apex:selectList>
</apex:pageBlockSection>
<apex:pageBlockSection id="selectedPageId">
Selected Page: {!selectedVF}
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Output:
No comments:
Post a Comment