Using "anchor goto:" to apply a command and switch to a different view

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

Using "anchor goto:" to apply a command and switch to a different view

Nick Brown
Folks,

I'm running Pier from the piercms.com one click image, and writing my
own structure and view subclasses, etc.

I'm wanting to produce an anchor which when clicked, will perform a
command and then switch to a different view.

I can do either one of those things, but seemingly not both. My
assumption was that I'd need to write something like the following,
where #view: is sent to the result of #command: ...

html anchor
     goto: (
         (self context command: MyCommandClass new) view: MyViewClass
     );
     with: 'click me'.

But I find that while this code takes me to the new view, the command is
never executed.

Is there an established way to do this? If not, I'd appreciate any ideas
on the best approach. It occurs to me that I could subclass the view
command and put my desired command behaviour in that.

Cheers,
Nick Brown
_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Using "anchor goto:" to apply a command and switch to a different view

Lukas Renggli
On 13 April 2010 15:19, Nick Brown <[hidden email]> wrote:

> Folks,
>
> I'm running Pier from the piercms.com one click image, and writing my own
> structure and view subclasses, etc.
>
> I'm wanting to produce an anchor which when clicked, will perform a command
> and then switch to a different view.
>
> I can do either one of those things, but seemingly not both. My assumption
> was that I'd need to write something like the following, where #view: is
> sent to the result of #command: ...
>
> html anchor
>    goto: (
>        (self context command: MyCommandClass new) view: MyViewClass
>    );
>    with: 'click me'.
>
> But I find that while this code takes me to the new view, the command is
> never executed.

A view has its own nop-command, namely PRViewCommand. So just goto
MyCommandClass and make sure that MyCommandClass answers to your view
after performing the command. To do this override #doAnswer in your
command and set the context to your custom view.

MyCommandClass>>doAnswer
     self answer: (self context view: MyViewClass)

Lukas



>
> Is there an established way to do this? If not, I'd appreciate any ideas on
> the best approach. It occurs to me that I could subclass the view command
> and put my desired command behaviour in that.
>
> Cheers,
> Nick Brown
> _______________________________________________
> Magritte, Pier and Related Tools ...
> https://www.iam.unibe.ch/mailman/listinfo/smallwiki
>



--
Lukas Renggli
www.lukas-renggli.ch

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: Using "anchor goto:" to apply a command and switch to a different view

Nick Brown
Lukas Renggli wrote:

>
> A view has its own nop-command, namely PRViewCommand. So just goto
> MyCommandClass and make sure that MyCommandClass answers to your view
> after performing the command. To do this override #doAnswer in your
> command and set the context to your custom view.
>
> MyCommandClass>>doAnswer
>      self answer: (self context view: MyViewClass)
>
> Lukas
>
>  

Ahh. Thanks Lukas.

-Nick

_______________________________________________
Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki