More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Creating Table in Echo3

                         

Table is a way to present data into the tabular format. You can also create tables in Echo3 by using the class Table, provided in the nextapp.echo.app package. There are four constructors provided for creating a table in Echo3 as given below:

  • Table() default constructor, will create a new Table with an empty DefaultTableModel
  • Table(int columns, int rows) will creates a new Table with a new DefaultTableModel with the specified rows and columns
  • Table(TableModel model) will creates a new Table using the provided TableModel
  •  Table(TableModel model, TableColumnModel columnModel) creates a new Table with the provided TableModel and the specified TableColumnModel.

In this example of creating Table in Echo3 we have created a simple application into which the Table with the DefaultTableModel will be added to the window pane when the user clicks on the button "Add Table".

TableServlet.java

package table;

import nextapp.echo.app.ApplicationInstance;
import nextapp.echo.webcontainer.WebContainerServlet;

public class TableServlet extends WebContainerServlet {

    public ApplicationInstance newApplicationInstance() {
        return new TableApp();
    }
}

TableApp.java

package table;

import nextapp.echo.app.ApplicationInstance;
import nextapp.echo.app.ContentPane;
import nextapp.echo.app.Label;
import nextapp.echo.app.Window;
import nextapp.echo.app.*;


import nextapp.echo.app.event.ActionListener;
import nextapp.echo.app.event.ActionEvent;

public class TableApp extends ApplicationInstance {
    
    private Table table;
    private ContentPane contentPane;
    private WindowPane windowPane;

    public Window init() {
        Window window = new Window();
    window.setTitle("Creating Table");
    table=new Table(4,4);
    table.setBorder(new Border(2,Color.BLUE,Border.STYLE_SOLID));
    contentPane = new ContentPane();
    windowPane = new WindowPane();
         Button add=new Button("Add Table ");
    add.setBorder(new Border(2,Color.BLUE,Border.STYLE_SOLID));
    contentPane.add(add);
    contentPane.add(windowPane);
    add.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e)
     {
         windowPane.setTitle("Table Example");
         windowPane.add(table);
     }
   });    
    window.setContent(contentPane);
        return window;
    }  

One more important thing to do is the mapping of TableServlet in the deployment descriptor web.xml as given below:

<!DOCTYPE web-app 
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<servlet>
<servlet-name>TableServlet</servlet-name>
<servlet-class>table.TableServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>TableServlet</servlet-name>
<url-pattern>/app/table</url-pattern>
</servlet-mapping>

</web-app>

Output:

To run this application download source code and deploy it into the Web Server (e.g Tomcat Server) and type the following URL into the address bar as http://localhost:8080/echo3/app/table

Click on "Add Table" button.

Download Project Source Code

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Join and Excel yourself with our Online instructor led training sessions
Training Courses
Tell A Friend
Your Friend Name

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.