<?php

class frmWebServices extends MForm
{
    private $MIOLO;
    
    public function __construct()
    {
        $this->MIOLO = MIOLO::getInstance();
        
        parent::__construct(_M('WebServices demo', $this->module));
        
        $this->eventHandler();
    }
    
    public function createFields()
    {    
        $postalCode = new MTextField('postalCode', $this->postalCode->value, 'Postal Code', 20,'Valid codes are: 95880-000, 95885-000 and 95900-000');
        $postalCode->setJsHint( _M('Please, inform a postal code', $this->module));
        $fields[] = $postalCode;
    
        $fields[] = new MDiv('resultDiv', '');
        
        $buttons = array( new MButton('btnGet', 'Get city Name', ':getWebService') );

        $this->setShowPostButton(false);
        $this->setButtons($buttons);
        
        $this->setFields($fields);       
        $this->setValidators($validators);        
    }
    
    public function getWebService($sender=NULL)
    {
        // wsClientDemo is located in directory webservices
        $ws = $this->MIOLO->getWebServices('example', 'wsClientDemo');
        // this method must exist in the above file  
        $rs = $ws->getCityName(MIOLO::_REQUEST('postalCode'));
        
        $this->setResponse('Server result: '.$rs, 'resultDiv');
    }

}

?>