Commit 4ae9db539bb369333efc8a942d5931671a64622a
1 parent
a3d39e05
Submit button: if an id is provided, it's used as name for the onclick javascript function.
Showing
1 changed file
with
42 additions
and
16 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| ... | ... | @@ -2704,7 +2704,7 @@ public define Printable_tree |
| 2704 | 2704 | variable Int32 count = 0. |
| 2705 | 2705 | |
| 2706 | 2706 | Note: this counter is private to the virtual machine, hence there is one counter by |
| 2707 | - client. | |
| 2707 | + client and by page : it seems that a new VM (simply a delegate) is started for each request. | |
| 2708 | 2708 | |
| 2709 | 2709 | define Int32 |
| 2710 | 2710 | new_count |
| ... | ... | @@ -2764,14 +2764,6 @@ type URL_or_JavaScript: |
| 2764 | 2764 | url (String), |
| 2765 | 2765 | javascript (Printable_tree script, Printable_tree handler). |
| 2766 | 2766 | |
| 2767 | - define URL_or_JavaScript | |
| 2768 | - format_action | |
| 2769 | - ( | |
| 2770 | - String the_url, | |
| 2771 | - Maybe(String) mb_form_name | |
| 2772 | - ) = | |
| 2773 | - url(the_url). | |
| 2774 | - | |
| 2775 | 2767 | |
| 2776 | 2768 | It was as shown below, in order to allow submission of a form from outside the form, |
| 2777 | 2769 | but this makes problems: |
| ... | ... | @@ -2780,6 +2772,7 @@ define URL_or_JavaScript |
| 2780 | 2772 | format_action |
| 2781 | 2773 | ( |
| 2782 | 2774 | String the_url, |
| 2775 | + Maybe(String) mb_id, | |
| 2783 | 2776 | Maybe(String) mb_form_name |
| 2784 | 2777 | ) = |
| 2785 | 2778 | if mb_form_name is |
| ... | ... | @@ -2788,17 +2781,22 @@ define URL_or_JavaScript |
| 2788 | 2781 | url(the_url), |
| 2789 | 2782 | success(form_name) then |
| 2790 | 2783 | with n = new_count, |
| 2784 | + fn_name = "pfu_" + if mb_id is | |
| 2785 | + { | |
| 2786 | + failure then form_name + n, | |
| 2787 | + success(id) then id, | |
| 2788 | + }, | |
| 2791 | 2789 | javascript( |
| 2792 | 2790 | [ |
| 2793 | 2791 | "<script type=\"text/javascript\" language =\"JavaScript\">\n", |
| 2794 | - "function pfu",form_name,n,"() {\n", | |
| 2792 | + "function ", fn_name, "() {\n", | |
| 2795 | 2793 | " var fa = document.forms.f",form_name,";\n", |
| 2796 | 2794 | " var u = \"",the_url,"\";\n", |
| 2797 | 2795 | " fa.action = u;\n", |
| 2798 | 2796 | " fa.submit(); }", |
| 2799 | 2797 | "</script>" |
| 2800 | 2798 | ], |
| 2801 | - ["pfu",form_name,n,"();"] | |
| 2799 | + [fn_name,"();"] | |
| 2802 | 2800 | ) |
| 2803 | 2801 | }. |
| 2804 | 2802 | |
| ... | ... | @@ -3010,7 +3008,35 @@ define Printable_tree |
| 3010 | 3008 | )= |
| 3011 | 3009 | ["<div" + format_attrs(options) + ">"] . |
| 3012 | 3010 | |
| 3013 | - | |
| 3011 | + | |
| 3012 | +define Maybe(String) | |
| 3013 | + extract_id | |
| 3014 | + ( | |
| 3015 | + List(CoreAttrs) attrbs | |
| 3016 | + ) = | |
| 3017 | + if attrbs is | |
| 3018 | + { | |
| 3019 | + [] then failure, | |
| 3020 | + [h . t] then | |
| 3021 | + if h is id(value) then success(value) | |
| 3022 | + else extract_id(t) | |
| 3023 | + }. | |
| 3024 | + | |
| 3025 | +define Maybe(String) | |
| 3026 | + extract_id | |
| 3027 | + ( | |
| 3028 | + Actioner_Aspect aspect | |
| 3029 | + ) = | |
| 3030 | + if aspect is | |
| 3031 | + { | |
| 3032 | + link(_,_) then failure, | |
| 3033 | + push_button(opts,_) then extract_id(opts), | |
| 3034 | + submit(opts,_) then extract_id(opts), | |
| 3035 | + button(_,_) then failure, | |
| 3036 | + button(_,_,_,_) then failure, | |
| 3037 | + immediate_selector(_,_,_) then failure, | |
| 3038 | + }. | |
| 3039 | + | |
| 3014 | 3040 | define Printable_tree |
| 3015 | 3041 | format_actioner |
| 3016 | 3042 | ( |
| ... | ... | @@ -3028,7 +3054,7 @@ define Printable_tree |
| 3028 | 3054 | if cinfo is info(common_name,http_port,https_port,site_dir,secret) then |
| 3029 | 3055 | with url = make_actioner_url(cinfo,connection,target, |
| 3030 | 3056 | state_name,action_name,extra_ops,is_https), |
| 3031 | - with action = format_action(url,mb_form_name), | |
| 3057 | + with action = format_action(url, extract_id(aspect), mb_form_name), | |
| 3032 | 3058 | if aspect is |
| 3033 | 3059 | { |
| 3034 | 3060 | |
| ... | ... | @@ -3514,7 +3540,7 @@ define Printable_tree |
| 3514 | 3540 | ]. |
| 3515 | 3541 | |
| 3516 | 3542 | |
| 3517 | - | |
| 3543 | +/* | |
| 3518 | 3544 | define Printable_tree |
| 3519 | 3545 | popup_topbar |
| 3520 | 3546 | ( |
| ... | ... | @@ -3569,7 +3595,7 @@ define Printable_tree |
| 3569 | 3595 | result. |
| 3570 | 3596 | |
| 3571 | 3597 | |
| 3572 | - | |
| 3598 | +*/ | |
| 3573 | 3599 | |
| 3574 | 3600 | |
| 3575 | 3601 | // The function below formats a datum of type 'HTML_Any($T)'. |
| ... | ... | @@ -3856,7 +3882,7 @@ define Printable_tree |
| 3856 | 3882 | private_download(url,name,extra,action) then |
| 3857 | 3883 | format(cinfo,sn,ic_v,any_private_download(url,name,extra,action),format_element,is_https), |
| 3858 | 3884 | label(n) then ["<a name=\"",n,"\">"], |
| 3859 | - form(fn,attributs, c) then | |
| 3885 | + form(fn,attributs, c) then | |
| 3860 | 3886 | [ |
| 3861 | 3887 | "<form name=\"f",fn,"\"", |
| 3862 | 3888 | format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https), | ... | ... |