Problem smalltalk code

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

Problem smalltalk code

Alexandre BP
Hi,

I'm stuck on a problem with smalltalk.
Here is my code:

 renderBibTypeOn: canvas 

| tagID | 
canvas div: [ 
canvas label 
for: (tagID := canvas nextId); 
with: 'BibteX Type:'. 
canvas select 
id: tagID; 
selected: bibEntry bibType ; 
list: bibEntry bibTypeList; 
callback: [:value | bibEntry bibType: value].
].

I'd like to change what is displayed on my webpage according to what the user choose from the scroll list.
I saw that there was an exemple of this on localhost-->browse-->examples-->examplebrowser 
but the code of this exemple is not online on the contraty of the other examples.
Could you help me with this code or post the code of the examplebrowser?

Thank you very much
alex

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

RE: Problem smalltalk code

Robert Sirois
Browse WAChoiceDialog.

You can make it as simple as:

renderContentOn: html

    html form: [ html select list: (Array with: 'a' with: 'b'); callback: [:v | self selected: v ] ].
    html text: self selected.

selected
    ^selected ifNil: [ selected := 'Choose a value to print.' ].

selected: aRenderable
    selected := aRenderable.

(Doing this from memory)
RS


From: [hidden email]
To: [hidden email]
Date: Tue, 26 Oct 2010 16:20:16 +0000
Subject: [Seaside] Problem smalltalk code

Hi,

I'm stuck on a problem with smalltalk.
Here is my code:

 renderBibTypeOn: canvas 

| tagID | 
canvas div: [ 
canvas label 
for: (tagID := canvas nextId); 
with: 'BibteX Type:'. 
canvas select 
id: tagID; 
selected: bibEntry bibType ; 
list: bibEntry bibTypeList; 
callback: [:value | bibEntry bibType: value].
].

I'd like to change what is displayed on my webpage according to what the user choose from the scroll list.
I saw that there was an exemple of this on localhost-->browse-->examples-->examplebrowser 
but the code of this exemple is not online on the contraty of the other examples.
Could you help me with this code or post the code of the examplebrowser?

Thank you very much
alex

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

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

RE: Problem smalltalk code

Alexandre BP
Thank you for you reply Robert,

Unfortunately it doesn't work. The variable selected is not updated directly when I change from 'a' to 'b' in the scroll list.
Any idea why it doesn't work?
 


From: [hidden email]
To: [hidden email]
Subject: RE: [Seaside] Problem smalltalk code
Date: Tue, 26 Oct 2010 10:38:09 -0600

Browse WAChoiceDialog.

You can make it as simple as:

renderContentOn: html

    html form: [ html select list: (Array with: 'a' with: 'b'); callback: [:v | self selected: v ] ].
    html text: self selected.

selected
    ^selected ifNil: [ selected := 'Choose a value to print.' ].

selected: aRenderable
    selected := aRenderable.

(Doing this from memory)
RS


From: [hidden email]
To: [hidden email]
Date: Tue, 26 Oct 2010 16:20:16 +0000
Subject: [Seaside] Problem smalltalk code

Hi,

I'm stuck on a problem with smalltalk.
Here is my code:

 renderBibTypeOn: canvas 

| tagID | 
canvas div: [ 
canvas label 
for: (tagID := canvas nextId); 
with: 'BibteX Type:'. 
canvas select 
id: tagID; 
selected: bibEntry bibType ; 
list: bibEntry bibTypeList; 
callback: [:value | bibEntry bibType: value].
].

I'd like to change what is displayed on my webpage according to what the user choose from the scroll list.
I saw that there was an exemple of this on localhost-->browse-->examples-->examplebrowser 
but the code of this exemple is not online on the contraty of the other examples.
Could you help me with this code or post the code of the examplebrowser?

Thank you very much
alex

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

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

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

Re: Problem smalltalk code

