+ Start a Discussion
TwEEkTwEEk 

Accessing page:attribute from controller

Lets say I have 

 

 

<apex:component controller="myController"> <apex:attribute name="foo" type="String" /> //REST OF CODE HERE (IRRELEVENT)</apex:component

 

In the controller "myController", how do I retrieve the value of the page attribute "foo"?

 

This is a difficult topic to goole for, because a bunch of hits about different tag attributes come up. 

 

 

 

 

sfdcfoxsfdcfox

Use the assignTo property of the attribute tag in order to access the parameter in your controller. Be sure you have a setX and getX property that is visible to the page ( variable { get; set; } or getVariable() and setVariable()).

 

Edit:

Clarification: You'll need to use the usual merge syntax, for example <apex:attribute name="foo" type="string" assignTo="{!bar}" />. In the controller, include the functions String getBar() and void setBar(String val).

Message Edited by sfdcfox on 12-03-2009 06:33 PM