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 Type | Function name | Arguments |
|---|---|---|
| void | hdsApp::InPageQuery | (hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsSystem.cpp
Function Logic:
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 ;
}