You need to sign in to do that
Don't have an account?
Cheyne
Dependent multi-select inputfield not rendering correctly after ajax event
I have a Visualforce that includes two Account fields, which have a field dependency defined. The controlling field is a single-select picklist and the dependent field is a multi-select picklist. When both fields are displayed on page load, they both display correctly, with the correct values that are in the Account record. However, when I display the dependent (multi-select) field in an outputpanel that is only rendered via an ajax event, after clicking a commandlink, the value in the dependent field shows as null, even though it is not actually null on the record.
Below is a simplified example. In this example, all of the outputfields display the value that is on the account. However, the inputField for Dependent_Field__c in the "bottom-area" outputpanel always shows null after clicking the "Set String" commandlink (the Controlling_Field__c input in the "bottom-area" panel displays the correct value after the rerender).
Has anyone run across this issue before or have any ideas as to what the problem might be?
Visualforce
Apex Controller
Below is a simplified example. In this example, all of the outputfields display the value that is on the account. However, the inputField for Dependent_Field__c in the "bottom-area" outputpanel always shows null after clicking the "Set String" commandlink (the Controlling_Field__c input in the "bottom-area" panel displays the correct value after the rerender).
Has anyone run across this issue before or have any ideas as to what the problem might be?
Visualforce
<apex:page controller="MultiSelectController"> <apex:form > <apex:commandLink action="{!setStr}" rerender="bottom-area" value="Set String"/> <br/><br/> <apex:outputField value="{!acct.Controlling_Field__c}"/><br/> <apex:outputField value="{!acct.Dependent_Field__c}" /><br/> <apex:inputField value="{!acct.Controlling_Field__c}" label="Controlling Field"/><br/> <apex:inPutField value="{!acct.Dependent_Field__c}" label="Dependent Field"/> <br/> <br/><br/> <apex:outputPanel id="bottom-area"> <apex:outputPanel rendered="{!str != null}"> <apex:outputField value="{!acct.Controlling_Field__c}" /><br/> <apex:outputField value="{!acct.Dependent_Field__c}" /><br/> <apex:inputField value="{!acct.Controlling_Field__c}" label="Controlling Field"/><br/> <apex:inPutField value="{!acct.Dependent_Field__c}" label="Dependent Field"/> <br/> </apex:outputPanel> </apex:outputPanel> </apex:form> </apex:page>
Apex Controller
public class MultiSelectController { public Account acct {get; set;} public String str {get; set;} public MultiSelectController() { this.acct = [SELECT Controlling_Field__c, Dependent_Field__c FROM Account WHERE Id = '001E0000010iUnj']; } public void setStr() { this.str = 'test'; } }
All Answers