Conditionally loading/displaying a component

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

Conditionally loading/displaying a component

sergio_101
I have a very trivial application that I am working on right now.

It has one form. Upon submission of the form, it gathers information from a few different APIs, and builds an ordered collection of results.

It has another component that displays the results of this component. I only want this component to be visible when there are results from the form submission.

How would I plumb up the the results component to render only when there are results from the form submission?

The form throws the values from the form into session. Is it bad practice for the results component just to watch the session, and if there is some information there, gather the results and render itself?

Is it bad practice to use the session as a sort of “Brain” for the application, in the same way we might use services in Angular?

Thanks!

----
peace,
sergio
photographer, journalist, visionary


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

Re: Conditionally loading/displaying a component

JupiterJones
Does the first component still display along with the results? (to allow the user to change values)

If so, you can just store the second component in an instance variable of the first component. Maybe store the results as an instance variable of the second component. The first component can collect the results and set them in the second component. That way the second component can choose if it has to display anything based on its results instance variable.

I’m sure some people will say it’s bad practise to use the session as a dumping ground for non-session related data.

There are, of course, so many ways of doing this. It’s just what makes sense for your application.

Cheers,

J

On 24 Jan 2019, at 12:37 am, sergio ruiz <[hidden email]> wrote:

I have a very trivial application that I am working on right now.

It has one form. Upon submission of the form, it gathers information from a few different APIs, and builds an ordered collection of results.

It has another component that displays the results of this component. I only want this component to be visible when there are results from the form submission.

How would I plumb up the the results component to render only when there are results from the form submission?

The form throws the values from the form into session. Is it bad practice for the results component just to watch the session, and if there is some information there, gather the results and render itself?

Is it bad practice to use the session as a sort of “Brain” for the application, in the same way we might use services in Angular?

Thanks!

----
peace,
sergio
photographer, journalist, visionary

_______________________________________________
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: Conditionally loading/displaying a component

sergio_101
the form would moved somewhere completely different when the results are rendered… i don’t think a parent child configuration would work..

On January 23, 2019 at 10:17:10 PM, Jupiter Jones ([hidden email]) wrote:

Does the first component still display along with the results? (to allow the user to change values)
----
peace,
sergio
photographer, journalist, visionary


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

Re: Conditionally loading/displaying a component

JupiterJones
Without knowing the structure, I’d just be guessing at solutions :)

There’s no reason you can’t use the session. Perhaps an “application” object accessible from the session? It can house all your application logic. Maybe that would work as a kind of “brain” for your app.

Cheers,

J

On 24 Jan 2019, at 2:42 pm, sergio ruiz <[hidden email]> wrote:

the form would moved somewhere completely different when the results are rendered… i don’t think a parent child configuration would work..

On January 23, 2019 at 10:17:10 PM, Jupiter Jones ([hidden email]) wrote:

Does the first component still display along with the results? (to allow the user to change values)
----
peace,
sergio
photographer, journalist, visionary

_______________________________________________
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: Conditionally loading/displaying a component

sergio_101
Thanks!

This is exactly what I ended up doing.. 

the session points to a brain object that holds the data.

As most of the information is generated from the brain data, the brain data itself if just a few strings.


On January 23, 2019 at 11:25:56 PM, Jupiter Jones ([hidden email]) wrote:

There’s no reason you can’t use the session. Perhaps an “application” object accessible from the session? It can house all your application logic. Maybe that would work as a kind of “brain” for your app.
----
peace,
sergio
photographer, journalist, visionary


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