QDialogBox closing without a button click action

thread: 4 messages  |  last: a year ago  |  started: tuesday, may 18, 2010, 12:35 pm pdt


#1  |  ssunderl (Washington,D.C.) United States of America
Tuesday, May 18, 2010, 12:35 PM PDT

Thanks to Mike Ho and all contributors for your work! Qcodo is a great framework.

I am trying to popup a dialog box after I've redirected to a copied form. The redirect and call to show the QDialogBox are done like this (code snippets):

     $strJs = “window.location = 'public_form_edit.php?intId=" . $this->objPublicForm->Id .
            “&isCopied=true&CopiedTicket=" . $this->strCopiedTicketNumber . “'”;
     QApplication::ExecuteJavaScript($strJs);  

     // ask for amend note
     if ($this->GetControl($strControlId)->Text == 'Amend')
     {      
        $this->noteType = 'regular';
        $this->dlgAmendPopup->ShowDialogBox();
        $this->strCntrlId = $strControlId; // save controlId for use later
     }

     public function ShowDialogBox() {
          parent::ShowDialogBox();
          $this->txtNote->Focus();          
     }

The redirect works and the dialog box shows briefly and then closes. The dialog box has save and cancel buttons which hide the dialog box and the $strCloseCallback method saves the text from the dialog.

I don't know the internals of QCodo very well but expected the dialog box to popup and wait until either the save or cancel button was clicked. I'm not sure what is triggering the quick close of the dialog.

Any help/explanation is appreciated!
Thanks.

#2  |  Mike Ho (Sunnyvale, CA) United States of America Qcodo Administrator
Wednesday, May 19, 2010, 8:45 AM PDT

could you provide more context for your code snippets?  I'm not really sure what I'm looking at... is this code from a QForm subclass?  What method are the first couple of lines in?  Or is this code from a custom QDialogBox subclass?

And if it's the latter, how is the QForm or parent QControl calling it?

#3  |  ssunderl (Washington,D.C.) United States of America
Wednesday, May 19, 2010, 9:26 AM PDT

Sorry, yes the first couple of line are from a QForm subclass. There is a button click action on the QForm that creates a copy of the current form and then does a redirect to that new form.

I'm trying to call the show dialog method once the redirect to the new form is finished. The form subclass code is pretty long.

The QDialogBox subclass code is:

   class NotePopUp extends QDialogBox {
       // PUBLIC Child Controls
       //public $pnlNoteDisplay;
       public $btnSave;
       public $btnCancel;
       public $txtNote;
                                     
       public $strCloseCallback;        
       // Default Overrides
       protected $blnMatteClickable = false;
       protected $strTemplate = 'NotePopUp.tpl.php';
       protected $strCssClass = 'Note_popup';
       protected $strToolTip = 'Please enter your note and click the Save button';
       

       public function __construct($strCloseCallback, $objParentObject, $strControlId = null) {
           parent::__construct($objParentObject, $strControlId);
           $this->strCloseCallback = $strCloseCallback;
           // Define local child controls
           //$this->pnlNoteDisplay = new QPanel($this);
           
           $this->txtNote = new QTextBox($this);            
           $this->txtNote->Required = true;            
           $this->txtNote->Name = “Note:”;            
               $this->txtNote->TextMode = QTextMode::MultiLine;
           $this->txtNote->Width = '400';
                                                       
           $this->btnSave = new QButton($this);
           $this->btnSave->Text = 'Save Note';
           // stop any further actions on the currently processing event - clicks on save button
           $this->btnSave->AddAction(new QClickEvent(), new QToggleEnableAction($this->btnSave));            
           $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));

           $this->btnCancel = new QButton($this);
           $this->btnCancel->Text = 'Cancel';
           $this->btnCancel->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnCancel_Click'));

       }


       public function btnCancel_Click() {
          $this->HideDialogBox();
       }
       
       public function btnSave_Click() {
          if (strlen(trim($this->txtNote->Text)) > 0)
          {
            call_user_func(array($this->objForm, $this->strCloseCallback));
            $this->HideDialogBox();
          }
          else {
            $this->txtNote->Warning = “Please enter your note.”;
          }

       }
             
       public function ShowDialogBox() {
          parent::ShowDialogBox();
          $this->txtNote->Focus();
       }
       
       public function HideDialogBox() {
          parent::HideDialogBox();
       }

   }

The QForm subclass creates an instance :
    // dialog box for notes
     $this->dlgAmendPopup = new NotePopUp('dlgNoteAmend_Close',$this);


The QForm subclass button action that causes the copy,redirect to that form and dialog popup:

  protected function btnAmend_Click($strFormId, $strControlId, $strParameter) {
     $this->btnCopy_Click($strFormId, $strControlId, $strParameter);
           
     $this->noteType = 'regular';
     $this->dlgAmendPopup->ShowDialogBox();
  }

  protected function btnCopy_Click($strFormId, $strControlId, $strParameter) {
// code ....
     $strJs = “window.location = 'public_form_edit.php?intId=" . $this->objPublicForm->Id .
            “&isCopied=true&CopiedTicket=" . $this->strCopiedTicketNumber . “'”;
     QApplication::ExecuteJavaScript($strJs);  
}

  public function dlgNoteAmend_Close() {
     $this->saveNote($this->dlgAmendPopup->txtNote->Text);
}

Hope this makes more sense.
Thank you for your help.

#4  |  ssunderl (Washington,D.C.) United States of America
Wednesday, May 19, 2010, 11:21 AM PDT

Mike,
I found a solution to my problem. I passed an another parameter to the redirected form. Once the redirected form is finished displaying, I check for the 'amend' parameter and then popup the dialog box.

I think the problem before I was calling the dialog box from the previous form right after the redirect.

Thank you for your help.



Copyright © 2005 - 2012, Quasidea Development, LLC
This open-source framework for PHP is released under the terms of The MIT License.