function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dev401hasdev401has 

Rendered not working in my Visualforce page

Hi All

 

I am preparing a Visualforce page which is having a dependent picklist i.e Picklist A (Controlling picklist) and Picklist B (Dependent picklist). There is one more textarea field which is supposed to be rendered/visible only when there is a specific value in dependent picklist i.e picklist B.

 

I am facing the problem in rendering the textarea field.

Extension:

 

 

public boolean check;
public boolean isCustom{
        get{
            check=false;
            if(dependent picklist val == 'specific_val')
            {
                check = true;
                system.debug('check-------->'+check);
            }   
            else
            {
                check=false;
            }
            return check ;
           }
           set;
        
    }

 

Visualforce page:

 

<apex:pageBlockSectionItem >
<apex:outputLabel > dependent picklist </apex:outputLabel>
<apex:inputField value="{!dependentpicklist}" id="etype" >
<apex:actionSupport event="onchange" reRender="cust, atp"/>
</apex:inputField>
</apex:pageBlockSectionItem>    
<apex:pageBlockSectionItem >
<apex:pageBlockSectionItem id="cust" rendered="{!isCustom}" >
<apex:outputLabel > Custom textarea </apex:outputLabel>
<apex:inputField value="{!textarea}" id="atp"/>
</apex:pageBlockSectionItem>

 

 

 

I am unable to find where the error is.

I checked in debug logs that when its a specific value in the picklist then boolean value check is getting true but in rendered its not working.

Best Answer chosen by Admin (Salesforce Developers) 
dev401hasdev401has

I tried that too but it didnt work. I should have worked but i dont know what was wrong.

 

Finally i did this way and its working now:

 

I called action function on change of the picklist.

In Action function I kept immediate=true and rerender to the customtextbox id. In actionfunction I kept param and assigned the value

 

I used that in rendered in the customtextboxarea and it worked fianlly.

 

 

All Answers

EalesieEalesie

Add an output panel around your pageBlockSectionItem containing the text area and refresh the output panel and not the textarea field

 

The problem is if IsCustom equates to false originally the pBSI will not be on the page

 

 

dev401hasdev401has

I did try that but its not working.

One more important fact is if I remove rerender attribute from the action support then the page refreshes and the textarea box appears but it does not on the Ajax refresh when i keep rerender attribute.

Imran MohammedImran Mohammed

Rerender the entire pageBlock and the ajax refresh should workin that case.

Let me know if it doesnt work.

dev401hasdev401has

I tried that too but it didnt work. I should have worked but i dont know what was wrong.

 

Finally i did this way and its working now:

 

I called action function on change of the picklist.

In Action function I kept immediate=true and rerender to the customtextbox id. In actionfunction I kept param and assigned the value

 

I used that in rendered in the customtextboxarea and it worked fianlly.

 

 

This was selected as the best answer