You need to sign in to do that
Don't have an account?
SelectList getting Rerendered on Command Button
Hi All
I have two selectlists. One Named BU and other is the SBU.
My SBU selectlist is dependent on the values of BU selectlist.
Following is the visualforce page code:
<apex:outputLabel value="Select BU : " title="Select BU" > </apex:outputLabel> <apex:selectList value="{!BUOptions}" size="1" id="BUs"> <apex:selectOptions Value="{!Items}"></apex:selectOptions> <apex:actionSupport event="onchange" reRender="SBUs,ReportType"/> </apex:selectList> <br/> <apex:outputLabel value="Select SBU : " title="Select SBU"> </apex:outputLabel> <apex:selectList value="{!SBUOptions}" size="1" id="SBUs" > <apex:selectOptions Value="{!SBUItems}"></apex:selectOptions> </apex:selectList>
Controller for the above is as follows:
public List<SelectOption> getItems() { List<SelectOption> options = new List<SelectOption>(); options.add(new SelectOption('None','--- None ---')); options.add(new SelectOption('ALL','ALL')); options.add(new SelectOption('CMH','CMH')); options.add(new SelectOption('FIS','FIS')); return options; } public List<SelectOption> getSBUItems() { List<SelectOption> options = new List<SelectOption>(); if(BUOptions == 'FIS') { options.add(new SelectOption('CONSOLIDATED','CONSOLIDATED')); options.add(new SelectOption('FIS-Asia','FIS-Asia')); options.add(new SelectOption('FIS-Europe','FIS-Europe')); } else if(BUOptions == 'CMH')
{
options.add(new SelectOption('CONSOLIDATED','CONSOLIDATED'));
options.add(new SelectOption('CMH-E','CMH-E'));
options.add(new SelectOption('CMH-HC','CMH-HC'));
}
else { options.add(new SelectOption('--- None ---','--- None ---')); } return options; }
Now I also have a button on my Visualforce page and an OutputLabel.
The Output Label has to simply display the contents of SBU Selectlist.
<apex:commandButton title="Go" value="Go" /> <apex:outputLabel value="{!SBUOptions}" title="Output" id="displaySBU"/>
Initially when I open my page, both BU and SBU selectlist values have "--- None ---".
I select a BU. Corresponding SBU values get rendered. I then select a SBU value.
************* EVERYTHING WORKS FINE UPTILL THIS POINT **********
But as soon as I click my button, I guess the page gets re-rendered or god knows what, but the
1. BU remains the same what I had selected.
2. Whatever might be the value of BU, the SBU value becomes "CONSOLIDATED".
and my Output Label shows "--- None ---"
*******************************************************************************
I WANT MY OUPUT LABEL TO SHOW THE VALUE OF SBU SELECTLIST.
PLEASE HELP.
Thanks in Advance
Shiv
What is the functionality of the button? Can you share the method calling from the button.
Please make sure that the page is not refreshed with the execute of the button .
Some problems are occuring in the SBUOptions value after the button click.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks