Respond to an in-page query (Dissemino AJAX) An in-page query is an AJAX request to a URL of the form '/ck-repos.member.value' - to which the response is a blank page with a HTTP return code of either 200 (OK) or 404 (NOTFOUND). A code of 200 indicates that the repository exists, is populated and is of a class which possesses the named member. The purpose of an in-page query is to support form validation. Fields which must contain a unique value such as an email address or a username (a common requirement in site membership application/registration forms), can be validated by these AJAX calls. Returns: None

Return TypeFunction nameArguments
voidhdsApp::InPageQuery(hzHttpEvent*,)

Declared in file: hzDissemino.h
Defined in file : hdsSystem.cpp

Function Logic:

0:START 1:r 2:unknown 3:items 4:S items pRepos 5:unknown 6:rc 7:Goto fail 8:unknown 9:rc 10:Goto fail 11:unknown 12:items 13:S items 14:unknown 15:rc 16:Goto fail 17:val atom items rc 18:unknown 19:items 20:Goto fail 21:items 22:unknown 23:items 24: No text 25:fail 26:items 27: No text

Function body:

void hdsApp::InPageQuery (hzHttpEvent* pE)
{
   //  Respond to an in-page query (Dissemino AJAX)
   //  
   //  An in-page query is an AJAX request to a URL of the form '/ck-repos.member.value' - to which the response is a blank page with a HTTP return code of either 200 (OK) or 404
   //  (NOTFOUND). A code of 200 indicates that the repository exists, is populated and is of a class which possesses the named member.
   //  
   //  The purpose of an in-page query is to support form validation. Fields which must contain a unique value such as an email address or a username (a common requirement in site
   //  membership application/registration forms), can be validated by these AJAX calls. 
   //  
   //  Argument: pE The HTTP event pointer
   //  
   //  Returns: None
   _hzfunc("hdsApp::InPageQuery") ;
   hzChain         Z ;             //  For arg processing
   hzAtom          atom ;          //  Need for Exists()
   hdbObjRepos*    pRepos ;        //  Use class (of desired document)
   const char*     r ;             //  Pointer into event resource
   hzString        S ;             //  Temp string
   hzString        val ;           //  Value
   uint32_t        objId ;         //  Object found
   hzEcode         rc = E_OK ;     //  Return code
   //  Get class/cache name
   r = pE->GetResource() ;
   for (r += 4; IsAlpha(*r) ; r++)
       Z.AddByte(*r) ;
   S = Z ;
   Z.Clear() ;
   pRepos = m_ADP.GetObjRepos(S) ;
   if (!pRepos)
       { rc = E_NOTFOUND ; goto fail ; }
   if (*r != CHAR_PERIOD)
       { rc = E_FORMAT ; goto fail ; }
   //  Get member name & value
   for (r++ ; IsAlpha(*r) ; r++)
       Z.AddByte(*r) ;
   S = Z ;
   Z.Clear() ;
   if (*r != CHAR_PERIOD)
       { rc = E_FORMAT ; goto fail ; }
   val = ++r ;
   atom = val ;
   m_pLog->Out("Doing Binary fetch on %s %s\n", *S, *val) ;
   rc = pRepos->Exists(objId, pRepos->Class()->GetMember(S), atom) ;
   if (rc != E_OK)
       { m_pLog->Out("Binary fech function failed. Err=%s\n", Err2Txt(rc)) ; goto fail ; }
   //  Serve it
   m_pLog->Out("%s. Located record %d\n", __func__, objId) ;
   if (objId)
   {
       pE->SendAjaxResult(HTTPMSG_OK) ;
       return ;
   }
fail:
   pE->SendAjaxResult(HTTPMSG_NOTFOUND) ;
   return ;
}