You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Michael Jouravlev <jm...@gmail.com> on 2006/01/30 01:13:53 UTC

[ANN] Tabbed notebooks in Struts/JSP or in pure JSP with new release of JSP Controls Tag Library

Well, finally I found time to encapsulate HTML into some tags. Wendy,
roles work too :-)

To build your own tabbed notebook you need to download tag library
version 0.4 from here:
http://sourceforge.net/project/showfiles.php?group_id=154342&package_id=171420&release_id=389310

Please, download samples and examine /tabs directory, it contains the
samples you need. You MUST create a separate JSP file for your tabbed
notebook. This JSP will be used as target for requests. You MUST
process tab change events on input phase, and set/obtain view name on
render phase.

The simplest three-tab notebook looks like this:

<%@ page import="net.jspcontrols.util.Constants"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://jspcontrols.net/tags/core" prefix="jc" %>
<%@ taglib uri="http://jspcontrols.net/tags/tabcontrol" prefix="jc-tab" %>

<span id="TigrisTabComponent_def">

<%-- Accept phase, either postback or regular link containing an event --%>

  <jc:accept>
    <jc:handler event="tab1event">
      <% session.setAttribute("tabsetOneCurrentTab", "tab1"); %>
    </jc:handler>
    <jc:handler event="tab2event">
      <% session.setAttribute("tabsetOneCurrentTab", "tab2"); %>
    </jc:handler>
    <jc:handler event="tab3event">
      <% session.setAttribute("tabsetOneCurrentTab", "tab3"); %>
    </jc:handler>
  </jc:accept>

<%-- Prerender phase: store reload address; fixup response header --%>

  <jc:prerender/>

<%-- Render Phase: render tabs --%>

  <jc-tab:tabcontrol styleClass="tigristabs">
    <jc-tab:tabpage default="true" viewKey="tabsetOneCurrentTab" view="tab1">
      <jc-tab:tabgrip event="tab1event" value="Tab1"/>
      <jc-tab:tabpanel>
          <p>Content of the first tab panel goes here.</p>
      </jc-tab:tabpanel>
    </jc-tab:tabpage>
    <jc-tab:tabpage viewKey="tabsetOneCurrentTab" view="tab2">
      <jc-tab:tabgrip event="tab2event" value="Tab2"/>
      <jc-tab:tabpanel>
          <p>Content of the second tab panel goes here.</p>
      </jc-tab:tabpanel>
    </jc-tab:tabpage>
    <jc-tab:tabpage viewKey="tabsetOneCurrentTab" view="tab3"
roles="admin, manager, tabtest1">
      <jc-tab:tabgrip event="tab3event" value="Tab3"/>
      <jc-tab:tabpanel>
          <p>Content of the third tab panel goes here.</p>
      </jc-tab:tabpanel>
    </jc-tab:tabpage>
  </jc-tab:tabcontrol>

</span>

Then you include your component into composite page like this:

    <div id="TigrisTabComponent" style="width: 500px;">
      <jsp:include page="tigrisTabComponent.jsp"/>
    </div>

This is it. It works with Javascript turned off, or in Ajax mode with
Javascript turned on. See live demo here:
http://www.superinterface.com/jspcontrols/tabcontrol/index.jsp

--
Michael Jouravlev.
JSP Controls: http://jspcontrols.sourceforge.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [ANN] Tabbed notebooks in Struts/JSP or in pure JSP with new release of JSP Controls Tag Library

Posted by Michael Jouravlev <jm...@gmail.com>.
On 1/29/06, Paul Benedict <pa...@yahoo.com> 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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [ANN] Tabbed notebooks in Struts/JSP or in pure JSP with new release of JSP Controls Tag Library

Posted by Paul Benedict <pa...@yahoo.com>.
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. 
  
  Paul
  


			
---------------------------------
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new and used cars.