Lançado Adianti Framework 7.6!
Clique aqui para saber mais
Dúvida no método onExitAction Boa noite, estou precisando de ajuda com um probleminha.. creio que deva ser falta de conhecimento no framework, mas está ocorrendo o seguinte, tenho no meu formulário um método de saída para que ao sair do SeekButton, seja capturado o sexo da matriz que foi selecionado, porém está aparecendo a seguinte mensagem: "Notice: Undefined index: idMatriz in C:\xampp\htdocs\webfish1\app\contr...
TS
Dúvida no método onExitAction  
Fechado
Boa noite,
estou precisando de ajuda com um probleminha.. creio que deva ser falta de conhecimento no framework, mas está ocorrendo o seguinte, tenho no meu formulário um método de saída para que ao sair do SeekButton, seja capturado o sexo da matriz que foi selecionado, porém está aparecendo a seguinte mensagem: "Notice: Undefined index: idMatriz in C:\xampp\htdocs\webfish1\app\control\regraNegocio\FrmMestreReproducao.class.php on line 276". Se alguém já tiver passado e saiba como resolver, estou precisando de um auxilio. Att.

Curso completo Meu Negócio Pronto
Use para si, ou transforme em um negócio: Inclui aulas e códigos-fontes
Gestor de conteúdo (SITE) + Loja Virtual (E-Commerce) + Emissor de Notas para infoprodutos


Meu negócio pronto Quero me inscrever agora!

Comentários (12)


LA

Ola Thiago

Posta como fez!
me parece ser algo errado na classe model da tabela usada na busca.
TS

Boa noite Luiz ALberto,

escrevi o método desse jeito:

  1. <?php
  2.  public static function onExitMatriz($param)
  3.    {
  4.        $idMatriz $param['idMatriz'];
  5.        try
  6.        {
  7.        
  8.            TTransaction::open('dbwf');
  9.                $matriz  = new Matriz($idMatriz);
  10.                
  11.                $obj = new StdClass;
  12.                $obj->sexoMatriz $matriz->sexoMatriz;
  13.            TTransaction::close();
  14.            TForm::sendData('FrmMestreReproducao'$obj);
  15.        
  16.        }
  17.        catch(Exception $e)
  18.        {
  19.            
  20.        
  21.        }
  22. ?>
TS

minha classe model que é estanciada para o método é essa:]

  1. <?php
  2. /**
  3.  * Matriz Active Record
  4.  * @author  <your-name-here>
  5.  */
  6. class Matriz extends TRecord
  7. {
  8.     const TABLENAME 'matriz';
  9.     const PRIMARYKEY'idMatriz';
  10.     const IDPOLICY =  'max'// {max, serial}
  11.     
  12.     
  13.     private $especies;
  14.     private $tanque;
  15.     /**
  16.      * Constructor method
  17.      */
  18.     public function __construct($idMatriz NULL$callObjectLoad TRUE)
  19.     {
  20.         parent::__construct($idMatriz$callObjectLoad);
  21.         parent::addAttribute('numeroChipMatriz');
  22.         parent::addAttribute('pesoMatriz');
  23.         parent::addAttribute('compCabecaMatriz');
  24.         parent::addAttribute('compParcialMatriz');
  25.         parent::addAttribute('compTotalMatriz');
  26.         parent::addAttribute('sexoMatriz');
  27.         parent::addAttribute('larguraMatriz');
  28.         parent::addAttribute('idEspecie');
  29.         parent::addAttribute('dataCadastro');
  30.         parent::addAttribute('status');
  31.     }
  32.     
  33.     /**
  34.      * Method addEspecie
  35.      * Add a Especie to the Matriz
  36.      * @param $object Instance of Especie
  37.      */
  38.     public function addEspecie(Especie $object)
  39.     {
  40.         $this->especies[] = $object;
  41.     }
  42.     
  43.     /**
  44.      * Method getEspecies
  45.      * Return the Matriz' Especie's
  46.      * @return Collection of Especie
  47.      */
  48.     public function getEspecies()
  49.     {
  50.         return $this->especies;
  51.     }
  52.     public function get_especies_descricao(){
  53.     
  54.         if(empty($this->especies)){
  55.             $this->especies = new Especie($this->idEspecie);
  56.         }
  57.         return $this->especies->nomePopularEspecie;
  58.     
  59.     }
  60.     
  61.     /**
  62.      * Method set_tanque
  63.      * Sample of usage: $matriz->tanque = $object;
  64.      * @param $object Instance of Tanque
  65.      */
  66.     public function set_tanque(Tanque $object)
  67.     {
  68.         $this->tanque $object;
  69.         $this->idtanque $object->id;
  70.     }
  71.     
  72.     /**
  73.      * Method get_tanque
  74.      * Sample of usage: $matriz->tanque->attribute;
  75.      * @returns Tanque instance
  76.      */
  77.     public function get_tanque()
  78.     {
  79.         // loads the associated object
  80.         if (empty($this->tanque))
  81.             $this->tanque = new Tanque($this->idtanque);
  82.     
  83.         // returns the associated object
  84.         return $this->tanque;
  85.     }
  86.     
  87.     /**
  88.      * Reset aggregates
  89.      */
  90.     public function clearParts()
  91.     {
  92.         $this->especies = array();
  93.     }
  94.     /**
  95.      * Load the object and its aggregates
  96.      * @param $id object ID
  97.      */
  98.     public function load($id)
  99.     {
  100.     
  101.         // load the related Especie objects
  102.         $repository = new TRepository('Especie');
  103.         $criteria = new TCriteria;
  104.         $criteria->add(new TFilter('idEspecie''='$id));
  105.         $this->especies $repository->load($criteria);
  106.     
  107.         // load the object itself
  108.         return parent::load($id);
  109.     }
  110.     /**
  111.      * Store the object and its aggregates
  112.      */
  113.     public function store()
  114.     {
  115.         // store the object itself
  116.         parent::store();
  117.     
  118.         // delete the related Especie objects
  119.         $criteria = new TCriteria;
  120.         $criteria->add(new TFilter('idEspecie''='$this->id));
  121.         $repository = new TRepository('Especie');
  122.         $repository->delete($criteria);
  123.         // store the related Especie objects
  124.         if ($this->especies)
  125.         {
  126.             foreach ($this->especies as $especie)
  127.             {
  128.                 unset($especie->id);
  129.                 $especie->idMatriz $this->id;
  130.                 $especie->store();
  131.             }
  132.         }
  133.     }
  134.     /**
  135.      * Delete the object and its aggregates
  136.      * @param $id object ID
  137.      */
  138.     public function delete($id NULL)
  139.     {
  140.         $id = isset($id) ? $id $this->id;
  141.         // delete the related Especie objects
  142.         $repository = new TRepository('Especie');
  143.         $criteria = new TCriteria;
  144.         $criteria->add(new TFilter('idEspecie''='$id));
  145.         $repository->delete($criteria);
  146.         
  147.     
  148.         // delete the object itself
  149.         parent::delete($id);
  150.     }
  151. }
SS

Boa Noite, Não sou muito experiente na área mas acredito que não existe o indice 'idMatriz' em $param.
utilize echo var_dump($param) e confime se existe ou não.
TS

Eu fiz algumas tentativas, mas continua dando erro. Se alguém puder me auxiliar em como resolver
SS

Thiago,

