Hi!

I am using Dojo with sevarals input form, and before the view appear, it can 
take 5 seconds, even in local...

When I desactivate Dojo, it really quick.

When online, 

Any idea on how I could improve performance ?

Here is my code : 



AdminController.php : 

    public function preDispatch ()
    {
       $this->layout = Zend_Layout::getMvcInstance(); 
       $this->view->addHelperPath('Zend/Dojo/View/Helper', 
'Zend_Dojo_View_Helper');
       $this->translate = Zend_Registry::get('translate');      
       $this->layout->translate = Zend_Registry::get('translate');
       $this->layout->controller = $this->getRequest()->getControllerName();
    }

public function customerAction()
    {
        $this->layout->field_left_title = 
$this->translate->_("admin_customer_left_title");
        $this->layout->field_middle_title = 
$this->translate->_("admin_customer_middle_title");
        $this->layout->field_right_title = 
$this->translate->_("admin_customer_right_title");        
        $id = $this->_getParam('id');

        $view = new Zend_View();
        $view->translate = Zend_Registry::get('translate');
        $view->id = $id;

        $customer = new CustomerModel();
        if ($id != "new")
        {
            $view->form = $customer->get($id);    
        } else {
            $view->form = $_POST;    
        }
        
        if (!empty($this->error))
        {
            $view->error = $this->error;
        }
        
        $view->setScriptPath('../application/views/scripts/index');
        
        Zend_Dojo::enableView($view);
       
        
        $customer = new CustomerModel();
        $view->customers_count = $customer->count(); 
        $view->customer_per_page = 7;
        $paginator = Zend_Paginator::factory($customer->get());
        $paginator->setCurrentPageNumber($this->_getParam('page'));
        $paginator->setItemCountPerPage($view->customer_per_page);
        $paginator->setPageRange(0);
        $view->paginator->translate = Zend_Registry::get('translate');
        $view->paginator = $paginator;
        $view->setScriptPath('../application/views/scripts/customer/admin/');
        $this->layout->field_left_content = $view->render('left.phtml');

        
$view->setScriptPath('../application/views/scripts/customer/admin/customer');
        $this->layout->field_middle_content = $view->render('middle.phtml');
        $this->layout->field_right_content = $view->render('right.phtml');
        $this->layout->main_js = $view->render('js.phtml');
    }    



Layout : 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="fr" lang="fr">
<head>
<title><?=$this->layout()->main_title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />  
<meta http-equiv="Expires" content="0" />
<? 
$dojo_theme = 'tundra';
/*if ($this->dojo()->isEnabled())
{   
   $this->dojo()->setLocalPath('/js/dojo/dojo.js')
                ->addStyleSheetModule('dijit.themes.'.$dojo_theme);
   echo $this->dojo();
}*/
?>

Etc...



middle.phtml

<input type="button" class="buttonblue" 
value="<?=$this->translate->_("customer_submenu_general");?>" 
onclick="showCustomerGeneral()" style="cursor:pointer">
<input type="button" class="buttonblue" 
value="<?=$this->translate->_("customer_submenu_account");?>" 
onclick="showCustomerAccount()" style="cursor:pointer">
<input type="button" class="buttonblue" 
value="<?=$this->translate->_("customer_submenu_option");?>" 
onclick="showCustomerOption()" style="cursor:pointer">
<input type="button" class="buttonblue" 
value="<?=$this->translate->_("customer_submenu_note");?>" 
onclick="showCustomerNote()" style="cursor:pointer">
<hr>

<form id="customer" name="customer" method="POST" 
action="<?=URL?>admin/customersave/id/new">
<div id="customer_general" style="display: block;height:600px;">
<table width="100%">
<?php

$this->dojo()->enable()
    ->setDjConfigOption('parseOnLoad', true)
    ->requireModule('dijit.Dialog');

if ($this->id != 'new' ) {
?>
                <tr><td><?= 
$this->translate->_("customer_id")?></td><td><?=$this->form['customer_id'];?></td></tr>
<? } ?>
<tr><td width="200">

<input type="hidden" name="customer_date_creation" value="<?=date("Y-m-d");?>">

<?= $this->translate->_("customer_civility")?></td><td>
<?php echo $this->radioButton(
    'customer_civility',
    $this->form['customer_civility'],
    array(),
    array(),
    array(
        'f' => $this->translate->_("customer_civility_female"),
        'm' => $this->translate->_("customer_civility_male"),
    )
);
?>
</td></tr>

                <tr><td><?=$this->translate->_("customer_name");?></td><td><?php
