You need to sign in to do that
Don't have an account?
TehNrd
Force.com Sites, iframes, and navigation
First a little background. Our company already has a website that is managed the old fashion way by our IT department. It is massive, complicated, and there is no way on earth we (I am in a separate group from IT) could convince them to convert to Force.com sites. The website has the two typical navigation bars, one along the top and one on the left. So a much more realistic possibility is using an iframe to embed a force.com site/web app within our site.
Here lies the problem. For an iframe that does not need to navigate anywhere we are good, but based on the use case and logic we may want to redirect the users to different pages. I was hoping that in the the page controller, based on the logic, I could set a string which is a URL and then on the completion of this action method call a javascript method. When doing this it appears that the oncomplete attribute of the action method is actually called before all of the variables are set in the controller.
Here is an example:
As you can see if returns the value of the previous action.
1) Enter 4 + 4, it will return null
2) Enter 4 + 2, it will return 'You know math!'
Thanks,
Jason
Message Edited by TehNrd on 12-03-2008 04:36 PM
Here lies the problem. For an iframe that does not need to navigate anywhere we are good, but based on the use case and logic we may want to redirect the users to different pages. I was hoping that in the the page controller, based on the logic, I could set a string which is a URL and then on the completion of this action method call a javascript method. When doing this it appears that the oncomplete attribute of the action method is actually called before all of the variables are set in the controller.
Here is an example:
Code:
Page: <apex:page controller="iframe"> <apex:form id="form"> <apex:inputText value="{!one}"/> + <apex:inputText value="{!two}"/> = 8 <br/> <apex:commandButton value="Validate" action="{!submit}" rerender="form" oncomplete="done();"/> <script type="text/javascript"> function done(){ var result = '{!result}'; alert(result); <!-- here I could use window.top.location.href = result to redirect the entire page -->
} </script> </apex:form> </apex:page> Controller: public class iframe { public Integer one {get; set;} public Integer two {get; set;} public String result {get; set;} /*In a real world example based on the logic I may want to pass the navigation URL*/ public PageReference submit() { if(one + two == 8){ result = 'You know math!'; // }else{ result = 'Keep trying!'; } system.debug(result ); return null; } }
As you can see if returns the value of the previous action.
1) Enter 4 + 4, it will return null
2) Enter 4 + 2, it will return 'You know math!'
Thanks,
Jason
Message Edited by TehNrd on 12-03-2008 04:36 PM
All Answers
so, in your command button, don't use oncomplete="", rather use rerender
the section that you rerender will have another output panel that is controlled by a rendered="{!doredirect}" expression
in your controller, you have doredirect off, until you have all the math done correctly, then set doredirect to true
in the (now rendered) output panel, you have a snippet of javascript to redirect
pseduo code:
hope this helps.
Only thing I don't like is that now I have logic in my VF page that ideally I would like to have in my controller.
Message Edited by Raizers on 12-12-2008 03:10 AM