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
Adrian-EAdrian-E 

Conditional visualforce Page Display

ii,

I have two Vforce pages.

 

I want to show page X if the case is high priority and show page Y if it is not.

 

How can I do this within Vforce? 

Message Edited by Adrian-E on 03-09-2009 10:48 PM
Best Answer chosen by Admin (Salesforce Developers) 
Ron HessRon Hess

Not an uncommon request, here is one way.

 

you start with a simple page: 

 

<apex:page sidebar="false"
action="{!redirect}" controller="LocationsExt" >
</apex:page>

 

 Then when this page loads, it calls locationsExt.redirect()

 

redirect() looks like this: 

 

public PageReference redirect() {

// jump to the prefered page,
// default is provided for us by Prefs
String prefUrl = Prefs.object_selected;
PageReference p = new PageReference( prefUrl);
p.setRedirect(true);
return p;
}

 

 

this redirect will allow you to visit one or the other of your pages, your code for redirect will have to read case priority and then specify one page or the other.

 

 

 

 

 

Message Edited by Ron Hess on 03-09-2009 05:15 PM

All Answers

Ron HessRon Hess

Not an uncommon request, here is one way.

 

you start with a simple page: 

 

<apex:page sidebar="false"
action="{!redirect}" controller="LocationsExt" >
</apex:page>

 

 Then when this page loads, it calls locationsExt.redirect()

 

redirect() looks like this: 

 

public PageReference redirect() {

// jump to the prefered page,
// default is provided for us by Prefs
String prefUrl = Prefs.object_selected;
PageReference p = new PageReference( prefUrl);
p.setRedirect(true);
return p;
}

 

 

this redirect will allow you to visit one or the other of your pages, your code for redirect will have to read case priority and then specify one page or the other.

 

 

 

 

 

Message Edited by Ron Hess on 03-09-2009 05:15 PM
This was selected as the best answer
BrianWKBrianWK

Hey Ron,

 

Are there any restricts no what can be done with that redirect? I've done the apex page redirect in a method that also does some setting in other methods before going to the page reference. It's also nested in an If statement so if my requirements are not met, the page does load. I can get the method to call and work correctly when called from a commandbutton - but not when the page loads. Instead I receive an "Invalid root component None found in view /apex/s7statuswizard2?id= ..."

 

The error only occurs when the first if statement returns true and the method does the page reference. I've tried removing the if statement entirely and only having the page reference and I still get the invalid root error. This is on a sandbox that was refreshed 2/27/09

 

public PageReference Initialize() { if(getInterfaces().size() == 1 && getWebs().size() ==1) { List<cImps> WebImps = getWebs(); list<cImps> IfIMps = getInterfaces(); WebImps[0].wSelected = true; ifIMps[0].iPrimary = True; ifImps[0].iSelected = true; ID ParentImpID = this.controller.getRecord().id; PageReference S7StatusWizard2 = Page.S7StatusWizard2; S7StatusWizard2.getParameters().put('Id',ParentImpID); return S7StatusWizard2; } else { return null; } }

 

<apex:page standardcontroller="Parent_Implementation__c" extensions="S7_Status_Controller_Extension" action="{!Initialize}" >

 

pvassilievpvassiliev
I have the same problem. Did you get it resolved?
BrianWKBrianWK

No, I submitted a case and it's been escalated up to the developer group. They were looking at it last night, but I don't have any updates from them yet.

 

One suggestion they made was to remove the action from the apex page component and replace with an actionSupport underneath the apex page component. No idea if that'll work yet though.

 

If I get resolution I'll try to post the results here