internal void InitLocalData()
 {
     if (webFormsLocalDataGetter == null)
     {
         throw new ApplicationException("webFormsLocalDataGetter not set");
     }
     webFormsLocalData = webFormsLocalDataGetter();
 }
 private string getJsInitStatements()
 {
     if (webFormsLocalDataGetter == null)
     {
         throw new ApplicationException("webFormsLocalDataGetter not set");
     }
     webFormsLocalData = webFormsLocalDataGetter();
     return(webFormsLocalData.JsInitStatements);
 }
Exemple #3
0
        private PageNode buildNode(PageComponent component, IdGenerator idGenerator, bool inEtherealContainer, bool inJsInitElement)
        {
            nodeCount += 1;

            IReadOnlyCollection <PageNode> buildChildren(IEnumerable <PageComponent> children, IdGenerator g) =>
            children.Select(i => buildNode(i, g, inEtherealContainer, inJsInitElement)).Materialize();

            if (component is ElementNode elementNode)
            {
                FormState.Current.SetForNextElement();

                var id = idGenerator.GenerateId();
                idSetter(id);

                var data = elementNode.ElementDataGetter(new ElementContext(id));
                ElementNodeLocalData          localData          = null;
                ElementNodeFocusDependentData focusDependentData = null;
                var node = new PageNode(
                    elementNode,
                    elementNode.FormValue,
                    buildChildren(data.Children, idGenerator),
                    buildChildren(data.EtherealChildren, idGenerator),
                    () => {
                    // Defer attribute creation for the JavaScript initialization element.
                    if (inJsInitElement)
                    {
                        return(new FocusabilityCondition(false));
                    }

                    localData = data.LocalDataGetter();
                    return(localData.FocusabilityCondition);
                },
                    (isFocused, writer) => {
                    // Defer attribute creation for the JavaScript initialization element.
                    if (inJsInitElement)
                    {
                        return;
                    }

                    focusDependentData = localData.FocusDependentDataGetter(isFocused);
                    writer.Write(focusDependentData.JsInitStatements);
                },
                    () => {
                    if (inJsInitElement)
                    {
                        localData          = data.LocalDataGetter();
                        focusDependentData = localData.FocusDependentDataGetter(false);
                    }

                    var attributes = focusDependentData.Attributes;
                    if (focusDependentData.IncludeIdAttribute)
                    {
                        attributes = attributes.Append(new ElementAttribute("id", data.ClientSideIdOverride.Any() ? data.ClientSideIdOverride : id));
                    }
                    return(localData.ElementName, attributes);
                });