At 01:54 PM 10/31/2001 -0600, Ian Bicking wrote:
>Someone else brought up this technique, so maybe someone has a good
>trick for how it should work.
>
>I want to do the technique where some actions give a message back to
>the user -- many times these actions immediately redirect to a more
>useful page, which should then display the results. So I can store
>the messages in a session variable, and clear them out when I later
>display them.
>
>However, sometimes I don't redirect after the action, and I'd like
>those messages to then display at the top of the page.
>
>So, if I do the standard write-start-page, write-page, write-end-page,
>then I can't do this, because the start of the page is where I want
>those status messages, but they don't get generated until the second
>step.
>
>I could require that anything that will display an immediate status
>message should do so in awake, but that seems too difficult. I'd
>almost prefer to reorganize Page if it really is necessary.
Why is it too difficult to do the computations in awake()?
My first thought is that you are mixing computations with display and that
is causing the problem. Of course, it's easy for me to say that with no
example on hand. Perhaps you can provide one?
My second thought is that this problem doesn't occur in a GUI, because the
display does not have to be sequential. Now for a web page, the _delivery_
has to be sequential, so if you ever came up with a non-sequential version
of page, you would have compute all results in memory and then deliver. If
you're willing to live with that, we could explore a non-sequential display
model.
The question is, would you live with that limitation?
Thinking aloud about such a design, your page could construct a list of
Spans, each of which is mutable string-like object with a name. The sum of
these spans represents your page content.
Each span would respond to write(), writeln(), set(), clear(), name(),
surround(pre, post), etc.
So at any point in your servlet, you could say something like:
self.span('message').set(errorMsg)
...
self.span('message').surround('<span class=error>', '</span>')
...
if someCondition:
self.span('body').clear()
...
self.span('body').write('<p> And here is some more text')
Then upon delivery, the page concatenates all the span content() together.
Other possibilities include:
* Making spans hierarchical/nested.
* Convenience methods to add or remove spans:
self.insertSpan('footer', Span('status bar'))
# the index is a name, so the the new span is inserted
# before the named span
Just an idea off the top of my head,
-Chuck
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss