Rendering togglemenu options dynamically on Input taskbusiness data

Hi All,
Iam creating a CAF form view which utilizes a toggle menu control. It contains two options that has respective hideablePanels linked to them. I want to dynamically render the toggle menu options, based on inputs passed to CAF form view by task business data , i have decided to use a control assessors to dynamically setup what options to render on beforeRenderResponse action in task. In some instances(randomly), the control accessor for a toggle menu option is returning ‘null’. What can possible be the cause? If you can suggest a better way, please inform me.

Thanks and Regards,
Anil Kumar Ellendula

Hi All,

below logic am using in beforeRenderResponse for rendering togglemenu options on

try{

		getToggleMenu().getChildren().clear();/*Togglemenu Control Acessor*/
		
		
		if(!getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRestricted()
				&&getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRequired()
				&&!getBranchReviewTask().getTaskData().getBranchReviewPI().getManagerReviewRequired()){
			
			displayOption = 2;
			getToggleMenu().getChildren().add(getEmploymentConfirmationItem());
			
			
		}else if(!getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRestricted()&&
				getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRequired()&&
				getBranchReviewTask().getTaskData().getBranchReviewPI().getManagerReviewRequired()){
				displayOption = 3;

getToggleMenu().getChildren().add(getEmploymentConfirmationItem());
getToggleMenu().getChildren().add(getManagerReviewItem());

		}else if((getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRestricted()
				&& getBranchReviewTask().getTaskData().getBranchReviewPI().getManagerReviewRequired())
				|| (!getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRestricted()
						&&!getBranchReviewTask().getTaskData().getBranchReviewPI().getEmploymentConfirmationRequired()
						&& getBranchReviewTask().getTaskData().getBranchReviewPI().getManagerReviewRequired())){
				displayOption = 1;
				getToggleMenu().getChildren().add(getManagerReviewItem());
			
		}
		
		log("calibrateDisplay "+displayOption);
	    if ((displayOption & 1) == 1){
	    	
	   	getToggleMenu().setValue(getManagerReviewItem().getItemValue());
	          	getHpManagerReview().setRendered(true);
	    	getHpManagerReview().setVisible(true);
	    	getHpManagerReview().setDisableWhenHidden(false);
	    }
	    
	    if ((displayOption & 2) == 2){
	    	
	    	getToggleMenu().setValue(getEmploymentConfirmationItem().getItemValue());
	    	getHpEmploymentConfirmation().setRendered(true);
	    	getHpEmploymentConfirmation().setVisible(true);
	    	getHpEmploymentConfirmation().setDisableWhenHidden(false);
	    }
		
	}catch (Exception e) {
		throw new RuntimeException(e);
	}

Please any one guide me am i doing right way of rendering togglemenu options on runtime depends on task input business data.

Thanks and Regards,