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
impalacrazy69impalacrazy69 

Rendered is not working what am i missing help..........

Ok so i have tried every message on the board over the last 2 days and cant seem to get what im trying to acomplish to work. So here is what i am trying to do and my code snipet.

 

I have a VF page that has a picklist called activity_type. When certain choices are picked i would like for the pageblocksection to go away and if they are not selected to show (i.e. if activity_type != Null or Conference or TradeShow remove venue details section)

 

So below is my code. I have tried actionsupport / rendered / rerendered / onchange / onclick u name i have tried it. What i am seeing is

1. that when the page loads for one the venue detail section is gone all together even with null listed

2. When i move the rendered to a field it  will work but not bring it back when it is changed

 

Below is my code i hope someone can see what im totally missing:

 

Ivan

 

Code from controller:

public Boolean checkMe (){ 
       	if (this.request.Activity_Type__c != null ||
			this.request.Activity_Type__c != 'Conference' ||
			this.request.Activity_Type__c != 'TradeShow'){
       		return false;
       	}
       	return true;
    }   		


Code from VF Page:

<apex:pageBlockSection title="Event Details" id="eventdetails">
        <apex:inputField required="true" value="{!request.Event_Name__c}" styleClass="normalinput"/>
        <apex:inputField required="true" value="{!request.Event_Date__c}"/>
        <apex:inputField required="true" value="{!request.Activity_Type__c}" />
        <apex:actionSupport event="onchange" rerender="venuedetails"/>
        <apex:inputField required="true" value="{!request.Estimated_Leads__c}" styleClass="shortinput"/>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Description</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Event_Description__c}" styleClass="textarea"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputPanel >
                <apex:outputLabel >Currency</apex:outputLabel> <br></br><br></br>
                <apex:outputLabel >Requested Funding Amount</apex:outputLabel>
            </apex:outputPanel>
            <apex:outputPanel >
                <apex:inputField required="true" value="{!request.Currency__c}"/>
                <apex:inputField required="true" value="{!request.Requested_Funding_Amount__c}" styleClass="shortinput"/>
            </apex:outputPanel>
        </apex:pageBlockSectionItem>

        
        <!-- Materials Section -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Materials Needed: <br></br> (select any that apply)</apex:outputLabel>
            <apex:selectCheckboxes value="{!materials}" layout="pageDirection">
                <apex:selectOptions value="{!materialOptions}" />
            </apex:selectCheckboxes>
        </apex:pageBlockSectionItem>
        <!-- END Materials Section -->
        
        <!-- Product Focus -->
        <apex:inputField required="true" value="{!request.Product_Focus__c}"/>
        <!-- END Product Focus -->
        
    </apex:pageBlockSection>
    <!-- END Event Details -->
    
    <!-- Venue Info -->
    <apex:pageBlockSection title="Venue Details" columns="1" id="venuedetails" rendered="{!checkMe}">
        <apex:inputField required="true" value="{!request.Venue_Name__c}"  styleClass="normalinput"/>
        
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Address__c}" styleClass="longinput"/>
            
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- Same actionRegion pattern as above -->
        <apex:pageBlockSectionItem dataStyleClass="requiredInput" >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <div class="requiredInput">
            <div class="requiredBlock"></div>
            <apex:selectList value="{!request.Venue_Country2__c}" size="1">
                <apex:actionSupport event="onchange" reRender="venuestate"/>
                <apex:selectOptions value="{!CountryOptions}"/>
            </apex:selectList>
            </div>
            </apex:actionRegion>
       </apex:pageBlockSectionItem>
    </apex:pageBlockSection> 
    
    <apex:pageBlockSection columns="1" id="venuestate">
        <apex:pageBlockSectionItem rendered="{!venueRequiresState}">
            <apex:outputLabel >State/Province</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_State__c}"/>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    <!-- END Venue Info -->

 

 

Marko LamotMarko Lamot

Hello,

 

ActionSupport has to be within inputfield and not out. I'm not saying this will completely solve your problem, but let fix that first ;-)

 

<apex:inputField required="true" value="{!request.Activity_Type__c}" >

<apex:actionSupport event="onchange" rerender="venuedetails"/>
</apex:inputField>

 

 

 

 

impalacrazy69impalacrazy69

Thanks for the reply Marko,

 

So it looks like that did something. Now when i change the field i am getting you must enter a value which is good becasue the field are required but im wondering will it submit the form.

 

So i made a change the the public boolean i have and now im getting a new error: Unknown property 'Marketing_Request__cStandardController.checkMe'

 

    public Boolean checkMe (){ 
       	if (this.request.Activity_Type__c != null ||
	    this.request.Activity_Type__c != 'Conference' ||
	    this.request.Activity_Type__c != 'TradeShow')
       		return false;
      	else 	
       		return true;
    }  

 

Avidev9Avidev9

Considering your last error message the method should look like

 public Boolean getCheckMe (){ 
       	if (this.request.Activity_Type__c != null ||
	    this.request.Activity_Type__c != 'Conference' ||
	    this.request.Activity_Type__c != 'TradeShow')
       		return false;
      	else 	
       		return true;
    }  

In VF page

 

{!checkMe}

 

 

 

 

impalacrazy69impalacrazy69

 

Thanks Avidev9 that fixed my error.

 

So code looks good but the outcome is when i go into the vf page my venue details section is no longer there. When i remove the rendered from the pageblocksection of my VF code the section shows but when its there as soon as the page loads its gone. So i have changed the checkme to read - return true; else return false. Now the page loads with the section there which is great.

 

But now when i change the activity_type field to something that is not "Conference, Tradeshow, or null" the page says i need to enter in a value. Its refreshed to get rid of the fields like i want but then they came right back. Doesnt seem as tho i can add in a screen shot :(

 

 

Avidev9Avidev9
Well I dont thing that I understand the requirement fully.

But I have seen you are making some of the field required="true" . So to do some action using a button you need to fill all the fields that are maked as required
impalacrazy69impalacrazy69

ok so i tested again. and it looks like any change to the activity type field makes the "Enter Field Value" appear.

Avidev9Avidev9

You have all over the place. Required= true.

 

This means you need to fill them before doing any ajax/call/submit whatever

 

<apex:inputField required="true" value=""/>

 

<apex:inputField  value=""/>
Marko LamotMarko Lamot

"and it looks like any change to the activity type field makes the "Enter Field Value" appear."

-> this error makes sense as you are using required attribute. 

For such situation, use now  apex:region  to exclude validation of required fields. 

See details on apex:region function, how to use it.

 

 

impalacrazy69impalacrazy69

So i have read up on actionregion tags and have tried every which way to place them in the code. Now all tha happens is the screen moves like it is trying to hide the section but it doesnt the fields still show.

 

Im wondering if i need to add in an outputpanel which i had not been using?

<apex:actionregion >
    <apex:pageBlockSection title="Event Details" id="eventdetails">
        <apex:inputField required="true" value="{!request.Event_Name__c}" styleClass="normalinput"/>
        <apex:inputField required="true" value="{!request.Event_Date__c}"/>
        	
        		<apex:inputField required="true" value="{!request.Activity_Type__c}" >
        			<apex:actionSupport event="onchange" rerender="venuedetails" status="Status"/>
        		</apex:inputField>
        	
        <apex:inputField required="true" value="{!request.Estimated_Leads__c}" styleClass="shortinput"/>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Description</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Event_Description__c}" styleClass="textarea"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputPanel >
                <apex:outputLabel >Currency</apex:outputLabel> <br></br><br></br>
                <apex:outputLabel >Requested Funding Amount</apex:outputLabel>
            </apex:outputPanel>
            <apex:outputPanel >
                <apex:inputField required="true" value="{!request.Currency__c}"/>
                <apex:inputField required="true" value="{!request.Requested_Funding_Amount__c}" styleClass="shortinput"/>
            </apex:outputPanel>
        </apex:pageBlockSectionItem>

        
        <!-- Materials Section -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Materials Needed: <br></br> (select any that apply)</apex:outputLabel>
            <apex:selectCheckboxes value="{!materials}" layout="pageDirection">
                <apex:selectOptions value="{!materialOptions}" />
            </apex:selectCheckboxes>
        </apex:pageBlockSectionItem>
        <!-- END Materials Section -->
        
        <!-- Product Focus -->
        <apex:inputField required="true" value="{!request.Product_Focus__c}"/>
        <!-- END Product Focus -->
        
    </apex:pageBlockSection>
    <!-- END Event Details -->
 </apex:actionregion>   
    <!-- Venue Info -->
    <apex:pageBlockSection title="Venue Details" columns="1" id="venuedetails" rendered="{!checkMe}" >
        <apex:inputField required="true" value="{!request.Venue_Name__c}"  styleClass="normalinput"/>
        
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Address__c}" styleClass="longinput"/>
            
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- Same actionRegion pattern as above -->
        <apex:pageBlockSectionItem dataStyleClass="requiredInput" >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <div class="requiredInput">
            <div class="requiredBlock"></div>
            <apex:selectList value="{!request.Venue_Country2__c}" size="1">
                <apex:actionSupport event="onchange" reRender="venuestate"/>
                <apex:selectOptions value="{!CountryOptions}"/>
            </apex:selectList>
            </div>
            </apex:actionRegion>
       </apex:pageBlockSectionItem>
    </apex:pageBlockSection> 
    
    <apex:pageBlockSection columns="1" id="venuestate">
        <apex:pageBlockSectionItem rendered="{!venueRequiresState}">
            <apex:outputLabel >State/Province</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_State__c}"/>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    <!-- END Venue Info -->

 

