コード例 #1
0
 protected function Form_Create()
 {
     // For now, let's load Person of ID #1
     // Remember that $this is the Model Connector's parent, because every QControl
     // we get from PersonConnector should have $this as its parent.
     $this->mctPerson = PersonConnector::Create($this, 1);
     // Instead of manually defining and setting up each QLabel and QTextBox,
     // we utilize the ModelConnector's _create() functionality to create them
     // for us.
     //$this->lblFirstName = $this->mctPerson->lblFirstName_Create();
     //$this->lblLastName = $this->mctPerson->lblLastName_Create();
     $this->txtFirstName = $this->mctPerson->txtFirstName_Create();
     $this->txtLastName = $this->mctPerson->txtLastName_Create();
     $this->lstPersonTypes = $this->mctPerson->lstPersonTypes_Create();
     // We can of course also define any additional controls we wish
     $this->btnSave = new QButton($this);
     $this->btnSave->Text = 'Save';
     $this->btnSave->Visible = false;
     $this->btnCancel = new QButton($this);
     $this->btnCancel->Text = 'Cancel';
     $this->btnCancel->Visible = false;
     // Finally, we can define all of our actions
     // ON some of these, we can override and set a CausesValidation handler
     $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click', 'default', true));
     $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));
     //$this->lblFirstName->AddAction(new QClickEvent(), new QAjaxAction('lblFirstName_Click'));
     //$this->lblLastName->AddAction(new QClickEvent(), new QAjaxAction('lblLastName_Click'));
     $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnSave_Click', 'default', true));
     $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->txtFirstName->AddAction(new QEscapeKeyEvent(), new QAjaxAction('btnCancel_Click', 'default', true));
     $this->txtFirstName->AddAction(new QEscapeKeyEvent(), new QTerminateAction());
     $this->txtLastName->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnSave_Click', 'default', true));
     $this->txtLastName->AddAction(new QEnterKeyEvent(), new QTerminateAction());
     $this->txtLastName->AddAction(new QEscapeKeyEvent(), new QAjaxAction('btnCancel_Click', 'default', true));
     $this->txtLastName->AddAction(new QEscapeKeyEvent(), new QTerminateAction());
 }
コード例 #2
0
 /**
  * These tests check to see that the codegen_options.json file is being used during code generation.
  */
 public function testOverrides()
 {
     $mctAddress = AddressConnector::Create(self::$frmTest);
     $blnError = false;
     try {
         $mctAddress->StreetLabel;
     } catch (QUndefinedPropertyException $e) {
         $blnError = true;
     }
     $this->assertTrue($blnError, 'Street Label was removed by override.');
     $this->assertEquals('100px', $mctAddress->CityControl->Width);
     // Many-to-Many settings
     $mctProject = ProjectConnector::Create(self::$frmTest);
     $this->assertEquals(3, $mctProject->PersonAsTeamMemberControl->RepeatColumns);
     $this->assertEquals('Team Members', $mctProject->PersonAsTeamMemberControl->Name);
     // Unique Reverse Reference
     $mctPerson = PersonConnector::Create(self::$frmTest);
     $this->assertTrue($mctPerson->LoginControl->Required, 'Reverse reference was marked required by override file.');
     $objItem = $mctPerson->LoginControl->GetItem(0);
     $this->assertEquals($objItem->Name, '- Select One -', 'Required value was detected by list control.');
 }