Ajax Bug?

Login or register to post comments
6 replies [Last post]
Offline
Joined: 03/03/2010

Hi,

I've been starting my development from the generated panel files in the drafts->panel folder, the "Dashboard".

I have two problems:

1)
I've been monitoring that the ajax responses do not only send back the controls which have changed, but also controls that didn't change at all (I made a diff on some ajax responses).

The return structure is follows the known pattern:
response>
controls>
control id="c169">
...

You can observe this behaviour for example when browsing the Ajax Dashboard of the "Project" example. When clicking on the edit or new button, not only the QPanel pnlEdit, but also the whole table pnlList ist send in the ajax response. the pnlList didn't change at all.

What needs to be changed configured that the framework only sends changed controls?

2)
I have a QControlProxy performing a QServerControlAction with an onClickEvent.

The triggered pxyControl_Click($strFormId, $strControlId, $strParameter) function then returns a vcard file following way:

<?php
public function pxyControl_Click($strFormId, $strControlId, $strParameter){
...
       
$output = $v->getVCard();
       
$filename = $v->getFileName();

       
Header("Content-Disposition: attachment; filename=$filename");
       
Header("Content-Length: ".strlen($output));
       
Header("Connection: close");
       
Header("Content-Type: text/x-vCard; name=$filename");

        echo
$output;
}
?>

As result, I get the VCard file, but it doesn't only contain the $output vcard string, but also

...
END:VCARD
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
head>
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    title>Business Warehouse</title>
           
    link rel="stylesheet" type="text/css" href="/dev/assets/_core/css/styles.css"/>
...

html code of my main page. Why does QCubed returns that html part?

Lot of questions and I've been trying to investigate for hours without success. Therefore I hope for some help here :-)

Thanks,
Nick

alex94040's picture
Offline
Joined: 11/06/2008

On #1: one way to reduce the amount of stuff that's sent back to the server on each postback is to use a QFileFormStateHandler (more info on form state handlers: http://examples.qcu.be/assets/_core/php/examples/other/form_state.php).

On #2: put an exit() statement right after your "echo $output" statement.

Offline
Joined: 03/31/2008

2) Simply because that's what it does every time that page is hit. You are still calling Form_Run from the main php file, so it still goes through everything.
If you want to end the responce after outputting your vcard, just call exit().

Offline
Joined: 03/03/2010

2)
Yes, that worked out great. I should have considered that easy and straight forward solution earlier ;-)

1)
I've been looking into this. When switching to the QFileFormStateHandler or QSessionFormStateHandler state handler, it reduces the amount of data send by an ajax request by the base64 encoded form state string. But however the server will send control data back of controls which haven't been changed at all and not even touched by the command.

Best Example:
You can observe this behaviour for example when browsing the Ajax Dashboard of the "Project" example. When clicking on the edit or new button, not only the QPanel pnlEdit, but also the whole table pnlList ist send in the ajax response. the pnlList didn't change at all.

I'm not sure how to solve this with the state handler classes (other as by comparing the new to the old form state and filtering out same control states, somehow. But better approach probably would be to not trigger an control update sendback of those controls at all).

Nick

alex94040's picture
Offline
Joined: 11/06/2008

On #1: no idea why this is happening. Others might know.

Offline
Joined: 01/09/2008

Not verified through code or looking at the dashboard sample, but I think that if a datasource is reloaded on the dategrid, the datagrid is marked as modified and will be sent to the browser when the page is reloaded.

cdhamm's picture
Offline
Joined: 05/09/2008

A control will returned in the ajax response only if it has been modified, or explicitly flagged to be re-rendered. I would look closely for the use of any list panel setters, as well calls to Refresh(), MarkAsModified(), or anything else that could be flagging the list panel to be updated. If that doesn't work, you could log debug messages inside the QControlBase and QFormBase functions which determine whether a control should be rendered.