impalacrazy69impalacrazy69

Thanks for everyones help on this. So after more reading on action regions i figured out that without an output panel to rerender that the fields would not work. Becasue i was trying to rerender the pageblocksection vf wouldnt allow so by combing it inside an outputpanel and using that id to rerender the code works. Attached is the the updated code.

 

  <apex:pageBlockSection title="Event Details" id="eventdetails">
        <apex:inputField required="true" value="{!request.Event_Name__c}" styleClass="normalinput"/>
        <apex:inputField required="true" value="{!request.Event_Date__c}"/>
         <apex:pageBlockSectionItem >	
         	<apex:outputLabel > Activity Type </apex:outputLabel>
        	<apex:actionregion >
        		<apex:inputField required="true" value="{!request.Activity_Type__c}"  >
        			<apex:actionSupport event="onchange" reRender="venuedetailspanel"/>
        		</apex:inputField>
        	</apex:actionregion>
        </apex:pageBlockSectionItem>	
        <apex:inputField required="true" value="{!request.Estimated_Leads__c}" styleClass="shortinput"/>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Description</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Event_Description__c}" styleClass="textarea"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputPanel >
                <apex:outputLabel >Currency</apex:outputLabel> <br></br><br></br>
                <apex:outputLabel >Requested Funding Amount</apex:outputLabel>
            </apex:outputPanel>
            <apex:outputPanel >
                <apex:inputField required="true" value="{!request.Currency__c}"/>
                <apex:inputField required="true" value="{!request.Requested_Funding_Amount__c}" styleClass="shortinput"/>
            </apex:outputPanel>
        </apex:pageBlockSectionItem>

        
        <!-- Materials Section -->
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Materials Needed: <br></br> (select any that apply)</apex:outputLabel>
            <apex:selectCheckboxes value="{!materials}" layout="pageDirection">
                <apex:selectOptions value="{!materialOptions}" />
            </apex:selectCheckboxes>
        </apex:pageBlockSectionItem>
        <!-- END Materials Section -->
        
        <!-- Product Focus -->
        <apex:inputField required="true" value="{!request.Product_Focus__c}"/>
        <!-- END Product Focus -->
        
    </apex:pageBlockSection>
    <!-- END Event Details -->
 
    <!-- Venue Info -->
    <apex:outputPanel id="venuedetailspanel">
    <apex:pageBlockSection title="Venue Details" columns="1" id="venuedetails" rendered="{!checkMe}" >
    	<apex:outputtext > {!checkMe} </apex:outputtext>
    	<apex:outputtext > {!testTime} </apex:outputtext>
    	<apex:outputtext > activity_type: {!request.Activity_Type__c} </apex:outputtext>
        <apex:inputField required="true" value="{!request.Venue_Name__c}"  styleClass="normalinput"/>
        
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Address</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Address__c}" styleClass="longinput"/>
            
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >City</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_City__c}"/>
        </apex:pageBlockSectionItem>
        <apex:pageBlockSectionItem >
            <apex:outputLabel >Postal Code</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_Postal__c}"/>
        </apex:pageBlockSectionItem>
        
        <!-- Same actionRegion pattern as above -->
        <apex:pageBlockSectionItem dataStyleClass="requiredInput" >
            <apex:outputLabel >Country</apex:outputLabel>
            <apex:actionRegion >
            <div class="requiredInput">
            <div class="requiredBlock"></div>
            <apex:selectList value="{!request.Venue_Country2__c}" size="1">
                <apex:actionSupport event="onchange" reRender="venuestate"/>
                <apex:selectOptions value="{!CountryOptions}"/>
            </apex:selectList>
            </div>
            </apex:actionRegion>
       </apex:pageBlockSectionItem>
    </apex:pageBlockSection> 

    <apex:pageBlockSection columns="1" id="venuestate">
        <apex:pageBlockSectionItem rendered="{!venueRequiresState}">
            <apex:outputLabel >State/Province</apex:outputLabel>
            <apex:inputField required="true" value="{!request.Venue_State__c}"/>
        </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    </apex:outputPanel>
    <!-- END Venue Info -->

 

Marko LamotMarko Lamot

Nice :)