On 1/29/06, Paul Benedict <[EMAIL PROTECTED]> wrote:
> This is awesome!!! Since Struts doesn't have  portlet support, using JSP to 
> emulate
> it is second to none. Portlets  are nothing but a subset of the servlet 
> request anyway,
> so you're doing  some great work.
>
>  I'd like to see an example where you connect this all up to Struts.

My library works with Struts but uses a pattern different to
traditional Struts "send request to an action, forward to JSP"
approach. Instead, request is sent to JSP file, which calls Struts
action if needed.

Say, you have a composite page that contains several components. In
this case, the composite page can be displayed in a traditional way:
you send request to the action, which forwards to the JSP file. This
JSP files contains <jsp:include> elements for every component on a
page.

Each component is called in a inverted fashion, kind of like "view
helper" pattern, but in my case every JSP file corresponding to a
component can process input as well, not just render a view. Please,
take a look at component lifecycle on project website, I tried to make
it readable: http://jspcontrols.sourceforge.net/jsptaglib/lifecycle/index.html

Each component has two sections: accept and render. On every request
Accept tag checks is it an event (it contains input data) or just a
request for render. If it is an event, then the body of Accept tag is
evaluated, here you can stick call to Struts action. Please, see this
section: http://jspcontrols.sourceforge.net/jsptaglib/struts.html . I
encourage you to download samples, there are just few of them, there
is one that uses Struts for input processing.

The render portion of JSP file contains one or several views, each
view is selected depending on component state. If you use Struts, you
may want to store state in session-scoped ActionForm ;-) Because
decision which subview to display is chosen in JSP file, there is no
need to define view mappings in struts config file.

I will modify the venerable MailReader to show how this works in a
real application.

I think that benefit of my approach to JSP components is that they
work in both sync and async modes, and the source code should not be
changed. The catch is that composite page should allow to refresh
itself, and it should not produce side effects on refresh. This is
important in sync mode when component redirects to composite page to
reload it.

---
Michael Jouravlev

JSP Controls:Create page components with JSP
http://jspcontrols.sourceforge.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to