void WMLInputElement::initialize() { String nameVariable = formControlName(); String variableValue; WMLPageState* pageSate = wmlPageStateForDocument(document()); ASSERT(pageSate); if (!nameVariable.isEmpty()) variableValue = pageSate->getVariable(nameVariable); if (variableValue.isEmpty() || !isConformedToInputMask(variableValue)) { String val = value(); if (isConformedToInputMask(val)) variableValue = val; else variableValue = ""; pageSate->storeVariable(nameVariable, variableValue); } setValue(variableValue); if (!hasAttribute(WMLNames::emptyokAttr)) { if (m_formatMask.isEmpty() || // check if the format codes is just "*f" (m_formatMask.length() == 2 && m_formatMask[0] == '*' && formatCodes().find(m_formatMask[1]) != notFound)) m_isEmptyOk = true; } }
void WMLTimerElement::timerFired(Timer<WMLTimerElement>*) { if (!m_card) return; WMLPageState* pageState = wmlPageStateForDocument(document()); if (!pageState) return; String value = this->value(); // When the timer expires, set the name varialbe of timer to '0' if (!m_name.isEmpty()) { value = "0"; pageState->storeVariable(m_name, value); } WMLIntrinsicEventType eventType = WMLIntrinsicEventOnTimer; WMLIntrinsicEventHandler* eventHandler = m_card->eventHandler(); bool hasIntrinsicEvent = false; if (eventHandler && eventHandler->hasIntrinsicEvent(eventType)) hasIntrinsicEvent = true; else if (m_card->templateElement()) { eventHandler = m_card->templateElement()->eventHandler(); if (eventHandler && eventHandler->hasIntrinsicEvent(eventType)) hasIntrinsicEvent = true; } if (hasIntrinsicEvent) eventHandler->triggerIntrinsicEvent(eventType); }
void WMLSelectElement::updateVariables() { WMLPageState* pageState = wmlPageStateForDocument(document()); if (!pageState) return; String name = this->name(); String iname = this->iname(); if (iname.isEmpty() && name.isEmpty()) return; String nameString; String inameString; unsigned optionIndex = 0; const Vector<Element*>& items = m_data.listItems(this); for (unsigned i = 0; i < items.size(); ++i) { OptionElement* optionElement = toOptionElement(items[i]); if (!optionElement) continue; ++optionIndex; if (!optionElement->selected()) continue; if (!nameString.isEmpty()) nameString += ";"; if (!inameString.isEmpty()) inameString += ";"; nameString += optionElement->value(); inameString += String::number(optionIndex); } if (!name.isEmpty()) pageState->storeVariable(name, nameString); if (!iname.isEmpty()) pageState->storeVariable(iname, inameString); }
void WMLSelectElement::initializeVariables() { ASSERT(!m_defaultOptionIndices.isEmpty()); WMLPageState* pageState = wmlPageStateForDocument(document()); if (!pageState) return; const Vector<Element*>& items = m_data.listItems(this); if (items.isEmpty()) return; // Spec: If the 'iname' attribute is specified, then the named variable is set with the default option index. String iname = this->iname(); if (!iname.isEmpty()) pageState->storeVariable(iname, optionIndicesToString()); String name = this->name(); if (name.isEmpty()) return; if (m_data.multiple()) { // Spec: If the 'name' attribute is specified and the select is a multiple-choice element, // then for each index greater than zero, the value of the 'value' attribute on the option // element at the index is added to the name variable. pageState->storeVariable(name, optionIndicesToValueString()); return; } // Spec: If the 'name' attribute is specified and the select is a single-choice element, // then the named variable is set with the value of the 'value' attribute on the option // element at the default option index. unsigned optionIndex = m_defaultOptionIndices.first(); ASSERT(optionIndex >= 1); int listIndex = optionToListIndex(optionIndex - 1); ASSERT(listIndex >= 0); ASSERT(listIndex < (int) items.size()); if (OptionElement* optionElement = toOptionElement(items[listIndex])) pageState->storeVariable(name, optionElement->value()); }