[Cartoweb-users] Send data from client to server part in a Plugin

Damien Corpataux damien.corpataux at camptocamp.com
Wed Jul 19 04:25:06 EDT 2006


Hi Yves,

there might be a problem in your ExportFile.php: the unserialize(). The 
filepath prop of your ExportFileRequest is a string. So, its 
unserialize() method should contain this:

$this->filepath = self::unserializeValue($struct, 'filepath', 'string');

or

$this->filepath = self::unserializeValue($struct, 'filepath');

as the third argument default value is 'string'.


Did you try to

var_dump($requ->filepath);

in ServerExportFile::initializeRequest($requ) ?


Damien




Jacolin Yves wrote:
> Hi,
>
> I can not manage this. I don't understand how it works and so I can not find 
> the error. I follow this url :
> http://www.cartoweb.org/cwiki/HowToDisplayOnTheMapAPointFromADatabaseQuery
>
> So, here the content of my ClientExportFile.php :
> <?php
> class ClientExportFile extends ClientPlugin implements ServerCaller {
>     /**
>     * Constructor
>     */
>     public function __construct() {
>         $this->log =& LoggerManager::getLogger(__CLASS__);
>         parent::__construct();
>         $this->Message = "";
>    }
>
>    public function handleHttpPostRequest($request) {
>         if($request['create_validate_all'] == 3) {
>           $this->exportOn = 1;
>         }
>     }
>
>    public function buildRequest() {
>       if($this->exportOn==1){
>          $mydata= new ExportFile();
>          
> $mydata->filepath="/var/www/html/cartoweb3/htdocs/generated/zip/tssitespt.zip";
>          return $mydata;
>       }
>    }
>
>     /**
>      * @see ServerCaller::initializeResult()
>      */ 
>     public function initializeResult($ExportFileResult) {}
>
>
>     /**
>      * @see ServerCaller::handleResult()
>      */ 
>     public function handleResult($ExportFileResult) {}
>
> }
> ?>
> /********************************************End*****************************
> Here the content of the ExportFile.php in common directory :
>
> <?php
> require_once(CARTOWEB_HOME . 'common/CwSerializable.php');
>
> class ExportFileRequest extends CwSerializable {
>
>       /** 
>        * filepath of the zip
>        * @var string
>        */
>       public $filepath;
>
>       /**
>       * @see CwSerializable::unserialize()
>       */
>       public function unserialize($struct) {
>         $this->filepath = self::unserializeValue($struct, 'filepath', 
> 'ExportFile');
>       }
>
>     /**
>      * Result
>      * @package Plugins
>      */
>     class ExportFileResult {}
>
> }
> ?>
> /********************************
> And the exportFile.wsdl.inc file in common directory :
>      <!-- exportFile -->
>       <complexType name="ExportFile">
>          <all>
>            <element name="filepath" type="xsd:string"/>
>          </all>
>       </complexType>
>
> /********************************
> Finally, the ServerExportFile.php file in server dir :
> <?php
> class ServerExportFile extends ClientResponderAdapter {
>
>    function initializeRequest($requ) {
>       if ($requ)
>             $this->filepath = $requ->filepath;
>    }
> ?>
> /*******************************
>
> At this moment, I just want to get $filepath from the form in cartoclient, in 
> the client side and send it to server side.
> I just obtain a not so nice white screen :-( I have no errors in 
> httpd/error_log nor in cartoclient.log
>
> any ideas where the errors are ? Or how to have more informations in the 
> cartoclient.log ?
>
> Thank you !
>
> Y.
> Le Mardi 18 Juillet 2006 16:44, Damien Corpataux a écrit :
>   
>> Hi,
>>
>> yes indeed, this looks correct.
>>
>> BUT: the $mydata variable returned by ServerPlugin::initializeRequest() HAS
>> TO be an object that implements the CwSerializable interface. Take a look
>> at /coreplugins/images/common/Images.php if you need an example.
>>
>> Also, don't forget to make your ClientPlugin implement the ServerCaller
>> interface, and make your ServerPlugin implement ClientResponder.
>>
>> Damien
>>
>>
>> ----- Original Message -----
>> From: "Jacolin Yves" <yjacolin at free.fr>
>> To: "Oliver Christen" <oliver.christen at camptocamp.com>
>> Sent: Tuesday, July 18, 2006 4:03 PM
>> Subject: Re: [Cartoweb-users] Send data from client to server part in a
>> Plugin
>>
>>
>> with the mail of Marc Monnerat and yours, I am begining to understand.
>> So in the clientMyPlugin class, I use :
>> public function buildRequest() {
>>  return $mydata;
>> }
>>
>> and in the serverMyPlugin class, I use :
>> function initializeRequest($requ) {
>>   if ($requ)
>>           $this->mydatat = $requ->mydata;
>> }
>>
>> Can you confirm ?
>>
>> Thank to you and marc Monnerat
>>
>> Y.
>>
>> Le Mardi 18 Juillet 2006 15:44, vous avez écrit :
>>     
>>> there is the public function handleHttpPostRequest($request) { (client
>>> side) if you need the data on server side, you will need to transfert
>>> them from client to server side via public function buildRequest() { and
>>> recover
>>> the result of your sever-side functions (if any) with public function
>>> initializeResult($someresultobject) { or public function
>>> handleResult($someresultobject) {
>>>
>>> maybe there is a simpler way, I will ask around
>>>
>>> O.
>>>
>>>       
>>>> Hello,
>>>> I want to use data from a form in my interface in the server part of my
>>>> plugin. Do I need to use ServerCaller::overrideRequest and
>>>> ClientResponder::initializeRequest ?
>>>>
>>>> I can not get informations about this, from the archive, and I am sure
>>>> to
>>>> read
>>>> something about this in the past.
>>>>
>>>> Thanks,
>>>>
>>>> Y.
>>>> --
>>>> Yves Jacolin
>>>> http://yjacolin.gloobe.org
>>>> ----
>>>> Stagaire Conservatoire Régional des Espaces Naturels de la région
>>>> Centre http://cahiersnaturalistes.free.fr/cpnrc/
>>>> ----
>>>> - Qu'est-ce que cela peut faire que je lutte pour la mauvaise cause
>>>> puisque je suis de bonne foi?
>>>> - Et qu'est-ce que ça peut faire que je sois de mauvaise foi
>>>> puisque c'est pour la bonne cause. (Jacques Prévert)
>>>>
>>>> _______________________________________________
>>>> Cartoweb-users mailing list
>>>> Cartoweb-users at lists.maptools.org
>>>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>>>         
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20060719/e14cc5c7/attachment.html


More information about the Cartoweb-users mailing list