Multiple submit buttons/links?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple submit buttons/links?

Carl Gundel
How can I create more than one button or link on a page that causes the
callbacks to be invoked for each component, even for pages that are composed
of one or more non-nested forms?  Is there a simple way provided in the
framework?

Thanks,

-Carl Gundel, author of Liberty BASIC
http://www.libertybasic.com


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Multiple submit buttons/links?

Carl Gundel
> How can I create more than one button or link on a page that causes the
> callbacks to be invoked for each component, even for pages that are
composed
> of one or more non-nested forms?  Is there a simple way provided in the
> framework?

Well, with some spelunking we managed to find
#anchorWithAction:text:submitFormNamed: which lets us have multiple anchors
and each can cause a submit.  These are links but using CSS we can make the
links look like buttons.

    html attributes name: #activeStuff.
    html form:
        [ html textInputWithCallback: [:value | self name: value].
            "here is a nested form which also has an anchor"
            super renderContentOn: html].
    html
        anchorWithAction: [self doThis ]
        text: 'this text'
        submitFormNamed: #activeStuff.
    html
        anchorWithAction: [self doThat ]
        text: 'that text'
        submitFormNamed: #activeStuff.

Problem solved.  I hope this helps somebody.  :-)

-Carl Gundel, author of Liberty BASIC
http://www.libertybasic.com


_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Re: Multiple submit buttons/links?

Boris Popov-4
Carl Gundel wrote:

>> How can I create more than one button or link on a page that causes the
>> callbacks to be invoked for each component, even for pages that are
> composed
>> of one or more non-nested forms?  Is there a simple way provided in the
>> framework?
>
> Well, with some spelunking we managed to find
> #anchorWithAction:text:submitFormNamed: which lets us have multiple anchors
> and each can cause a submit.  These are links but using CSS we can make the
> links look like buttons.
>
>     html attributes name: #activeStuff.
>     html form:
>         [ html textInputWithCallback: [:value | self name: value].
>             "here is a nested form which also has an anchor"
>             super renderContentOn: html].
>     html
>         anchorWithAction: [self doThis ]
>         text: 'this text'
>         submitFormNamed: #activeStuff.
>     html
>         anchorWithAction: [self doThat ]
>         text: 'that text'
>         submitFormNamed: #activeStuff.
>
> Problem solved.  I hope this helps somebody.  :-)
>
You can also do that with actual buttons. Attached is an extension of
WASubmitButtonTag that borrows javascript snippet from an anchor and a
demo application in Login.st,

Note that this all using the new render canvas API, which I highly
recommend over the old way of doing things anyway.

Hope this helps,

-Boris

<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.4 of December 5, 2005 on June 17, 2006 at 5:32:05 pm</time-stamp>


<methods>
<class-id>Seaside.WASubmitButtonTag</class-id> <category>javascript</category>

<body package="Seaside-Canvas-Tags" selector="submitFormNamed:">submitFormNamed: formName
        self onClick: 'submitForm(' , formName asString printString , '); return false;'</body>
</methods>

</st-source>

<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.4 of December 5, 2005 on June 17, 2006 at 5:31:53 pm</time-stamp>


<class>
<name>Login</name>
<environment>Smalltalk</environment>
<super>Seaside.WAComponent</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars>username password </inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category>Login</category>
<attributes>
<package>Login</package>
</attributes>
</class>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>Login class</class-id> <category>accessing</category>

<body package="Login" selector="canBeRoot">canBeRoot
        ^true</body>
</methods>

<methods>
<class-id>Login class</class-id> <category>initialize-release</category>

<body package="Login" selector="initialize">initialize
        self registerAsApplication: 'login'</body>
</methods>

<!-- -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -   -->


<methods>
<class-id>Login</class-id> <category>rendering</category>

<body package="Login" selector="renderContentOn:">renderContentOn: html
        html text: '(start of form)'.
        html horizontalRule.
        (html form)
                name: 'login';
                with:
                                [html div:
                                                [html text: 'Username'.
                                                html space.
                                                (html textInput)
                                                        value: self username;
                                                        callback: [:v | self username: v]].
                                html div:
                                                [html text: 'Password'.
                                                html space.
                                                (html textInput)
                                                        value: self password;
                                                        callback: [:v | self password: v]].
                                html div: [html submitButton value: 'Login'].
                                html
                                        text: 'u:';
                                        space;
                                        text: self username;
                                        break;
                                        text: 'p:';
                                        space;
                                        text: self password].
        html horizontalRule.
        html text: '(end of form)'.
        html form:
                        [(html submitButton)
                                submitFormNamed: 'login';
                                value: 'Second Login']</body>

<body package="Login" selector="rendererClass">rendererClass
        ^Seaside.WARenderCanvas</body>
</methods>

<methods>
<class-id>Login</class-id> <category>accessing</category>

<body package="Login" selector="password">password
        ^password</body>

<body package="Login" selector="password:">password: anObject
        password := anObject</body>

<body package="Login" selector="username">username
        ^username</body>

<body package="Login" selector="username:">username: anObject
        username := anObject</body>
</methods>

<methods>
<class-id>Login</class-id> <category>initialize-release</category>

<body package="Login" selector="initialize">initialize
        super initialize.
        self
                username: String new;
                password: String new</body>
</methods>

<initialize>
<class-id>Login</class-id>
</initialize>

</st-source>

_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside