+ Start a Discussion
Diego Vieira 8Diego Vieira 8 

Visualforce ReRender Help

Someone can help?
I have a pageBlockSectionItem to display a selectList and i should render another pageBlockSectionItem if some option of the list is selected("Dinâmica").
*Mudanca variable in visualforce page is the realizaMudanca in the controller

This is the pageBlockSectionItem of the list:
<apex:pageBlockSectionItem>
                                <apex:outputLabel value="Nova Fase do Candidato"/>
                                    <apex:selectList value="{!NovaFaseCandidato}" multiselect="false" size="1">
                                        <apex:actionSupport event="onchange" action="{!Change}" reRender="{!IF({Mudanca, "Blockteste", "")}"/>
                                        <apex:selectOptions value="{!FasesCandidato}"/>
                                    </apex:selectList>
                                    
</apex:pageBlockSectionItem>
*this is giving a syntax error, I don't know why

This is the function that i called in the controller
public PageReference Change() {

		if(NovaFaseCandidato == 'Dinâmica')
		{
			realizaMudanca = true;
			system.debug('true');
		}
		else
		{
			realizaMudanca = false;
			system.debug('false');
		}
		return null;
	}

This is the pageBlockSectionItem that i should render if "Dinâmica" is the option selected
 
</apex:pageBlockSectionItem>
                            
                            <apex:pageBlockSectionItem id="Blockteste" rendered = "{!Mudanca}">
                                <apex:outputLabel value="Selecione o painel"/>
                                    <apex:selectList value="{!DataHoraPainel}" styleClass="flutua-direita" multiselect="false" size="1">
                                        <apex:selectOptions value="{!QualPainel}"/>
                                    </apex:selectList>
                                    
                            </apex:pageBlockSectionItem>


 
Best Answer chosen by Diego Vieira 8
SKSANJAYSKSANJAY
Hi Diego....In Tiago code I can see an unexpected curli braces before "Mudanca" in rerender section. Remove and try to save.
 
<apex:actionSupport event="onchange" action="{!Change}" reRender="{!IF(Mudanca, 'Blockteste', '')}"/>

Hope this will help you​

All Answers

SKSANJAYSKSANJAY
Hi Diego,

Find below code for your reference:

<!--  Remove condition check from rerender-->
<apex:pageBlockSectionItem>
    <apex:outputLabel value="Nova Fase do Candidato"/>
        <apex:selectList value="{!NovaFaseCandidato}" multiselect="false" size="1">
            <apex:actionSupport event="onchange" action="{!Change}" reRender="Blockteste"/>
            <apex:selectOptions value="{!FasesCandidato}"/>
        </apex:selectList>         
</apex:pageBlockSectionItem>

<!-- Wrap the pageblocksectionitem inside an output panel and rerender that -->
<apex:outputPanel  id="Blockteste">
                                <apex:outputPanel rendered="{!Mudanca}">
                                    <apex:pageBlockSectionItem>
                                        <apex:outputLabel value="Selecione o painel"/>
                                            <apex:selectList value="{!DataHoraPainel}" styleClass="flutua-direita" multiselect="false" size="1">
                                                <apex:selectOptions value="{!QualPainel}"/>
                                            </apex:selectList>
                                            
                                    </apex:pageBlockSectionItem>
                                </apex:outputPanel>
                            </apex:outputPanel>

Hope this will help you...

Thanks,
Sanjay
 
Tiago Armando CoelhoTiago Armando Coelho
Please check this code:

<apex:page >
    <apex:pageBlockSectionItem>
                                <apex:outputLabel value="Nova Fase do Candidato"/>
                                    <apex:selectList value="{!NovaFaseCandidato}" multiselect="false" size="1">
                                        <apex:actionSupport event="onchange" action="{!Change}" reRender="{!IF({Mudanca, 'Blockteste', '')}"/>
                                        <apex:selectOptions value="{!FasesCandidato}"/>
                                    </apex:selectList>
                                    
</apex:pageBlockSectionItem>
</apex:page>
Diego Vieira 8Diego Vieira 8
thx Guys, but still don't working.
@SKSANJAY, I think that I need a solution that doesn't use an outputPanel, and by the way, your code doesn't work too. I can't figure out why.
@Tiago Armando Coelho, Your code gets syntax error just like mine :/
SKSANJAYSKSANJAY
Hi Diego....In Tiago code I can see an unexpected curli braces before "Mudanca" in rerender section. Remove and try to save.
 
<apex:actionSupport event="onchange" action="{!Change}" reRender="{!IF(Mudanca, 'Blockteste', '')}"/>

Hope this will help you​
This was selected as the best answer
Diego Vieira 8Diego Vieira 8
Thank you all, I solved it