[TYPO3-project-formidable] majix: <datahandler:LISTER> = error

Jerome Schneider j.schneider at ameos.com
Mon May 28 17:43:51 CEST 2007


Hello,

I understand now.

You should use a server event instead of a client event, like this:

<onclick runat="server" params="uid">
   <userobj>
     <php><![CDATA[

       $aParams = func_get_arg(1);
       $this->_oParent->oMyForm->iForcedEntryId = $aParams["uid"];

            // _oParent points to your plugin
                       // oMyForm has to point to your formidable object
                       // in your plugin

     ]]></php>
   </userobj>
</onclick>




And for the events explaination:
--------------------------------

CLIENT EVENTS:
--------------

   -> are used when no page refresh nor PHP processing is required to do 
what has to be done ( typically hiding divs in page, but could be a lot 
other things )

   -> are generated as static javascript when the whole HTML is generated

   -> cannot be conditional ( meaning you cannot provide if-conditions 
on wheter to execute task A or task B inside the event when fired )

AJAX EVENTS:
------------

-> don't require formidable to refresh the whole page ( meaning a true 
page refresh )
-> are used when :

     1) the things to execute are to complicated to be processed by 
client event only

     OR / AND

     2) you want to execute PHP when event is fired ( like: changing the 
status of something in the database, sending a mail, all you can do with 
PHP actually )

     OR / AND

     3) you may have different tasks executed depending on whatever you 