Lukas Renggli
The code you posted looks ok. Did you put everything into a form and
did you submit this form (see
http://book.seaside.st/book/fundamentals/forms).

Lukas

On Wednesday, October 27, 2010, Alexandre BP <[hidden email]> wrote:

>
>
>
>
>
> Thank you for you reply Robert,
> Unfortunately it doesn't work. The variable selected is not updated directly when I change from 'a' to 'b' in the scroll list.Any idea why it doesn't work?
>
> From: [hidden email]
> To: [hidden email]
> Subject: RE: [Seaside] Problem smalltalk code
> Date: Tue, 26 Oct 2010 10:38:09 -0600
>
> Browse WAChoiceDialog.
> You can make it as simple as:
> renderContentOn: html
>     html form: [ html select list: (Array with: 'a' with: 'b'); callback: [:v | self selected: v ] ].    html text: self selected.
> selected    ^selected ifNil: [ selected := 'Choose a value to print.' ].
> selected: aRenderable    selected := aRenderable.
> (Doing this from memory)RS
>
> From: [hidden email]
> To: [hidden email]
> Date: Tue, 26 Oct 2010 16:20:16 +0000
> Subject: [Seaside] Problem smalltalk code
>
> Hi,
> I'm stuck on a problem with smalltalk.Here is my code:
>  renderBibTypeOn: canvas
> | tagID |  canvas div: [  canvas label  for: (tagID := canvas nextId);  with: 'BibteX Type:'.  canvas select  id: tagID;  selected: bibEntry bibType ;  list: bibEntry bibTypeList;  callback: [:value | bibEntry bibType: value]. ].
> I'd like to change what is displayed on my webpage according to what the user choose from the scroll list.I saw that there was an exemple of this on localhost-->browse-->examples-->examplebrowser but the code of this exemple is not online on the contraty of the other examples.Could you help me with this code or post the code of the examplebrowser?
> Thank you very much  
>

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

Re: Problem smalltalk code

Johan Brichau-2
In reply to this post by Alexandre BP
<base href="x-msg://52/">
Changing the selection in the scroll list does not submit the form automatically. You either need to have an explicit submit button, which will trigger the callbacks on the server-side, or you need to make the form submit on the 'change' event of the scroll list.

If you want the form to submit when changing the selection in the scroll list, you can use the jQuery ajax serialize functionality like this:

html select
list: ...
callback: ....
onChange: (html jQuery ajax serializeForm)


Johan

On 27 Oct 2010, at 09:05, Alexandre BP wrote:

Thank you for you reply Robert,

Unfortunately it doesn't work. The variable selected is not updated directly when I change from 'a' to 'b' in the scroll list.
Any idea why it doesn't work?
 


From: [hidden email]
To: [hidden email]
Subject: RE: [Seaside] Problem smalltalk code
Date: Tue, 26 Oct 2010 10:38:09 -0600

Browse WAChoiceDialog.

You can make it as simple as:

renderContentOn: html

    html form: [ html select list: (Array with: 'a' with: 'b'); callback: [:v | self selected: v ] ].
    html text: self selected.

selected
    ^selected ifNil: [ selected := 'Choose a value to print.' ].

selected: aRenderable
    selected := aRenderable.

(Doing this from memory)
RS


From: [hidden email]
To: [hidden email]
Date: Tue, 26 Oct 2010 16:20:16 +0000
Subject: [Seaside] Problem smalltalk code

Hi,

I'm stuck on a problem with smalltalk.
Here is my code:

 renderBibTypeOn: canvas 

| tagID | 
canvas div: [ 
canvas label 
for: (tagID := canvas nextId); 
with: 'BibteX Type:'. 
canvas select 
id: tagID; 
selected: bibEntry bibType ; 
list: bibEntry bibTypeList; 
callback: [:value | bibEntry bibType: value].
 ].

I'd like to change what is displayed on my webpage according to what the user choose from the scroll list.
I saw that there was an exemple of this on localhost-->browse-->examples-->examplebrowser 
but the code of this exemple is not online on the contraty of the other examples.
Could you help me with this code or post the code of the examplebrowser?

Thank you very much
alex

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

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


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

RE: Problem smalltalk code

Robert Sirois
Ah, yea, my bad. I just threw that in there from memory. The callbacks can be triggered with a submitButton or an ajax serialization. Here's a couple snippets from code I've written just as examples:

This one's pretty basic:

renderContentOn: html
html form: [
html text: 'Game name: '.
html textInput
callback: [:v | gameName := v ].
html break.
html text: 'World: '.
html select
callback: [:v | worldName := v ];"The callback will get evaluated when the client hits the submitButton within the form tags"
list: (GTLWorld worlds collect: [:w | w n ]).
html break.
html select
callback: [:v | desiredPlayers := v ];"oh... just on another note (to whoever posted that thing about restricting input values to integers), this will accomplish that)
list: #(2 3 4 5 6)."I could have also done: #list: (2 to: 6)."
html break.
html submitButton"regardless of what the submitButton's callback does, the callbacks on all the form elements will be evaluated"
callback: [ self createNewGame ];
value: 'Add game to queue'.
].

This select will automatically go to another page when the client selects something (#goToPage: renders a new component via jQuery):

html select
on: #selected of: self;"browse implementors of this method, it's another way of assigning input to instance variables"
list: ((user organizations collect: [:org | org oName ]) addFirst: '-- Select an organization --'; yourself);
onChange: html jQuery ajax serializeThis, (html jQuery ajax script: [:s | s add: (self goToPage: s)] )."concatenation is my lazy way of chaining jQuery/javascript"

This one is a little more complicated: The select will get serialized when the client hits the "Invite" button, and then refreshes the page (displaying in a list all the users the client has invited).

html select
id: #invitePlayer;
list: (self session gameObject server players collect: [:player | player username ]);
callback: [:v | self invitedPlayers add: v ];
onSubmit: html jQuery ajax serializeThis."the submit event is irrelevant... I just chose it because it wouldn't normally occur"
html button
bePush;
onClick: (html jQuery: #invitePlayer) triggerSubmit, html javascript refresh;
with: 'Invite'.

Anyway... I hope this helps.
RS


From: [hidden email]
Subject: Re: [Seaside] Problem smalltalk code
Date: Wed, 27 Oct 2010 09:39:57 +0200
To: [hidden email]

Changing the selection in the scroll list does not submit the form automatically. You either need to have an explicit submit button, which will trigger the callbacks on the server-side, or you need to make the form submit on the 'change' event of the scroll list.

If you want the form to submit when changing the selection in the scroll list, you can use the jQuery ajax serialize functionality like this:

html select
list: ...
callback: ....
onChange: (html jQuery ajax serializeForm)


Johan

On 27 Oct 2010, at 09:05, Alexandre BP wrote:

Thank you for you reply Robert,

Unfortunately it doesn't work. The variable selected is not updated directly when I change from 'a' to 'b' in the scroll list.
Any idea why it doesn't work?
 


From: [hidden email]
To: [hidden email]
Subject: RE: [Seaside] Problem smalltalk code
Date: Tue, 26 Oct 2010 10:38:09 -0600

Browse WAChoiceDialog.

You can make it as simple as:

renderContentOn: html

    html form: [ html select list: (Array with: 'a' with: 'b'); callback: [:v | self selected: v ] ].
    html text: self selected.

selected
    ^selected ifNil: [ selected := 'Choose a value to print.' ].

selected: aRenderable
    selected := aRenderable.

(Doing this from memory)
RS


From: [hidden email]
To: [hidden email]
Date: Tue, 26 Oct 2010 16:20:16 +0000
Subject: [Seaside] Problem smalltalk code

Hi,

I'm stuck on a problem with smalltalk.
Here is my code:

 renderBibTypeOn: canvas 

| tagID | 
canvas div: [ 
canvas label 
for: (tagID := canvas nextId); 
with: 'BibteX Type:'. 
canvas select 
id: tagID; 
selected: bibEntry bibType ; 
list: bibEntry bibTypeList; 
callback: [:value | bibEntry bibType: value].
 ].

I'd like to change what is displayed on my webpage according to what the user choose from the scroll list.
I saw that there was an exemple of this on localhost-->browse-->examples-->examplebrowser 
but the code of this exemple is not online on the contraty of the other examples.
Could you help me with this code or post the code of the examplebrowser?

Thank you very much
alex

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

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


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

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

Re: Problem smalltalk code

Ramon Leon-5
Rather than adding to the list like this and passing around strings...

html select
   list: ((user organizations collect: [:org | org oName ]) addFirst:
'-- Select an organization --'; yourself);
   on: #selected of: self;

Just do this to accomplish the same thing, and you don't really want to
just get org names either, you want the org object, so fix the labels
like this...

html select
   beOptional;
   optionLabel: '-- Select an organization --';
   list: user organizations;
   labels: [:org | org oName];
   on: #selected of: self;

Now when the user makes a selects, #selected is set to the correct org
object, not just its name.

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

RE: Problem smalltalk code

Robert Sirois
Oh cool. Thanks Ramon now I change a bunch of code tonight ;) I always wondered how to do that lol.

Gracias :)

RS via G1

> Date: Wed, 27 Oct 2010 10:49:47 -0700
> From: ramon.leon@allresnet.com
> To: seaside@lists.squeakfoundation.org
> Subject: Re: [Seaside] Problem smalltalk code
>
> Rather than adding to the list like this and passing around strings...
>
> html select
> list: ((user organizations collect: [:org | org oName ]) addFirst:
> '-- Select an organization --'; yourself);
> on: #selected of: self;
>
> Just do this to accomplish the same thing, and you don't really want to
> just get org names either, you want the org object, so fix the labels
> like this...
>
> html select
> beOptional;
> optionLabel: '-- Select an organization --';
> list: user organizations;
> labels: [:org | org oName];
> on: #selected of: self;
>
> Now when the user makes a selects, #selected is set to the correct org
> object, not just its name.
>
> --
> Ramon Leon
> http://onsmalltalk.com
> _______________________________________________
> seaside mailing list
> seaside@lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

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