I have a "header" Visualforce Page which contains a navigation bar with links to other various Visualforce pages. However, one of the links, instead of going to another VF page makes a call to a function in the controller class.
//VF page for Header
<apex:page controller="headerPageController"
sidebar="false"
showheader="false"
cache="false"
expires="0"
standardStylesheets="false">
<div id="navbar">
(link to my page outside of Salesforce.)
<a class="nav" id="cMethod" href="#" onclick="ControllerMethod(); return false;">C</a>
...other nav link to other SF page
...other nav link to other SF page
</div>
These header and footer VF pages are added to each of the other pages directed to from the home screen in order to keep a seamless page feel. The call works fine when clicked from the home screen which uses the included header and not much else.
However, if I am directed to "Page 1" and then click the method link, nothing happens. Why is this? Is an included page's controller method not accessible or overridden by its own controller?
//VF Page for otherPage
<apex:page controller="otherPageController"
sidebar="false"
showheader="false"
cache="false"
expires="0"
standardStylesheets="false">
<body>
<div class="body-container">
<!-- Header -->
<apex:include pageName="header_page" />
.....
More info:
The controller method provides a link on return, which is used as a redirect. When it is clicked on a page other than the home page, a #
is added to the URL and nothing else happens.
headerPageController
//I use a function for this so I can also add request parameters to the
//page reference, they are not shown here as this is just an example.
public with sharing class headerPageController
{
public PageReference ControllerMethod()
{
String url = 'www.google.com';
PageReference pr = new PageReference(url );
return pr;
}
}
Controller()
defined in the VF page(s) (header, otherPage)?ControllerMethod()
is some javascript method? an actionFunction? -- onclick can't call controller methods directly. More details please.include
to other pages. The method works as expected in our main page, but doesn't in other pages that include the header page but define their own controller. So, onclick can call the controller methods directly, it's already working that way. What I'm asking is if an included page's controller/controller methods don't work when added to a page with its own method.actionFunction action="controllerActionMethodName" ...