Exemple #1
0
        public void Update(NameValueCollection values, FormItem source, string argument)
        {
            if (formGroup == null)
            {
                return;
            }

            submitted = false;

            ISubmit iSubmit = source as ISubmit;

            if (iSubmit != null && iSubmit.Submit)
            {
                throw new ApplicationException();
            }

            IUpdate iUpdate = source as IUpdate;

            if (iUpdate == null || !iUpdate.Update)
            {
                throw new ApplicationException();
            }

            new FormUpdateVisitor(formGroup, values, source, argument);

            ApplyRules(true, source, argument);

            new FormLastMessageVisitor(formGroup, false);
        }
Exemple #2
0
        public void Submit(NameValueCollection values, FormItem source, string argument)
        {
            if (formGroup == null)
            {
                return;
            }

            submitted = false;

            new FormUpdateVisitor(formGroup, values, source, argument);

            ApplyRules(true, source, argument);

            ISubmit iSubmit = source as ISubmit;

            if (iSubmit == null || !iSubmit.Submit)
            {
                throw new ApplicationException();
            }

            if (!formGroup.IsValid)
            {
                new FormLastMessageVisitor(formGroup, true);
                return;
            }

            PerformAction();
        }
Exemple #3
0
        public void HandleRequest(HttpRequest request)
        {
            if (formModel == null)
            {
                return;
            }

            string eventTarget   = request["__EVENTTARGET"];
            string eventArgument = request["__EVENTARGUMENT"];

            if (eventTarget == null || eventArgument == null)
            {
                return;
            }

            FormItem source   = formModel.GetItem(eventTarget);
            string   argument = eventArgument;

            NameValueCollection values = new NameValueCollection();

            foreach (var key in request.Form.Keys)
            {
                if (key == null)
                {
                    continue;
                }

                if (key.ToString().StartsWith("__"))
                {
                    continue;
                }

                values.Add(key.ToString(), request.Form[key.ToString()]);
            }

            IUpdate iUpdate = source as IUpdate;
            ISubmit iSubmit = source as ISubmit;

            if (iUpdate == null && iSubmit == null)
            {
                return;
            }

            if (iSubmit != null && iSubmit.Submit)
            {
                formModel.Submit(values, source, argument);
            }
            else if (iUpdate != null && iUpdate.Update)
            {
                formModel.Update(values, source, argument);
            }
        }