+ Start a Discussion
Colin LoretzColin Loretz 

Visualforce button only works in development mode

I have put together a few visualforce pages and the following is the workflow from an opportunity:

Opportunity (standardObject)
  Custom button (to reviewRFP)
reviewRFP (visualforce page - standard Opportunity controller with controller extension)
  CommandButton (<apex:CommandButton value="Select Recipient Partners" onclick="window.parent.location.href='/apex/selectPartners?oppId={!Opportunity.Id}';" />)
 selectPartners (visualforce page - custom controller)

This whole process works perfectly for me when I am in Development Mode.
The CommandButton (in green) will only refresh the page when Development Mode is turned off.

I've checked the profiles by going to Setup > Manager Users > Profiles. I checked each profile's Enabled Apex Class Access and Enabled Visualforce Page Access and have added all the relevant items.

I encountered this problem with CommandButtons not showing up on a visualforce page powered by a standard controller. The solution was to create an empty controller extension and voila! In this case, I'm already using a controller extension and nothing is happening. The last issue can be found here: http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=3416#M3416

Can anyone help me out with this one?

Another note: I can navigate straight to the visualforce page and everything works fine. It appears as though the button is the only misfunctioning part of this puzzle.

Message Edited by Colin Loretz on 07-31-2008 03:48 PM

Message Edited by Colin Loretz on 07-31-2008 03:53 PM
That's not how you should be using commandButton.  Use the action attribute on commandButton to bind to an action method in your controller that returns Page.selectPartners (adding any query string parameters you need).  I wouldn't really expect this to work outside of devmode.  When you're in devmode your page is running in an iframe, so when you're not in devmode, window.parent is probably undefined.

You should feel very suspicious of yourself if you find you have to drop into javascript to redirect to another page.  :)  There's pretty much no reason for it in Visualforce, and there's almost a guarantee that you're really going to screw up your page either in or out of devmode (you might take yourself out of devmode, you might get nested editor toolbars, your redirect might not work at all, etc. etc.)
Colin LoretzColin Loretz
Thanks Jill.

I was not aware I could redirect in that manner. I will give it a shot.

Message Edited by Colin Loretz on 07-31-2008 04:25 PM