Tenta setar o idMatriz somente para teste

  1. <?php
  2.  public static function onExitMatriz($param)
  3.    {
  4.              $idMatriz '1'//VEJA SE O ERRO CONTINUA
  5.            // $idMatriz = $param['idMatriz'];
  6.        try
  7.        {
  8.        
  9.            TTransaction::open('dbwf');
  10.                $matriz  = new Matriz($idMatriz);
  11.                
  12.                $obj = new StdClass;
  13.                $obj->sexoMatriz $matriz->sexoMatriz;
  14.            TTransaction::close();
  15.            TForm::sendData('FrmMestreReproducao'$obj);
  16.        
  17.        }
  18.        catch(Exception $e)
  19.        {
  20.            
  21.        
  22.        }
  23. ?>


Veja o que tem no array $param com o var_dump por favor.
Como disse não sou tão experiente, mas acho que qualquer ajuda é bem vinda.
no aguardo
JD

Olá Thiago, tudo bom?
Este erro ocorre quando não é possivel localizar o índice no Array, no seu caso o indice é idMatriz, tente o seguinte:
  1. <?php
  2. public static function onExitMatriz($param)
  3.    {
  4.              echo "<pre>";
  5.              var_dump($param);
  6.            $idMatriz $param['idMatriz'];
  7.        try
  8.        {
  9.        
  10.            TTransaction::open('dbwf');
  11.                $matriz  = new Matriz($idMatriz);
  12.                
  13.                $obj = new StdClass;
  14.                $obj->sexoMatriz $matriz->sexoMatriz;
  15.            TTransaction::close();
  16.            TForm::sendData('FrmMestreReproducao'$obj);
  17.        
  18.        }
  19.        catch(Exception $e)
  20.        {
  21.            
  22.        
  23.        }
  24. ?>

Isso vai retornar toda a estrutura da variável $param.
Poste o retorno aqui no fórum para que possamos analizar.</pre>
TS

Jheferson Fonseca:, segue abaixo o que foi retornado:

array(27) { ["class"]=> string(19) "FrmMestreReproducao" ["method"]=> string(12) "onExitMatriz" ["static"]=> string(1) "1" ["codigo"]=> string(10) "0000000001" ["idReproducao"]=> string(1) "1" ["dataInicioReproducao"]=> string(19) "2016-04-16 00:23:03" ["temperatura"]=> string(0) "" ["equipeReproducao"]=> string(0) "" ["climaDia"]=> string(0) "" ["txEclosao"]=> string(0) "" ["txFecundacao"]=> string(0) "" ["dataFinalReproducao"]=> string(19) "2016-04-16 00:23:03" ["qtdeMatFemea"]=> string(1) "0" ["qtdeMatMacho"]=> string(0) "" ["totalGeralHormonio"]=> string(0) "" ["pesoTotMatFemea"]=> string(1) "0" ["pesoTotMatMacho"]=> string(1) "0" ["pesoGeralMatriz"]=> string(1) "0" ["matrizes_id"]=> string(1) "2" ["matrizes_numeroChipMatriz"]=> string(0) "" ["matrizes_identMatriz"]=> string(0) "" ["matrizes_pesoMatriz"]=> string(0) "" ["matrizes_sexoMatriz"]=> string(0) "" ["matrizes"]=> string(0) "" ["reproducao_incubadoras"]=> array(1) { [0]=> string(1) "3" } ["key"]=> string(1) "2" ["ajax_lookup"]=> string(1) "1"}
Notice: Undefined index: idMatriz in C:\xampp\htdocs\webfish1\app\control\regraNegocio\FrmMestreReproducao.class.php on line 283
SS

Thiago, testa da seguinte forma:

  1. <?php
  2.  public static function onExitMatriz($param)
  3.    {
  4.        $idMatriz $param['key'];
  5.        try
  6.        {
  7.        
  8.            TTransaction::open('dbwf');
  9.                $matriz  = new Matriz($idMatriz);
  10.                
  11.                $obj = new StdClass;
  12.                $obj->sexoMatriz $matriz->sexoMatriz;
  13.            TTransaction::close();
  14.            TForm::sendData('FrmMestreReproducao'$obj);
  15.        
  16.        }
  17.        catch(Exception $e)
  18.        {
  19.            
  20.        
  21.        }
  22. ?>
TS

Sergio,

assim ele não retorna erro, porém não preenche o TEntry com o Sexo da Matriz.
SS

tenta:
  1. <?php
  2.                $obj = new StdClass;
  3.                $obj->matrizes_sexoMatriz $matriz->sexoMatriz;
  4. ?>
TS

Vlw Sergio, deu certo agora, era isso que estava errado então!.

Vlw