1

I'm trying to set up some visualforce input and output to display if a select list is sent to a certain value. I've got my select list set to rerender the entire panelgrid on change and the inputs and outputs set to render if the selectlist value == "yes". I have had success with similar rendering in the past but can't get this to work.

Here are some samples of my code:

Controller setting the select list and a string to hold the value:

public class createContact {
    public string createOrg {get;set;}
    public List<selectOption     createOrgList {get {
        List<selectOption     orgOptions = new List<selectOption    ();
        orgOptions.add(new selectOption('Yes', 'Yes'));
        orgOptions.add(new selectOption('No', 'No'));
        return orgOptions;
        }
        private set;
    }
}

panelGrid with select list and two fields dependent on rendering:

<apex:panelGrid columns="2" cellpadding="2" columnClasses="colleft, colright" id="AccountCheck"/>
<apex:outputLabel value="Create New Organization?" for="createNewOrg" />
<apex:selectList id="createNewOrg" value="{!createOrg}" size="1">
    <apex:selectOptions value="{!createOrgList}"/>
    <apex:actionSupport event="onchange" rerender="AccountCheck"/>
</apex:selectList>

<apex:outputLabel value="Organization Name - Required" for="Name" rendered="{!IF(createOrg == 'Yes',true,false)}" />
<apex:inputText id="Name" value="{!strAccountName}" rendered="{!IF(createOrg == 'Yes',true,false)}"/>

The fields aren't showing up at all, any advice?

1 Answer 1

1

I think you want your last two elements to be wrapped by the panelgrid Currently, you are not wrapping anything in the grid at all.

Change the panelgrid definition to:

<apex:panelGrid columns="2" cellpadding="2" columnClasses="colleft, colright" id="AccountCheck">
    <apex:outputLabel value="Organization Name - Required" for="Name" rendered="{!IF(createOrg == 'Yes',true,false)}" />
    <apex:inputText id="Name" value="{!strAccountName}" rendered="{!IF(createOrg == 'Yes',true,false)}"/>
</apex:panelGrid>

Either that or give an id to the label an and input and make them targets of the rerender too (rerender="AccountCheck,orgNameLabel,orgNameInput") for example

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .