Reusing components - revisited
Hello, everybody!
Please help me! I have the following code (fragments): the main (index) page
<?php
require_once('cardemo/qcubed202/qcubed.inc.php');
include('cardemo/modules/language.php');
include('cardemo/classes/body_styles.class.php');
class IndexCardemoForm extends QForm {
protected $body_styles;
protected function Form_Create() {
$this->body_styles = new BodyStyles($this);
$this->body_styles->fillupBodyStyles($this);
}
}
IndexCardemoForm::Run('IndexCardemoForm','indexCardemo.tpl.php');
?> where I include the next class definition, separated for to be reused in a number of other pages:
<?php
class BodyStyles extends QPanel {
public $nrStart;
public $rightArrow;
public function __construct($obj) {
$this->nrStart=0;
$this->rightArrow = new QImageControl($obj,"rightBody");
$this->rightArrow->ImagePath="cardemo/pictures/next_16x43_1.png";
$this->rightArrow->AddAction(new QClickEvent(), new QAjaxControlAction($this,'right_body_styles'));
}
public function right_body_styles($strFormId, $strControlId, $strParameter) {
$this->nrStart = $this->nrStart+1;
$this->fillupBodyStyles($obj);
}
}
?>In the second code, I attach an action to the right arrow, so a function named right_body_styles to be executed. When clicking on the image, the function is serached in the first code (index) and not in the second, where is defined.
My question is: how should I name it in AddAction to be found in the class module?
I need to have it there, otherwise I have to define it in every page where the body_styles class will be included, which I do not want to do.
Thanks,
Sanyi.

Try to pass the panel ($this) instead of the form object when constructing QImageControl. That might help.
<?php$this->rightArrow = new QImageControl($this,"rightBody");
?>
Cheers
Helge