How do I just redirect to another top-level component of Seaside?

New question. Google didn't help at all. Also, the problem that I have is pretty hard to explain properly.

I have two components in my application: JournalView and JournalEntryView. JournalView displays a list of journal entries with links to individual entries. When you click on each of these links, you need to create a new EventView log and redirect to this newly created JournalEntryView.

I am currently doing this:

html anchor callback: [ entryView := JournalEntryView new. entryView entry: anEntry. self call: entryView ]; with: '(read more)' ] 

The problem is that this code expects the newly created component to respond with a value later. Looking at the ghosting, I see the following hierarchy of components:

 JournalView WADelegation WAAnswerHandler JournalEntryView 

I do not want it. I want my EntryView Journal to be a top-level view, and I just want my bindings redirected to the new toplevel JournalEntryView.

Is this possible in Primorye?

+4
source share
3 answers

You can use ads. It should be something like this:

 ComponentA>>renderContentOn: html html anchor callback: [ self announce: (ViewEntryAnnouncement with: anEntry) ]; with: '(read more)' ]. 

then when you declare ComponentA. You are doing something like this:

 ParentComponent>>initialize super initialize. componentA := (ComponentA new on: ViewEntryAnnouncement do: [ :ann | | entryView | entryView := JournalEntryView new. entryView entry: ann entry. self call: entryView ]; yourself) 

This way you tell your parent that something happened and your parent can respond.

This approach works most of the time, but you need to add mechanisms for components to respond to declarations (they are not ready by default). If you can, it is best to approach to create your own Component class at the top of your hierarchy that can handle declarations. There are some examples (in Pharo) ...

Hope this helps :)

+4
source

You can replace the root component by calling accessor #rootPresenter: in the session. Not what you usually do, but it is possible.

 self requestContext rootPresenter: aComponent 
+1
source

Nm, a really strange question. Do not forget that Seaside is a web application platform and is not provided for displaying different static pages. Also, the basic idea of ​​Primorye is the concept of continuation, that is, something like a stream or chain. Thus, you have only one entry point to your web application. And to easily control the flow, it is recommended to use a task controller. See WATask and read here .

And by the way, its a very bad style to call from renderContentOn :.

+1
source

Source: https://habr.com/ru/post/1379261/


All Articles