I'm attempting to rerender an apex:outputPanel containing a visualforce component. When I click the panel containing the onclick code to call the controller method to change values and rerender, nothing happens. I appreciate any help with solving this issue.

I've provide example code below.
Thank you.

VF Page (example_page)

<apex:page controller="ExamplePageController">
  <apex:form >
    <apex:pageBlock title="Example Page">
      <apex:outputPanel layout="block">Example ID: {!exampleId}</apex:outputPanel>
      <apex:outputPanel layout="block" onclick="doSomethin('{!exampleId2}');">Example ID2: {!exampleId2}</apex:outputPanel>
    <apex:actionFunction name="rerenderExample" action="{!updateComponentValue}" rerender="exampleComp">
      <apex:param name="p1" value="" assignTo="{!componentIdValue}" />
    function doSomethin(id) {
  <apex:outputPanel id="exampleComp">
    <c:example_component currentPageController="{!this}" currentId="{!exampleId}" />

VF Component (example_component)

<apex:component controller="ExampleComponentController">
  <apex:attribute name="currentPageController" type="ExamplePageControllerBase" assignTo="{!pageController}" required="true" description="The controller for the page." />
  <apex:attribute name="currentId" type="Id" assignTo="{!myId}" required="true" description="Example Id for display." />
  <apex:pageBlock >
    <apex:outputPanel layout="block">{!myUser.Name}</apex:outputPanel>

VF Component Controller (ExampleComponentController)

public with sharing class ExampleComponentController extends ExampleComponentControllerBase {
    // Component property
    public Id myId { 
        get { return myIdValue; }
        set { myIdValue = value; }

    public User myUser {
        get { return [SELECT Name FROM User WHERE Id = :this.myIdValue]; }

    // Component update method
    public void updateValue(Id newIdValue) {
        myId = newIdValue;

    private Id myIdValue;

VF Page Controller (ExamplePageController)

public with sharing class ExamplePageController extends ExamplePageControllerBase {
    // Page properties
    public Id exampleId { get; set; }
    public Id exampleId2 { get; set; }

    // Page property that sets component property
    public Id componentIdValue { get; set; }

    // Page method that calls component method
    public void updateComponentValue() {

    // Page reference to component controller
    public ExampleComponentController compController { get; set; }

    // ExamplePageControllerBase overrides
    public override ExampleComponentControllerBase getComponentController() {
        return this.compController;

    public override void setComponentController(ExampleComponentControllerBase componentController) {
        this.compController = (ExampleComponentController)componentController;

    // Constructor
    public ExamplePageController() {
        this.exampleId = UserInfo.getUserId();
        User secondUser = [SELECT Name FROM User WHERE Id != :this.exampleId LIMIT 1];

        this.exampleId2 = secondUser.Id;

VF Component Base Controller (ExampleComponentControllerBase)

public with sharing virtual class ExampleComponentControllerBase {
    public ExamplePageControllerBase pageController {
        set { 
            if (value != null) {
                pageController = value;

VF Page Base Controller (ExamplePageControllerBase)

public with sharing virtual class ExamplePageControllerBase {
    public virtual ExampleComponentControllerBase getComponentController() {
        return this.componentController;

    public virtual void setComponentController(ExampleComponentControllerBase componentController) {
        this.componentController = componentController;

    public ExamplePageControllerBase getThis() { return this; }

    private ExampleComponentControllerBase componentController;

1 Answer 1


In your ExamplePageController's method updateComponentValue add line:

exampleId = this.componentIdValue;

So method will look like this:

public void updateComponentValue() {
    exampleId = this.componentIdValue;

and it will work.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .