When I add a simple relationship, "New Record" form is blank

A place for users and developers of the Xataface to discuss and receive support.

When I add a simple relationship, "New Record" form is blank

Postby semicon_guy » Wed Oct 13, 2010 5:13 pm

Hi - I am a new Xataface user working through the tutorial, but with my own database. I am trying to build a relationship, but it isn't working. I have two tables: tblProduct and tblAttachment. See below for table fields.

In my relationships.ini for tblProduct, I have the following code:
Code: Select all
[tblAttachmentRelationship]
tblAttachment.ProductID = "$ID"


When I go into tblProduct and select "New Record" the Xataface screen loads but the HTML stops loading shortly after functionHandleLoadNode(){...}
the HTML file ends with the javascript "document.recordIndex['tblProduct?ID=4'] = "

Any suggestions would be greatly appreciated! Thanks!

Code: Select all
tblProduct
Field    Type    Null    Default    Comments    MIME
ID    int(11)    No               (PRIMARY KEY)
ProductType    varchar(255)    Yes     NULL          
ProcessNode    int(11)    Yes     NULL

tblAttachment
Field    Type    Null    Default    Comments    MIME
ID    int(11)    No                (PRIMARY KEY)
ProductID    int(11)    No               
AttachmentTypeID    int(11)    Yes     NULL          
Version    double    Yes     0          
Description    varchar(255)    Yes     NULL          
Attachment    longblob    Yes     NULL
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby semicon_guy » Wed Oct 13, 2010 5:15 pm

By the way, this is Xataface 1.2.5. If it isn't a bug in my code, I am wondering if MySql is limiting the number of queries? I have been able to use SQL commands successfully in valuelists.ini.
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby semicon_guy » Wed Oct 13, 2010 5:54 pm

Just to see if my database was the problem, I created the "Course" and "Program" tables as per the tutorial. For the Program database, I created the relationships.ini. When I try to create a new Program, my HTML file looks like this (starting near the bottom):

Code: Select all
   /**
    * Function called by HTTPRequest object to handle the response to the AJAX call to get the node
    * data.  This will load the node with the retrieved data from the ajax_nav_tree_node action
    * in JSON format, and format the contents in HTML.
    */
   function handleLoadNode(){
      if ( document.http.readyState == 4 ){
         //alert(document.http.responseText);
         var data = eval('('+document.http.responseText+')');
         //var ul = document.getElementById('navtree-'+document.http_vars.basepath+'/'+id);
         var ul = document.http_vars.ul;
         var out = '';
         for (var id in data){
            out += '<li><img '+((data[id]['__expandable__']==0)?' style="display:none" ':'')+'src="'+DATAFACE_URL+'/images/treeCollapsed.gif" alt="Expand node"  onclick="expandNode(this,\''+document.http_vars.basepath+'/'+id+'\')"/>&nbsp;'+((data[id]['__url__'])?('<a href="'+data[id]['__url__']+'">'):'')+data[id]['__title__']+((data[id]['__url__'])?'</a>':'')+'<ul style="display:none" id="navtree-'+document.http_vars.basepath+'/'+id+'">';
            if ( id.indexOf('?') >= 0 ){
               
            
               if ( !document.recordIndex[id] ){
                  document.recordIndex[id] = data[id];
               }
               out += '<li>Loading ...</li>';
               
            } else {
               
               for (recid in data[id]['records']){
                  out += '<li><img src="'+DATAFACE_URL+'/images/treeCollapsed.gif" alt="Expand node"  onclick="expandNode(this,\''+document.http.basepath+'/'+id+'/'+recid+'\')"/>&nbsp;<a href="'+data[id]['records'][recid]['__url__']+'">'+data[id]['records'][recid]['__title__']+'</a><ul style="display:none" id="navtree-'+document.http.basepath+'/'+recid+'"><li>Loading ...</li></ul></li>';
               }
            }
            out += '</ul>';
            
            
         }
         document.http_vars.ul.innerHTML = out;
         document.http_vars.ul.menuLoaded = true;
      }
   
   }
   
   /**
    * We will maintain an associative array of all record objects that have been loaded.
    */
   if (!document.recordIndex){
      document.recordIndex = {};
   }
   document.http_vars = {};
   
   document.recordIndex['Program?ProgramID=1'] =
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby shannah » Thu Oct 14, 2010 3:49 pm

The best thing to do is to check your error log.

(Also a note... Make sure you close the site off with some authentication before too long).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby semicon_guy » Thu Oct 14, 2010 5:13 pm

OK, that's a great suggestion! Here is the error:
<b>Fatal error</b>: Call to undefined function json_encode() in <b>/..../xataface-1.2.5/Dataface/Record.php</b> on line <b>2675</b><br />

It looks like I need to install json_encode, which is only installed by default for PHP >=5.2. It might be useful to updated documentation with some clarification, since it currently says PHP >=5 is sufficient.
http://xataface.com/documentation/tutor ... troduction

Thanks again!!
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby shannah » Thu Oct 14, 2010 6:07 pm

What version of php are you running.? Json_encode should be standard in 5 or higher.
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby semicon_guy » Thu Oct 14, 2010 8:29 pm

I am running 5.1.x. It appears it is only part of the default install for >= 5.2
http://www.boutell.com/scripts/jsonwrapper.html

Here is a workaround you could implement too
http://www.stetsenko.net/2009/09/php-js ... ore-5-2-0/
semicon_guy
 
Posts: 16
Joined: Wed Oct 13, 2010 5:05 pm

Re: When I add a simple relationship, "New Record" form is blank

Postby shannah » Fri Oct 15, 2010 6:44 pm

Xataface ships with Services_JSON, a PHP class that could be used as a workaround.

e.g.
Code: Select all
if ( !function_exists('json_encode') ){
    require_once 'dataface/lib/Services/JSON.php';
    function json_encode($data){
        $json = new Services_JSON();
        return $json->encode($data);
    }
}



(Just add something like this to the beginning of your index.php file)
json_decode requires more care because it takes some extra parameters, but you could create a workaround for this too.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 15 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved