WAComponent>>#call:/#answer: usage question

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

WAComponent>>#call:/#answer: usage question

John Thornborrow
Hello,

The below #renderContentOn: does not render, nor does the #call:'ed
component; I receive only a blank page.

I understand there have been some changes to the #call:/#answer:
methods, however I cannot find any reference to what I can use instead.

Any assistance is appreciated, thanks.

The code:

==
FVAdmin>>#initialize
  options _ Dictionary new
    at: 'user' put: #FVAdminUser;
    at: 'blogCreate' put: #FVBlogCreate;
    at: 'moderation' put: #FVModeration;
    at: 'articleCreate' put: #FVAdminArticle;
    at: 'imageUpload' put: #FVImageUpload;
    at: 'subscriptionAdmin' put: #FVAdminSubscriptions;
    yourself.
  content := FVAdminOptions new registry: self registry.
  ^super initialize

FVAdmin>>#renderContentOn: html
  html heading level: 2; with: [
   html text: 'Administration Area'].
  self content: (self call: content)

FVAdmin>>#content: aString
  | cont |
  cont := options
    at: aString
    ifAbsent: [self error: 'Incorrect Option Chosen: ', aString].
  content := (Smalltalk at: cont) new registry: self registry

FVAdminOptions>>#renderContentOn: html
  html unorderedList with: [
    html listItem with: [
      html anchor
        callback: [self answer: 'user'];
        with: [html text: 'User Administration']].
    html listItem with: [
      html anchor
        callback: [self answer: 'articleCreate'];
        with: [html text: 'Create New/Edit existing Analysis Article']].
    html listItem with: [
      html anchor
        callback: [self answer: 'imageUpload'];
        with: [html text: 'Upload Images']].
    html listItem with: [
      html anchor
        callback: [self answer: 'subscriptionAdmin'];
        with: [html text: 'Administer Subscriptions']]]
==


Regards,
John

www.pinesoft.co.uk


Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: WAComponent>>#call:/#answer: usage question

Damien Cassou-3
Hi John,

2007/8/21, John Thornborrow <[hidden email]>:
> The below #renderContentOn: does not render, nor does the #call:'ed
> component; I receive only a blank page.


You must not send #call: during the rendering. Only during callbacks
(after a click on a link for example). (Note for the others: I think
this problem should be dealt with in the FAQ).

You might probably want to use a WATask or change a bit the flow of
your application. See documentation at http://www.seaside.st.

A non-related note: use (Smalltalk classNamed: aSymbol) instead of
(Smalltalk at: aSymbol). This is clearer.


> I understand there have been some changes to the #call:/#answer:
> methods, however I cannot find any reference to what I can use instead.
>
> Any assistance is appreciated, thanks.
>
> The code:
>
> ==
> FVAdmin>>#initialize
>   options _ Dictionary new
>     at: 'user' put: #FVAdminUser;
>     at: 'blogCreate' put: #FVBlogCreate;
>     at: 'moderation' put: #FVModeration;
>     at: 'articleCreate' put: #FVAdminArticle;
>     at: 'imageUpload' put: #FVImageUpload;
>     at: 'subscriptionAdmin' put: #FVAdminSubscriptions;
>     yourself.
>   content := FVAdminOptions new registry: self registry.
>   ^super initialize
>
> FVAdmin>>#renderContentOn: html
>   html heading level: 2; with: [
>    html text: 'Administration Area'].
>   self content: (self call: content)
>
> FVAdmin>>#content: aString
>   | cont |
>   cont := options
>     at: aString
>     ifAbsent: [self error: 'Incorrect Option Chosen: ', aString].
>   content := (Smalltalk at: cont) new registry: self registry
>
> FVAdminOptions>>#renderContentOn: html
>   html unorderedList with: [
>     html listItem with: [
>       html anchor
>         callback: [self answer: 'user'];
>         with: [html text: 'User Administration']].
>     html listItem with: [
>       html anchor
>         callback: [self answer: 'articleCreate'];
>         with: [html text: 'Create New/Edit existing Analysis Article']].
>     html listItem with: [
>       html anchor
>         callback: [self answer: 'imageUpload'];
>         with: [html text: 'Upload Images']].
>     html listItem with: [
>       html anchor
>         callback: [self answer: 'subscriptionAdmin'];
>         with: [html text: 'Administer Subscriptions']]]


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

Re: WAComponent>>#call:/#answer: usage question

John Thornborrow
Hi Damien,

Thanks, I did try a task, but I hit another problem with that which I
shall save for another day..

The scenario includes that I must have a link to reset the content
instvar via an anchor; which I failed to explain in my example.

So that means one of a few scenarios must be possible (or other that I
am not aware of, of course - and please note these are not demands, they
are merely user stories.)

1.) If using a WATask, I must be able to simultaneously #call: twice.
2.) The WATask must be able to render the Heading and Anchor.
3.) If I make a separate component for the heading and anchor, then
#render: those components, it must be able to #answer: for it's parent
component.

Now I am fully aware I could create a #parent:/#parent method on my
title object,  then use "self parent answer: 'foobar'", or simply render
the heading and anchor on every component (messy..) but I did think "I
surely cannot be the first person to encounter this?" thus I posted the
previous question :)

Best Regards,
John

Damien Cassou wrote:

> Hi John,
>
> 2007/8/21, John Thornborrow <[hidden email]>:
>> The below #renderContentOn: does not render, nor does the #call:'ed
>> component; I receive only a blank page.
>
>
> You must not send #call: during the rendering. Only during callbacks
> (after a click on a link for example). (Note for the others: I think
> this problem should be dealt with in the FAQ).
>
> You might probably want to use a WATask or change a bit the flow of
> your application. See documentation at http://www.seaside.st.
>
> A non-related note: use (Smalltalk classNamed: aSymbol) instead of
> (Smalltalk at: aSymbol). This is clearer.
>
>
>> I understand there have been some changes to the #call:/#answer:
>> methods, however I cannot find any reference to what I can use instead.
>>
>> Any assistance is appreciated, thanks.
>>
>> The code:
>>
>> ==
>> FVAdmin>>#initialize
>>   options _ Dictionary new
>>     at: 'user' put: #FVAdminUser;
>>     at: 'blogCreate' put: #FVBlogCreate;
>>     at: 'moderation' put: #FVModeration;
>>     at: 'articleCreate' put: #FVAdminArticle;
>>     at: 'imageUpload' put: #FVImageUpload;
>>     at: 'subscriptionAdmin' put: #FVAdminSubscriptions;
>>     yourself.
>>   content := FVAdminOptions new registry: self registry.
>>   ^super initialize
>>
>> FVAdmin>>#renderContentOn: html
>>   html heading level: 2; with: [
>>    html text: 'Administration Area'].
>>   self content: (self call: content)
>>
>> FVAdmin>>#content: aString
>>   | cont |
>>   cont := options
>>     at: aString
>>     ifAbsent: [self error: 'Incorrect Option Chosen: ', aString].
>>   content := (Smalltalk at: cont) new registry: self registry
>>
>> FVAdminOptions>>#renderContentOn: html
>>   html unorderedList with: [
>>     html listItem with: [
>>       html anchor
>>         callback: [self answer: 'user'];
>>         with: [html text: 'User Administration']].
>>     html listItem with: [
>>       html anchor
>>         callback: [self answer: 'articleCreate'];
>>         with: [html text: 'Create New/Edit existing Analysis Article']].
>>     html listItem with: [
>>       html anchor
>>         callback: [self answer: 'imageUpload'];
>>         with: [html text: 'Upload Images']].
>>     html listItem with: [
>>       html anchor
>>         callback: [self answer: 'subscriptionAdmin'];
>>         with: [html text: 'Administer Subscriptions']]]
>
>


Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: WAComponent>>#call:/#answer: usage question

Lukas Renggli
> 1.) If using a WATask, I must be able to simultaneously #call: twice.

That doesn't really make sense, because #call: replaces an entire
component with a new one.

In case you really want to change two components at once you can use
#show: that does not block (check out the comments of the methods
#call: and #show:).

> 2.) The WATask must be able to render the Heading and Anchor.

WATask does not render anything (check out the class comment). It just
delegates the rendering to a sequenze of other components.

> 3.) If I make a separate component for the heading and anchor, then
> #render: those components, it must be able to #answer: for it's parent
> component.

It looks like you need to compose your components, not to #call: them.
#call: is only useful if you expect to get back a result (read the
class comment of WAComponent).

HTH,
Lukas

--
Lukas Renggli
http://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: WAComponent>>#call:/#answer: usage question

John Thornborrow
Hi Lukas,

1.) Yes, I need something like #show: but I do require a result (via
#answer: would be the logical choice). There will of course only be one
answer at a time, but I want to present the options from two components
on the same page.

2.) I realise WATask does not render, hence my trial with WAComponent
subclass and #call:

3.) I am expecting a result; in FVAdminOptions>>#renderContentOn: it can
be noted that each listitem contains and anchor with a callback of "self
answer: 'foobar'". Each of these results in the rendering of a different
component in place of FVAdminOptions, which also #answer:.

I'm currently toying with a task, as it is the closest I have to what I
need, but it is restricting me from using a separate component for the
anchor which will be used to reset the content. In other words, I am
forced to implement the lines:

html heading
  level: 2;
  with: [html text: 'Administration Area'].
html anchor
  callback: [self answer: 'options'];
  with: [html text: '[Return to Options]']

in every class I have as options (currently 4, but there will be more.)
What I would like to achieve is to have that separated into it's own
component, but because of the callback: [self answer: 'options'] I
cannot do so.

Best regards,
John

www.pinesoft.co.uk


Lukas Renggli wrote:

>> 1.) If using a WATask, I must be able to simultaneously #call: twice.
>
> That doesn't really make sense, because #call: replaces an entire
> component with a new one.
>
> In case you really want to change two components at once you can use
> #show: that does not block (check out the comments of the methods
> #call: and #show:).
>
>> 2.) The WATask must be able to render the Heading and Anchor.
>
> WATask does not render anything (check out the class comment). It just
> delegates the rendering to a sequenze of other components.
>
>> 3.) If I make a separate component for the heading and anchor, then
>> #render: those components, it must be able to #answer: for it's parent
>> component.
>
> It looks like you need to compose your components, not to #call: them.
> #call: is only useful if you expect to get back a result (read the
> class comment of WAComponent).
>
> HTH,
> Lukas
>


Pinesoft Computers are registered in England, Registered number: 2914825. Registered office: 266-268 High Street, Waltham Cross, Herts, EN8 7EA



This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com

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

Re: WAComponent>>#call:/#answer: usage question

Damien Cassou-3
Hi John,

you may want to try to pass your root component to the child component
and modify the child to send a message to the root when the job is
done. The root display the default child if it has not get any answer
and something else otherwise. Am I clear enough?

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