I like this idea a lot. It helps to have a page-level
component in which certain events trigger methods at
various times in the request-response loop. This idea
is somewhat like the "components" in WebObjects. Every
template is bound to a component class, and all the
components have a common superclass.

-Harris


--- James Klicman <[EMAIL PROTECTED]> wrote:

> The key benefits of Pagelets would be:
>
>   * Having a non-intrusive interface that JSP beans
> can optionally
>     implement.
>   * Ability to create Servlet and JSP aware beans.
>   * Beans that can cleanup after itself.
>   * Pagelets would be thread-safe since a Pagelet
> can only be
>     associated with one page at a time.
>   * A place to put processRequest
>
>
> Here is what the Pagelet interface can look like:
> - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - -
> - - - -
> package javax.servlet.jsp;
>
> public interface Pagelet {
>
>         /**
>          * Initializes the pagelet. Pagelets have a
> lifespan of page.
>          * destroy() is called at the end of
> _jspService.
>          */
>         public void init(PageContext pageContext);
>
>         /**
>          * <p>This method gives the pagelet an
> opportunity
>          * to clean up any resources that are being
> held (for example,
>          * jdbc connections)
>          */
>         public void destroy();
>
>
>         /**
>          * Backwards compatibility, init(PageContext
> pageContext) would
>          * replace it.
>          *
>          * @deprecated
>          */
>         public void
> processRequest(HttpServletRequest request);
> }
> - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - -
> - - - -
>
>
> Here are Pagelets in action:
> - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - -
> - - - -
> <jsp:useBean id="jdbcConnection" scope="page"
> class="pagelets.JdbcConnection"/>
> <jsp:useBean id="allUsers" scope="page"
> class="pagelets.AllUsers"/>
> <jsp:useBean id="allGroups" scope="page"
> class="pagelets.AllGroups"/>
>
> <html>
> All Users:<br>
> <ol>
> <%
>         String[] users = allUsers.getUsers();
>         for (int i = 0; i < users.length; i++) {
> %>
> <li> <%= users[i] %>
> <%
>         }
> %>
> </ol>
> <p>
>
> All Groups:<br>
> <ol>
> <%
>         String[] groups = allGroups.getGroups();
>         for (int i = 0; i < groups.length; i++) {
> %>
> <li> <%= groups[i] %>
> <%
>         }
> %>
> </ol>
>
> </html>
> - - - - - - - - - - - - - - - - - - - - - - - - - -
> - - - - - - - - - -
> - - - -
>
> How Pagelets benefit us in this example would be
> automatic clean up of
> the JDBC connection and the ability to invisibly
> share the connection.
> The Pagelet jdbcConnection would have its destroy()
> method called at
> the end of _jspService and would then close the
> connection.  Meanwhile
> both allUsers and allGroups could have used the
> database connection
> that jdbcConnection created and made available
> through the
> request.setAttribute().
>
>
> I think Pagelets can consolidate and provide some
> features that people
> have been asking for on the JSP list. One being
> processRequest
> functionality and another being Thread-Safe beans,
> and my personal
> favorite automatic bean cleanup.
>
> -James Klicman
>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to