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
ckahlckahl 

Dynamic Page Sections

 I have a visualforce page that I'm working on and it's the first time I've used dynamic sections.  I have an object called Work Orders.  There are two different types of work orders 1)Sign Orders and 2)Design Orders.  When either type is selected, I want the section to appear with the appropriate fields.  So far, it seems to work fine when the user selects the "Sign" work order type.  However, when the "Design Only" type is selected, "applying value..." appears next to the field and nothing happens until AFTER the user hits the save button.  After the save button is pressed, appropriate section is shown. Why does it work correctly when the "Sign" type is selected and not the "Design Only" option.

 

 

<apex:page standardController="Work_Orders__c" sidebar="false">
    <apex:sectionHeader title="Edit Work Order" subtitle="{!Work_Orders__c.name}"/>
    <apex:form >
        <apex:pageBlock title="Edit Work Order" id="thePageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>               
            </apex:pageBlockButtons>
            <apex:actionRegion >
                <apex:pageBlockSection title="Basic Information" columns="1">
                    <apex:inputField value="{!Work_Orders__c.name}"/>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Work Order Type"/>
                        <apex:outputPanel >
                            <apex:inputField value="{!Work_Orders__c.WO_Type__c}">
                                <apex:actionSupport event="onchange" rerender="thePageBlock"
                                                    status="status"/>
                            </apex:inputField>
                            <apex:actionStatus startText="applying value..." id="status"/>
                        </apex:outputPanel>
                    </apex:pageBlockSectionItem>
                    <apex:inputField value="{!Work_Orders__c.Project__c}"/>
                    <apex:inputField value="{!Work_Orders__c.Order_Status__c}"/>                    
                </apex:pageBlockSection>
            </apex:actionRegion>
            <apex:pageBlockSection title="Design Information" columns="1"
                                   rendered="{!Work_Orders__c.WO_Type__c == 'Design Only'}">
                <apex:inputField value="{!Work_Orders__c.Design_Description__c}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Sign Information" columns="2"
                                   rendered="{!Work_Orders__c.WO_Type__c == 'Sign'}">
                <apex:inputField value="{!Work_Orders__c.Verbiage__c}"/>
                <apex:inputField value="{!Work_Orders__c.Background_Color__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Sign_Options__c}"/>
                <apex:inputField value="{!Work_Orders__c.Template__c}"/>
                <apex:inputField value="{!Work_Orders__c.Text_Color__c}"/>
                <apex:inputField value="{!Work_Orders__c.Vinyl_Style__c}"/>
                <apex:inputField value="{!Work_Orders__c.Vinyl_Type__c}"/>
                <apex:inputField value="{!Work_Orders__c.Width__c}"/>
                <apex:inputField value="{!Work_Orders__c.Type__c}"/>
                <apex:inputField value="{!Work_Orders__c.Material__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Order_Comments__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Type__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Type__c}"/>                  
            </apex:pageBlockSection>
        </apex:pageBlock>
            </apex:form>
</apex:page>

 

asish1989asish1989

Hi

   I think .It must be checking from database value wheather Work__Order__c.Type__c has 'sign ' value or not .

   why dont you try by using actionFunction .It will fullfill your requirement . 

   There is some code you can follow...

   

