Hi sven

so I studied your code and I got a solution working. Tx for your support.
 Now I do not know if what I did is correct.

registerRoutes
        teapot
                GET: '/' -> '<h1>My game collection</h1>';
                output: #html;
                GET: '/games' -> [ :reg | (self htmlListFor: self games)];
                output: #html;
                GET:
'/findDetails/<title>' -> [ :req | collector findMatchingTitle: (req at: #title) ];
                output: #json;
                GET:
                        '/find/<title>'
                                -> [ :req |
                                        TeaResponse ok
body: (self htmlListFor: (collector findMatchingTitle: (req at: #title))) ];
                output: #html;
                GET: '/add' -> [ :req | self edit: req ];
                GET: '/create' -> (Send message: #create: to: self)

So I used /add
to enter the parameter and pass them to the /create page.
in the /create I created the new item and I could redirect to game list (I imagine that this is possible). So now I see tht I could merge add and create into a single page (as you did) and

edit: request
        | title page |
        title := 'Enter a title'.
        page := ZnHtmlOutputStream
                streamContents: [ :html |
                        html
                                page: 'Create game named'
                                do: [ html
                                        tag: #form
                                        attributes: #(#action 'create' 
'accept-charset' 'utf-8' #method #GET)
                                        do: [ html
                                                str: 'Title';
                                                space;
                                                tag: #input
                                                attributes:
                                                {#type.
                                                #input.
                                                #name.
                                                #input.
                                                #value.
                                                title};
                                                space;
                                tag: #input attributes: #(#type #submit) ] ] ].
        ^ ZnResponse new
                statusLine: ZnStatusLine ok;
                entity: (ZnEntity html: page);
                yourself


create: aRequest
        collector addGame: (GameItem new title: (aRequest at: #input)).
        ^ ZnResponse new
                statusLine: ZnStatusLine ok;
                entity: (ZnEntity html: 'Created!');
                yourself

Reply via email to