Aggregates to the supplied chain, HTML code for presenting an input field as part of a form. The resulting field will be unpopulated unless a data source is specified as an attribute to <xfield> and only then if that source successfully evaluates. Returns: None
| Return Type | Function name | Arguments |
|---|---|---|
| void | hdsField::Generate | (hzChain&,hzHttpEvent*,uint32_t&,) |
Declared in file: hzDissemino.h
Defined in file : hdsGenerate.cpp
Function Logic:
Function body:
void hdsField::Generate (hzChain& C)hzHttpEvent* pE, uint32_t& nLine,
{
// Aggregates to the supplied chain, HTML code for presenting an input field as part of a form. The resulting field will be unpopulated unless a
// data source is specified as an attribute to <xfield> and only then if that source successfully evaluates.
//
// Arguments: 1) C The HTML output chain
// 2) pE The HTTP event being responded to
// 3) nLine Line number tracker (controls NL printing)
//
// Returns: None
_hzfunc("hdsField::Generate") ;
hzAtom atom ; // For fetching field value from db
hdbEnum* pSlct ; // Selector
const char* pDictStr ; // String from dictionary string number
hzString value ; // Value in session if set
hzString S ; // Temp string
uint32_t rows ; // Selector rows for radio
uint32_t n ; // Selector items iterator
hzEcode rc ; // Return code
if (pE && m_Source)
{
rc = m_pApp->PcEntConv(atom, m_Source, pE) ;
if (atom.IsSet())
value = atom.Str() ;
}
switch (m_Fldspec.htype)
{
case HTMLTYPE_HIDDEN: // Insert hidden value
C.Printf("<input type=\"hidden\" name=\"%s\" value=\"%s\"/>", *m_Varname, *value) ; // atom.Str()) ;
break ;
case HTMLTYPE_SELECT: // Write out the selector with already selected options marked as selected
pSlct = (hdbEnum*) m_Fldspec.m_pType ;
if (m_flagVE & VE_MULTIPLE)
C.Printf("<select name=\"%s\" multiple>", *m_Varname) ;
else
C.Printf("<select name=\"%s\">", *m_Varname) ;
for (n = 0; n < pSlct->Count() ; n++)
{
S = pSlct->GetStr(n) ;
// strNo = pSlct->m_Items[n] ;
// pDictStr = _hzGlobal_setStrings->Xlate(strNo) ;
if (value == pDictStr)
C.Printf("<option selected>%s</option>", *S) ;
else
C.Printf("<option>%s</option>", *S) ;
}
C << "</select>" ;
break ;
case HTMLTYPE_RADIO:
// Write out the selector as a radio button set. The seletor cannot be multiple but the number of colums must be specified. The radio set will appear
// within a <table> in which each column except the last, will contain N items. N is calculated as the total selector population divided by the number
// of columns, then plus one. The last column will contain the remainder. The items will be displayed in the order they appear in the selector but are
// used to fill each column before moving on to the next. The columns are from left to right.
pSlct = (hdbEnum*) m_Fldspec.m_pType ;
rows = (pSlct->Count() / m_Fldspec.nCols) + 1;
C << "<table>\n" ;
C << "\t<tr>\n" ;
C << "\t\t<td>\n" ;
for (n = 0; n < pSlct->Count() ; n++)
{
S = pSlct->GetStr(n) ;
if (n && (n % rows) == 0)
{
C.Printf("<input type=\"radio\" name=\"%s\" value=\"%d\">%s\n", *m_Varname, n, *S) ;
C << "\t\t<td>\n\t\t</td>\n" ;
continue ;
}
C.Printf("<input type=\"radio\" name=\"%s\" value=\"%d\">%s<br>\n", *m_Varname, n, *S) ;
}
C << "\t\t</td>\n" ;
C << "\t</tr>\n" ;
C << "</table>\n" ;
break ;
case HTMLTYPE_CHECKBOX: if (value)
C.Printf("<input type=\"checkbox\" name=\"%s\" checked>", *m_Varname) ;
else
C.Printf("<input type=\"checkbox\" name=\"%s\">", *m_Varname) ;
break ;
case HTMLTYPE_FILE: C.Printf("<input type=\"file\" name=\"%s\" value=\"%s\">", *m_Varname, *value) ;
break ;
case HTMLTYPE_TEXT:
case HTMLTYPE_TEXTAREA:
if (m_Fldspec.nRows <&eq; 1)
{
if (m_flagVE & VE_UNIQUE)
C.Printf("<input type=\"text\" name=\"%s\" size=\"%d\" maxlength=\"%d\" onchange=\"ckUnique_%s()\"",
*m_Varname, m_Fldspec.nCols, m_Fldspec.nSize, *m_Varname) ;
else
C.Printf("<input type=\"text\" name=\"%s\" size=\"%d\" maxlength=\"%d\"", *m_Varname, m_Fldspec.nCols, m_Fldspec.nSize) ;
if (m_CSS)
C.Printf(" class=\"%s\"", *m_CSS) ;
if (value)
C.Printf(" value=\"%s\"", *value) ;
if (m_flagVE & VE_DISABLED)
C << " disabled" ;
C << "/>" ;
}
else
{
C.Printf("<textarea name=\"%s\" rows=\"%d\" cols=\"%d\" maxlength=\"%d\"", *m_Varname, m_Fldspec.nRows, m_Fldspec.nCols, m_Fldspec.nSize) ;
if (m_CSS)
C.Printf(" class=\"%s\"", *m_CSS) ;
C.AddByte(CHAR_MORE) ;
if (value)
C << value ;
C << "</textarea>" ;
}
break ;
case HTMLTYPE_PASSWORD:
C.Printf("<input type=\"password\" name=\"%s\" size=\"%d\" maxlength=\"%d\"", *m_Varname, m_Fldspec.nCols, m_Fldspec.nSize) ;
if (m_CSS)
C.Printf(" class=\"%s\"", *m_CSS) ;
if (value)
C.Printf(" value=\"%s\"", *value) ;
C << "/>" ;
break ;
default:
C.Printf("Sorry: HTML Unknown type. FldDesc=%s Name=%s Type=%s htype=%d Rows=%d Cols=%d Size=%d",
*m_Fldspec.m_Refname, *m_Varname, m_Fldspec.m_pType->txtType(), m_Fldspec.htype, m_Fldspec.nRows, m_Fldspec.nCols, m_Fldspec.nSize) ;
break ;
}
}