want ( data in the page, hour of the day, random, you name it ) ; for 
this you can ask the event to fetch data on page, before asking the PHP 
server what to do thru an ajax request, if needed ( params="uid, title, 
..." )





SERVER EVENTS:
--------------
-> are used when the whole page has to be refreshed to process the event
-> typically used to motorize edit buttons, as edition *requires* (for 
now) a page refresh





Let's now have a closer look at what happens when each one of these 
three kinds of event is fired ; imagine a button with an onclick event


CLIENT EVENT: ----------------------------------------------------
You provide a php-userobj to tell Formidable what to do when button 
clicked. This PHP is executed when page is generated, returning an array 
of majix tasks to execute, and resulting JS is statically embeded in the 
page.

Logical scheme:

1 - Formidable reads XML configuration for the button
2 - F. generates the whole collection of majix things to execute as a 
static string of javascript
3 - When clicked, the static JS is executed


SERVER EVENT: ----------------------------------------------------
You provide a php-userobj to tell Formidable what to do when button 
clicked. The PHP is not executed when page is generated. Formidable will 
rather notice that a server event is declared, and will automatically 
attach a tiny piece of JS code (that is, the server-event header) on the 
onclick event for the button. When  the button is clicked, this JS is 
executed, placing data in the POST telling formidable that the 
onclick-event of the button has been fired, and then making the page 
refresh. When PHP receives the POST of the just submitted page, it 
notices that this server event has been thrown, and will then execute 
the attached PHP do what you wanted it to do on button click.

Logical scheme:

1 - Formidable reads XML configuration for the button
2 - F. generates a server-event header ( tiny piece of JS ) and places 
it on our button's onclick event
3 - When clicked, parameters are fetched (if any declared), page 
refreshes and F. executes the PHP code attached to the event fired 
(determined by the sent server-event header)

AJAX EVENT: -------------------------------------------------------
You provide a php-userobj to tell Formidable what to do when button 
clicked. It's a mix of client-event and server event, as it requires no 
page refresh to be processed (like the client event) and still requires 
PHP dynamic execution to process things (like server-event).
Like for the server event, when page is generated, the userobj is not 
executed, but formidable rather notices that an ajax event has been 
declared on the button. And so formidable generates an ajax-event header 
( small piece of javascript ) asking formidable to execute an ajax 
request to the server when the event is fired. When button is clicked, 
ajax request is sent, userobj is executed, and an array of majix tasks 
to execute in the browser are sent back ; kinda like the browser asks 
"This guy clicked the button, what should I do now ?" and the server 
responds "You have to change the value of this, hide this, display this, 
  etc"


Logical scheme:

1 - Formidable reads XML configuration for the button
2 - F. generates an ajax-event header and attach it to the onclick event
3 - When clicked, parameters are fetched (if any declared), and an ajax 
request is sent to the server ( page don't refreshes )
4 - Your PHP-userobj receives the ajax request, inspects the parameters 
(if any) and executes what has to be executed.
5 - If returned by the userobj, the array of majix tasks to execute by 
the browser are sent back thru the ajax request




a lot of things there, but it's quite useful to know it :)


Best regards,
Jerome Schneider


Asbjørn Morell a écrit :
> Hello,
> 
> Okay. Here is some more information. I copied most of the xml from your 
> example with no changes. What I am trying to do is loading the art 
> record with uid 16 when edit is pressed.
> Object not found is with IE7. I tried loading the page with firefox 2 
> and the error log gives me this error: (clicking on edit) Could you 
> provide a few hint on how to create a list with edit for each record. 
> Would be very helpful until version 0.8 is released.
> 
> Best regards.
> Asbjørn Morell.
> 
> 
> 
> Error: syntax error
> Source: 
> http://domain.dk/typo3conf/ext/ameos_formidable/res/jsfwk/framework.js
> Line: 85, Kolonne: 1
> Source code:
> 0,
> 
> Line 85 is the line with eval(unescape(sJs));
> 
> framework.js
> executeInlineJs: function(oJson) {
>  console.log("executeInlineJs", oJson);
>  $H(oJson).each(function(sJs) {
>   eval(unescape(sJs));
>  }.bind(this));
> },
> 
> 
> 
> main function:
>            $this->aORenderlets = 
> t3lib_div::makeInstance("tx_ameosformidable");
>            $this->aORenderlets->init(&$this,
>                t3lib_extmgm::extPath($this->extKey) . 
> "pi1/xml/art/list.xml"
>                );
>            $content .= $this->aORenderlets->render();
> 
>            return $this->pi_wrapInBaseClass($content);
> 
> list.xml:
> <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
> <formidable version="0.7.1" 
> xmlns:datahandler="http://www.ameos.com/formidable/071/datahandler" 
> xmlns:renderer="http://www.ameos.com/formidable/071/renderer" 
> xmlns:renderlet="http://www.ameos.com/formidable/071/renderlet" 
> xmlns:validator="http://www.ameos.com/formidable/071/validator" 
> xmlns:actionlet="http://www.ameos.com/formidable/071/actionlet">
> 
> <meta>
>  <name>Art</name>
>  <form formid="my_artform_list" />
>  <displaylabels>false</displaylabels>
>  <debug>false</debug>
> </meta>
> 
> <control>
> 
>  <datahandler:LISTER
> 
>   <tablename>tx_myart_art</tablename>
>   <keyname>uid</keyname>
>   <labelname>title</labelname>
> 
> 
>  </datahandler:LISTER
> 
> 
> <renderer:STANDARD>
> <style>
> <![CDATA[
> 
>    #box_step1, #box_step2, #box_step3, #box_step4, #box_step5,
>    #step1_gotostep2, #step2_gotostep3, #step3_gotostep4, #step4_gotostep5,
>    #step3_btnchange, #step4_boxexplain, #step4_btntimenocache { display: 
> none;}
> 
>    #box_step1, #box_step2, #box_step3, #box_step4, #box_step5 {
>     background-color: #ff8c00;
>     color: white;
>     padding: 5px;
>    }
> 
>    #step2_replacedata {
>     text-decoration: underline;
>    }
> 
>    h3 {
>     margin: 0;
>     margin-left: -5px;
>     margin-right: -5px;
>     margin-top: 5px;
>     padding-left: 5px;
> 
>     color: white;
>     background-color: #FF6D06;
>     border-top: 2px solid #CB5702;
>     border-bottom: 2px solid #CB5702;
> 
>     padding-top: 10px;
>     padding-bottom: 10px;
>    }
> 
> 
> 
>  ]]>
>  </style>
>  </renderer:STANDARD>
> 
> 
> </control>
> 
> <elements>
> 
> 
>  <renderlet:TEXT name="title" label="title *">
>   <validators>
>    <validator:STANDARD>
>     <required message="title is required!" />
>    </validator:STANDARD>
>   </validators>
>  </renderlet:TEXT>
> 
>  <renderlet:TEXTAREA name="text" label="text *">
>   <validators>
>    <validator:STANDARD>
>     <required message="text is required!" />
>    </validator:STANDARD>
>   </validators>
>  </renderlet:TEXTAREA>
> 
>  <renderlet:CHECKBOX name="category" label="category">
>   <data>
>    <items>
>     <item caption="Red" value="red" />
>     <item caption="Green" value="green" />
>     <item caption="Blue" value="blue" />
>    </items>
>   </data>
>  </renderlet:CHECKBOX>
> 
>  <renderlet:TEXT name="price" label="price *"></renderlet:TEXT>
> 
> 
> 
> 
>  <renderlet:BUTTON name="btn_step1" label="edit">
>   <onclick runat="client">
>    <userobj>
>     <php><![CDATA[
> 
> 
> 
> 
>      //$aParams = func_get_arg(1);
> 
>      //dump($aParams);
> 
> 
>      $this->_oParent->aORenderlets->iForcedEntryId = 16;
> 
> 
>  /*    return array(
>       $this->aORenderlets["box_step4"]->majixDisplayBlock(),
>      ); */
> 
>     ]]></php>
>    </userobj>
>   </onclick>
>  </renderlet:BUTTON>
> 
>  <renderlet:BOX name="box_step4">
>   <childs>
>    <renderlet:BOX>
>     <html><![CDATA[
> 
>      <h3>Another nice aspect of majix is that it can also handle <b>ajax 
> events</b></h3>
>      <p>Click the button below ...</p>
> 
>     ]]></html>
>    </renderlet:BOX>
> 
>    <renderlet:BUTTON label="Gimme ajax !!" >
>     <onclick runat="ajax">
>      <userobj>
>       <php><![CDATA[
> 
>        return array(
>         $this->aORenderlets["step4_boxchange"]->majixReplaceData(
>          "<b>The PHP server says: when you clicked this button it was 
> exactly " . strftime("%H:%M:%S") . " at my watch</b>"
>         ),
>         $this->aORenderlets["step4_boxexplain"]->majixDisplayBlock(),
>         $this->aORenderlets["step4_btntimenocache"]->majixDisplayBlock(),
>         $this->majixScrollTo("step4_btntimenocache")
>        );
> 
>       ]]></php>
>      </userobj>
>     </onclick>
>    </renderlet:BUTTON>
> 
>    <renderlet:BOX name="step4_boxchange" />
> 
>    <renderlet:BOX name="step4_boxexplain">
>     <html><![CDATA[
> 
>      <p>This event has been processed by the PHP server on-demand ( 
> using json over ajax RPC ).</p>
>      <p>The default config for ajax events is to cache results return by 
> server, so that when the same event is fired again, no ajax request is 
> needed to execute the majix tasks.</p>
>      <p>Click the same button again: nothing happens, the time don't 
> change</p>
>      <p>Then click the following button for fresh data at each click.</p>
> 
>     ]]></html>
>    </renderlet:BOX>
> 
>    <renderlet:BUTTON name="step4_btntimenocache" label="Gimme ajax !! 
> without caching">
>     <onclick runat="ajax" cache="false">
>      <userobj>
>       <php><![CDATA[
> 
>        return array(
>         $this->aORenderlets["step4_boxchange"]->majixReplaceData(
>          "<b>The PHP server says: when you clicked this button it was 
> exactly <span style='color: purple;'>" . strftime("%H:%M:%S") . "</span> 
> at my watch</b>"
>         ),
>         $this->aORenderlets["step4_gotostep5"]->majixDisplayBlock()
>        );
> 
>       ]]></php>
>      </userobj>
>     </onclick>
>    </renderlet:BUTTON>
> 
>    <renderlet:BUTTON name="step4_gotostep5" label="Continue with step 5">
>     <onclick runat="client">
>      <userobj>
>       <php><![CDATA[
> 
>        return array(
>         $this->aORenderlets["box_step5"]->majixDisplayBlock(),
>         $this->aORenderlets["step4_gotostep5"]->majixDisplayNone(),
>         $this->majixScrollTo("box_step5"),
>        );
> 
>       ]]></php>
>      </userobj>
>     </onclick>
>    </renderlet:BUTTON>
>   </childs>
>  </renderlet:BOX>
> 
>  <renderlet:BOX name="box_step5">
>   <childs>
>    <renderlet:BOX>
>     <html><![CDATA[
> 
>      <h3>Ajax events in formidable ...</h3>
>      <p>... are used when something has to be processed by php before 
> knowing what to execute on browser.</p>
>      <p>For instance: (<i>note that result is cached for already 
> requested operations !</i>)</p>
>     ]]></html>
>    </renderlet:BOX>
> 
>    <renderlet:TEXT name="step5_txtmd5" label="Enter some text" />
> 
>    <renderlet:LISTBOX name="step5_whattodo">
>     <data>
>      <items>
>       <item caption="Calculate md5" value="md5" />
>       <item caption="Transform to upper case" value="uppercase" />
>       <item caption="Calculate soundex" value="soundex" />
>      </items>
>     </data>
>    </renderlet:LISTBOX>
> 
>    <renderlet:BUTTON label="Do it !!">
>     <onclick runat="ajax" require="modalbox" params="step5_txtmd5, 
> step5_whattodo">
>      <userobj>
>       <php><![CDATA[
> 
>        $aParams = func_get_arg(1);
>        $sRes = "";
> 
>        switch($aParams["step5_whattodo"]) {
>         case "md5": {
> 
>          $sRes = md5($aParams["step5_txtmd5"]);
>          break;
>         }
>         case "uppercase": {
>          $sRes = strtoupper($aParams["step5_txtmd5"]);
>          break;
>         }
>         case "soundex": {
>          $sRes = soundex($aParams["step5_txtmd5"]);
>          break;
>         }
>        }
> 
>        return array(
>         $this->aORenderlets["step5_modalbox"]->majixShowBox(),
>         $this->aORenderlets["step5_mbox_res"]->majixReplaceData($sRes),
>        );
> 
>       ]]></php>
>      </userobj>
>     </onclick>
>    </renderlet:BUTTON>
> 
>    <renderlet:MODALBOX name="step5_modalbox">
>     <childs>
>      <renderlet:BOX html="The result is ..." mode="h1" />
>      <renderlet:BOX name="step5_mbox_res" mode="b" />
>      <renderlet:BUTTON name="step5_mbox_close" label="Close">
>       <wrap><![CDATA[<div>|</div>]]></wrap>
>       <onclick runat="client">
>        <userobj>
>         <php><![CDATA[
> 
>          return $this->aORenderlets["step5_modalbox"]->majixCloseBox();
> 
>         ]]></php>
>        </userobj>
>       </onclick>
>      </renderlet:BUTTON>
>     </childs>
>    </renderlet:MODALBOX>
> 
>   </childs>
>  </renderlet:BOX>
> 
> 
> 
> </elements>
> 
> </formidable>
> 
> 
> ----- Original Message ----- From: "Jerome Schneider" 
> <j.schneider at ameos.com>
> Newsgroups: typo3.projects.formidable
> Sent: Monday, May 28, 2007 11:10 AM
> Subject: Re: [TYPO3-project-formidable] majix: <datahandler:LISTER> = error
> 
> 
>> Hello !
>>
>> Couldyou provide the xml that reproduces the bug ? And are you using 
>> ie6 or ie7 ?
>>
>> Best regards,
>> Jerome
>>


More information about the TYPO3-project-formidable mailing list