<apex:page standardController="Work_Orders__c" sidebar="false" extension = "WorkOrderExtension">
    <apex:sectionHeader title="Edit Work Order" subtitle="{!Work_Orders__c.name}"/>
	
	<script type="text/javascript">
  function Callmefunc(id)
   {
   alert(id);
   var type = document.getElementById(id).value;
   alert(type);
   alert('hi');
    
    check(type); 
    //return true;
    
   
   }
    <apex:form >
	
		<apex:actionFunction name="check" action="{!getSelected}" reRender="thePageBlock">
                    <apex:param name="Mahavir" value="" />
                </apex:actionFunction>
        <apex:pageBlock title="Edit Work Order" id="thePageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>               
            </apex:pageBlockButtons>
            <apex:actionRegion >
                <apex:pageBlockSection title="Basic Information" columns="1">
                    <apex:inputField value="{!Work_Orders__c.name}"/>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Work Order Type"/>
                        <apex:outputPanel >
                            <apex:inputField value="{!Work_Orders__c.WO_Type__c}" id="check"  onchange="Callmefunc('{!$Component.check}');"/>
                            
                        </apex:outputPanel>
                    </apex:pageBlockSectionItem>
                    <apex:inputField value="{!Work_Orders__c.Project__c}"/>
                    <apex:inputField value="{!Work_Orders__c.Order_Status__c}"/>                    
                </apex:pageBlockSection>
            </apex:actionRegion>
            <apex:pageBlockSection title="Design Information" columns="1"
                                   rendered="{!display = 'not visible'}">
                <apex:inputField value="{!Work_Orders__c.Design_Description__c}" />
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Sign Information" columns="2"
                                   rendered="{!display == 'visible'}">
                <apex:inputField value="{!Work_Orders__c.Verbiage__c}"/>
                <apex:inputField value="{!Work_Orders__c.Background_Color__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Sign_Options__c}"/>
                <apex:inputField value="{!Work_Orders__c.Template__c}"/>
                <apex:inputField value="{!Work_Orders__c.Text_Color__c}"/>
                <apex:inputField value="{!Work_Orders__c.Vinyl_Style__c}"/>
                <apex:inputField value="{!Work_Orders__c.Vinyl_Type__c}"/>
                <apex:inputField value="{!Work_Orders__c.Width__c}"/>
                <apex:inputField value="{!Work_Orders__c.Type__c}"/>
                <apex:inputField value="{!Work_Orders__c.Material__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Order_Comments__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Type__c}"/> 
                <apex:inputField value="{!Work_Orders__c.Type__c}"/>                  
            </apex:pageBlockSection>
        </apex:pageBlock>
            </apex:form>
</apex:page>

public class WorkOrderExtension{
	public String display{get;set;}
	public String workOrderType{get;set;}
	public WorkOrderExtension(ApexPages.StandardController controller){
	}
	public PageReference getSelected() {
		groupQuesName = System.currentPageReference().getParameters().get('Mahavir');
		if(groupQuesName == 'Sign'){
			display = 'visible';
		}
		else{
		    display = 'not visible';
		}
		return null;
	}
}	

 Did this post answers your question ,If so please mark it as solutions so that Others get benifited.

 

Thanks

asish

ckahlckahl

When I go to create the extension I get this- "Error: Compile Error: line 7:74 no viable alternative at character '' at line 7 column 74"

 

 

 

 

public class WorkOrderExtension{
    public String display{get;set;}
    public String workOrderType{get;set;}
    public WorkOrderExtension(ApexPages.StandardController controller){
    }
    public PageReference getSelected() {
        groupQuesName = System.currentPageReference().getParameters().get('Mahavir');
        if(groupQuesName == 'Sign'){
            display = 'visible';
        }
        else{
            display = 'not visible';
        }
        return null;
    }
}

 

asish1989asish1989

HI

   will you kindely check this..

       public String workOrderType{get;set;}

       public PageReference getSelected() {
        workOrderType = System.currentPageReference().getParameters().get('Mahavir');
        if(workOrderType == 'Sign'){
            display = 'visible';
        }
        else{
            display = 'not visible';
        }
        return null;
    }
}

 

Try this and let me know It works or not ....

Did this post answers your questions,If so please mark it solved so that others get benifited..

 

Thanks

asish

ckahlckahl

I still get the error- Error: WorkOrderExtension Compile Error: Variable does not exist: display at line 6 column 13

public class WorkOrderExtension {
       public String workOrderType{get;set;}
       public PageReference getSelected() {
        workOrderType = System.currentPageReference().getParameters().get('Mahavir');
        if(workOrderType == 'Sign'){
            display = 'visible';
        }
        else{
            display = 'not visible';
        }
        return null;
    }
}

 

asish1989asish1989

Hi

   Please declaire a variable like this and let me know wheather it works or not

    public String display{get;set;}

   your final code...

public class WorkOrderExtension {
       public String display{get;set;}
       public String workOrderType{get;set;}
       public PageReference getSelected() {
        workOrderType = System.currentPageReference().getParameters().get('Mahavir');
        if(workOrderType == 'Sign'){
            display = 'visible';
        }
        else{
            display = 'not visible';
        }
        return null;
    }
}

 DId this post answers your question,if so please mark it solved so that other's get benifited.

 

Thanks

asish

 

 

 

ckahlckahl

I'm not sure how to do that exactly.