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 Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


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


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. TTransaction::open('dbwf');
  10. $matriz = new Matriz($idMatriz);
  11. $obj = new StdClass;
  12. $obj->sexoMatriz = $matriz->sexoMatriz;
  13. TTransaction::close();
  14. TForm::sendData('FrmMestreReproducao', $obj);
  15. }
  16. catch(Exception $e)
  17. {
  18. }
  19. ?>

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. TTransaction::open('dbwf');
  8. $matriz = new Matriz($idMatriz);
  9. $obj = new StdClass;
  10. $obj->sexoMatriz = $matriz->sexoMatriz;
  11. TTransaction::close();
  12. TForm::sendData('FrmMestreReproducao', $obj);
  13. }
  14. catch(Exception $e)
  15. {
  16. }
  17. ?>
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