echo $this->validationTextBox(
   'customer_name',
   $this->form['customer_name'],
   array(
       'required' => true,
       'regExp'   => '[a-zA-Z\s]+',
       'invalidMessage' => $this->translate->_("customer_name_invalidMessage"),
       'class' => 'admin_customer_general_name',
   ),
   array(
       'maxlength' => 50,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_firstname");?></td><td><?php
echo $this->validationTextBox(
   'customer_firstname',
   $this->form['customer_firstname'],
   array(
       'required' => true,
       'regExp'   => '[a-zA-Z\s]+',
       'invalidMessage' => 
$this->translate->_("customer_firstname_invalidMessage"),
       'class' => 'admin_customer_general_firstname',
   ),
   array(
       'maxlength' => 50,
   )
);
?></td></tr>
                
<tr><td><?=$this->translate->_("customer_birthday");?></td><td><?php

    echo $this->dateTextBox(
    'customer_birthday',
   $this->form['customer_birthday'],
    array('required' => true,
    'class' => 'admin_customer_general_birthday',
    )
    );
                ?></td></tr>
                <tr><td colspan="2"><hr width="250" align="left"></td></tr>
                
<tr><td><?=$this->translate->_("customer_address");?></td><td><?php
echo $this->validationTextBox(
   'customer_address',
   $this->form['customer_address'],
   array(
       'required' => true,
       'regExp'   => '[\,\.a-zA-Z\s]+',
       'invalidMessage' => 
$this->translate->_("customer_address_invalidMessage"),
       'class' => 'admin_customer_general_firstname',
   ),
   array(
       'maxlength' => 50,
   )
);
?></td></tr>
                
<tr><td><?=$this->translate->_("customer_postcode");?></td><td><?php
echo $this->validationTextBox(
   'customer_postcode',
   $this->form['customer_postcode'],
   array(
       'required' => true,
       'regExp'   => '\d{5}',
       'invalidMessage' => 
$this->translate->_("customer_postcode_invalidMessage"),
       'class' => 'admin_customer_general_postcode',
   ),
   array(
       'maxlength' => 5,
   )
);
?></td></tr>
                <tr><td><?=$this->translate->_("customer_city");?></td><td><?php
echo $this->validationTextBox(
   'customer_city',
   $this->form['customer_city'],
   array(
       'required' => true,
       'regExp'   => '[\-\,\.a-zA-Z\s]+',
       'invalidMessage' => $this->translate->_("customer_city_invalidMessage"),
       'class' => 'admin_customer_general_city',
   ),
   array(
       'maxlength' => 50,
   )
);
?></td></tr>
                
<tr><td><?=$this->translate->_("customer_country");?></td><td><?php
echo $this->validationTextBox(
   'customer_country',
   $this->form['customer_country'],
   array(
       'required' => true,
       'regExp'   => '[\-\,\.a-zA-Z\s]+',
       'invalidMessage' => 
$this->translate->_("customer_country_invalidMessage"),
       'class' => 'admin_customer_general_country',
   ),
   array(
       'maxlength' => 50,
   )
);
?></td></tr>
                
                <tr><td colspan="2"><hr width="250" align="left"></td></tr>

                
<tr><td><?=$this->translate->_("customer_mobile");?></td><td><?php
echo $this->validationTextBox(
   'customer_mobile',
   $this->form['customer_mobile'],
   array(
       'required' => true,
       'regExp'   => '[0-9\+]+',
       'invalidMessage' => 
$this->translate->_("customer_mobile_invalidMessage"),
       'class' => 'admin_customer_option_mobile',
   ),
   array(
       'maxlength' => 20,
   )
);
?></td></tr>
                
<tr><td><?=$this->translate->_("customer_email");?></td><td><?php
echo $this->validationTextBox(
   'customer_email',
   $this->form['customer_email'],
   array(
       'required' => true,
       'regExp'   => '[EMAIL PROTECTED],}[\.][a-z]{2,3}$',
       'invalidMessage' => $this->translate->_("customer_email_invalidMessage"),
       'class' => 'admin_customer_option_email',
   ),
   array(
       'maxlength' => 50,
   )
);
?></td></tr>
                
<tr><td><?=$this->translate->_("customer_telephone");?></td><td><?php
echo $this->validationTextBox(
   'customer_phone',
   $this->form['customer_phone'],
   array(
       'required' => true,
       'regExp'   => '[0-9\+]+',
       'invalidMessage' => $this->translate->_("customer_phone_invalidMessage"),
       'class' => 'admin_customer_option_phone',
   ),
   array(
       'maxlength' => 20,
   )
);
?></td></tr>

        </table>
</div>

<div id="customer_account" style="display:none;height:600px;">
<table width="100%">


                
<tr><td><?=$this->translate->_("customer_bankaccount_store");?></td><td><?php
echo $this->validationTextBox(
   'customer_bankaccount_store',
   $this->form['customer_bankaccount_store'],
   array(
       'required' => true,
       'regExp'   => '[a-zA-Z\s]+',
       'invalidMessage' => 
$this->translate->_("customer_bankaccount_store_invalidMessage"),
       'class' => 'admin_customer_bankaccount_store',
   ),
   array(
       'maxlength' => 50,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_bankaccount_bank");?></td><td><?php
echo $this->validationTextBox(
   'customer_bankaccount_bank',
   $this->form['customer_bankaccount_bank'],
   array(
       'required' => true,
       'regExp'   => '[0-9\s]+',
       'invalidMessage' => 
$this->translate->_("customer_bankaccount_bank_invalidMessage"),
       'class' => 'admin_customer_bankaccount_bank',
   ),
   array(
       'maxlength' => 20,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_bankaccount_teller");?></td><td><?php
echo $this->validationTextBox(
   'customer_bankaccount_teller',
   $this->form['customer_bankaccount_teller'],
   array(
       'required' => true,
       'regExp'   => '[0-9\s]+',
       'invalidMessage' => 
$this->translate->_("customer_bankaccount_teller_invalidMessage"),
       'class' => 'admin_customer_bankaccount_teller',
   ),
   array(
       'maxlength' => 20,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_bankaccount_account");?></td><td><?php
echo $this->validationTextBox(
   'customer_bankaccount_account',
   $this->form['customer_bankaccount_account'],
   array(
       'required' => true,
       'regExp'   => '[0-9\s]+',
       'invalidMessage' => 
$this->translate->_("customer_bankaccount_account_invalidMessage"),
       'class' => 'admin_customer_bankaccount_account',
   ),
   array(
       'maxlength' => 20,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_bankaccount_key");?></td><td><?php
echo $this->validationTextBox(
   'customer_bankaccount_key',
   $this->form['customer_bankaccount_key'],
   array(
       'required' => true,
       'regExp'   => '[0-9\s]+',
       'invalidMessage' => 
$this->translate->_("customer_bankaccount_key_invalidMessage"),
       'class' => 'admin_customer_bankaccount_key',
   ),
   array(
       'maxlength' => 10,
   )
);
?>              </td></tr>

                <tr><td colspan="2"><hr width="250" align="left"></td></tr>

                
<tr><td><?=$this->translate->_("customer_creditcard_valid");?></td><td><?php
echo $this->radioButton(
    'customer_creditcard_valid',
    $this->form['customer_creditcard_valid'],
    array(),
    array(),
    array(
        '1' => $this->translate->_("customer_creditcard_valid_yes"),
        '0' => $this->translate->_("customer_creditcard_valid_no"),
    )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_creditcard_number");?></td><td><?php
echo $this->validationTextBox(
   'customer_creditcard_number',
   $this->form['customer_creditcard_number'],
   array(
       'required' => true,
       'regExp'   => '[0-9]+',
       'invalidMessage' => 
$this->translate->_("customer_creditcard_number_invalidMessage"),
       'class' => 'admin_customer_creditcard_number',
   ),
   array(
       'maxlength' => 20,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_creditcard_validitydate");?></td><td><?php
    echo $this->dateTextBox(
    'customer_creditcard_validitydate',
   $this->form['customer_creditcard_validitydate'],
    array('required' => false,
    'class' => 'admin_customer_creditcard_validitydate',
    )
    );
?>              </td></tr>

                <tr><td colspan="2"><hr width="250" align="left"></td></tr>

                
<tr><td><?=$this->translate->_("customer_credit");?></td><td><?php
echo $this->currencyTextBox(
   'customer_credit',
   $this->form['customer_credit'],
   array(
        'label'          => 'Currency:',
        'currency'       => 'USD',   /* http://en.wikipedia.org/wiki/ISO_4217 */
        'fractional'     => false,
       'required' => true,
       'invalidMessage' => 
$this->translate->_("customer_credit_invalidMessage"),
       'class' => 'admin_customer_credit',
   ),
   array(
       'maxlength' => 20,
   )
);
?>              </td></tr>
                
<tr><td><?=$this->translate->_("customer_credit_date");?></td><td><?php
    echo $this->dateTextBox(
    'customer_credit_date',
   $this->form['customer_credit_date'],
    array('required' => false,
    'class' => 'admin_customer_credit_date',
    )
    );
?>              </td></tr>

</table>
</div>

<div id="customer_option" style="display:none;height:600px;">
<table width="100%">

                
<tr><td><?=$this->translate->_("customer_sponsor_number");?></td><td><?php
echo $this->validationTextBox(
   'customer_sponsor_number',
   $this->form['customer_sponsor_number'],
   array(
       'required' => true,
       'regExp'   => '[a-zA-Z0-9\s]+',
       'invalidMessage' => 
$this->translate->_("customer_sponsor_number_invalidMessage"),
       'class' => 'admin_customer_sponsor_number',
   ),
   array(
       'maxlength' => 20,
   )
);
?>              </td></tr>

                
<tr><td><?=$this->translate->_("customer_profession");?></td><td><?php
echo $this->comboBox(
    'customer_profession',
    'other',
    array(
        'autocomplete' => false,
    ),
    array(),
    array(
            'housewife' => $this->translate->_("customer_profession_housewife"),
            'without_employment' => 
$this->translate->_("customer_profession_without_employment"),
            'student' => $this->translate->_("customer_profession_student"),
            'employee' => $this->translate->_("customer_profession_employee"),
            'studentmanager' => 
$this->translate->_("customer_profession_manager"),
            'entrepreneur' => 
$this->translate->_("customer_profession_entrepreneur"),
            'artisan' => $this->translate->_("customer_profession_artisan"),
            'retired' => $this->translate->_("customer_profession_retired"),
            'other' => $this->translate->_("customer_profession_other"),
            )
);
?>              </td></tr>

                
<tr><td><?=$this->translate->_("customer_origin");?></td><td><?php
echo $this->comboBox(
    'customer_origin',
    'other',
    array(
        'autocomplete' => false,
    ),
    array(),
    array(
        'walk_in' => $this->translate->_("customer_origin_walk_in"),
        'billboard' => $this->translate->_("customer_origin_billboard"),
        'internet' => $this->translate->_("customer_origin_internet"),
        'word_of_mouth' => $this->translate->_("customer_origin_word_of_mouth"),
        'letter_box' => $this->translate->_("customer_origin_letter_box"),
        'hand_to_hand' => $this->translate->_("customer_origin_hand_to_hand"),
        'free_newspaper' => 
$this->translate->_("customer_origin_free_newspaper"),
        'newsletter' => $this->translate->_("customer_origin_newsletter"),
        'yellow_pages' => $this->translate->_("customer_origin_yellow_pages"),
        'press' => $this->translate->_("customer_origin_press"),
        'radio' => $this->translate->_("customer_origin_radio"),
        'text_messaging' => 
$this->translate->_("customer_origin_text_messaging"),
    )
);
?>              </td></tr>

                <tr><td><?=$this->translate->_("customer_skin");?></td><td><?php
echo $this->radioButton(
    'customer_skin',
    $this->form['customer_skin'],
    array(),
    array(),
    array(
        'easy' => $this->translate->_("customer_skin_easy"),
        'medium' => $this->translate->_("customer_skin_medium"),
        'hard' => $this->translate->_("customer_skin_hard"),
    )
);
?>              </td></tr>

                <tr><td colspan="2"><hr width="250" align="left"></td></tr>

                
<tr><td><?=$this->translate->_("customer_news_sms");?></td><td><?php
echo $this->radioButton(
    'customer_news_sms',
    $this->form['customer_news_sms'],
    array(),
    array(),
    array(
        '1' => $this->translate->_("customer_news_sms_yes"),
        '0' => $this->translate->_("customer_news_sms_no"),
    )
);
?>              </td></tr>

                
<tr><td><?=$this->translate->_("customer_news_email");?></td><td><?php
echo $this->radioButton(
    'customer_news_email',
    $this->form['customer_news_email'],
    array(),
    array(),
    array(
        '1' => $this->translate->_("customer_news_email_yes"),
        '0' => $this->translate->_("customer_news_email_no"),
    )
);
?>              </td></tr>

                
<tr><td><?=$this->translate->_("customer_news_mail");?></td><td><?php
echo $this->radioButton(
    'customer_news_mail',
    $this->form['customer_news_mail'],
    array(),
    array(),
    array(
        '1' => $this->translate->_("customer_news_mail_yes"),
        '0' => $this->translate->_("customer_news_mail_no"),
    )
);
?>              </td></tr>

</table>
</div>

<div id="customer_note" style="display:none;height:600px;">
<table width="100%">
                <tr><td 
width="100"><?=$this->translate->_("customer_note");?></td><td><textarea 
name="customer_note" class="admin_customer_note_note"><?php echo 
stripslashes($this->form['customer_note']); ?></textarea></td></tr>
</table>
</div>

<hr>

        <center>
<?php
if ($this->id == 'new' ) {
    ?>
<input type="button" class="buttongreen" 
value="<?=$this->translate->_("customer_add");?>" onclick="submit()" 
style="cursor:pointer;">
<? } else { ?>
<input type="button" class="buttonred" 
value="<?=$this->translate->_("customer_del");?>" 
onclick="location.href='<?=URL?>admin/customerdel/id/<?=$this->id?>'" 
style="cursor:pointer;">
<input type="button" class="buttongreen" 
value="<?=$this->translate->_("customer_save");?>" 
onclick="document.customer.action='<?=URL?>admin/customersave/id/<?=$this->id?>';submit();"
 style="cursor:pointer;">
<? } ?>
</form>
        </center>

Reply via email to