Home Struts Struts2 Struts2uitags TabbedPanel (Ajax Tag) Example



TabbedPanel (Ajax Tag) Example
Posted on: October 25, 2007 at 12:00 AM
In this section, you will learn about the tabbedPanel tag. This is an Ajax component, where each tab is either a local content or a remote content (refreshed each time when user selects that tab).

TabbedPanel (Ajax Tag) Example

     

In this section, you will learn about the tabbedPanel tag. This is an Ajax component, where each tab is either a local content or a remote content (refreshed each time when  user selects that tab). 

To use tabbedPanel tag, the head tag must be included on the jsp page and must be configured for performance or debugging purposes. However, If you want to use the cookie feature then you must provide a unique id for the tabbedpanel component. This is used for identifying the name of component that is stored by the cookie.

Add the following code snippet into the struts.xml file.
struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
  "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
  <!-- Rose India Struts Tutorials -->
  <constant name="struts.enable.DynamicMethodInvocation" value="false" />
  <constant name="struts.devMode" value="true" />

  <package name="roseindia" namespace="/roseindia" extends="struts-default"> 

  <action name="TabbedPanel">
  <result>/pages/tabbedpanel.jsp</result>
  </action>

 <!-- Add actions here -->
  </package>


  <!-- Add packages here -->

</struts>

Create a jsp using the tag <s:tabbedPanel>. This tag is used for creating the tabs.
       

tabbedPane.jsp

<%taglib prefix="s" uri="/struts-tags" %>

<html>
  <head>
  <s:head theme="ajax" debug="true"/>
  </head>
  <body>
  <table border="1" width="50%">
  <tr>
  <td width="100%">

  <s:tabbedPanel id="test" >

  <s:div id="one" label="Tab 1" theme="ajax" labelposition="top" >
  This is the first panel.
  RoseIndia.nt<br>
  JavaJazzUp.com<br>
  NewsTrackIndia.com
  </s:div>

  <s:div id="two" label="Tab 2" theme="ajax">
  This is the second panel.
  </s:div>
  
  <s:div id="three" label="Tab 3" theme="ajax">
  This is the third panel.<br>
  Java Tutorial<br>
  PHP Tutorial<br>
  Linux Tutorial
  </s:div>

  <s:div id="four" label="Tab 4" theme="ajax">
  This is the forth panel.
  </s:div>

 </s:tabbedPanel>

 </td>
  </tr>
  </table>
  </body>
</html>

Output:

When you run the above example, you get the output as:

When you click the "Tab 2" then you get the content of "Tab 2" as shown:

If you click "Tab 3" then you get the content of "Tab 3" as shown:

If you click the "Tab 4" you get the content of "Tab 4" as:

     

Related Tags for TabbedPanel (Ajax Tag) Example:
cperformancedebuggingcomjspideormantformdebugincludecookiepageviuniquecomponenttagpanelbugidootabconfigjsifforietoconfigurefeatureposeusepemanceintabbedrmmheadntwanososjadclesagehowpropanuniqsrmanspdebginatpanekinceaandconfwantssthstabfeosesprndonomo


More Tutorials from this section

Ask Questions?    Discuss: TabbedPanel (Ajax Tag) Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.