Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Displaying Tabular data using custom tags

 
jai walia
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

I am planning to write a custom tag which will display content in a typical tabular format plus paging and ordering.
My question is which way I should follow: Simple Tag(JSP2) or Classical Tags ? Also, I my creating the portal using MVC arch, so therefore I cannot go for JSTL db_access tag and <c:forEach> for printing as HTML table.

How can I achieve this using tags + MVC architecture?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"jai", please check your private messages for an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you not use the SimpleTag support mechanisms? Is therre something you plan to dothat doesn't fit into that?

And of course you can use JSTL tags, just not the SQL tags.
 
Arvind Mahendra
Ranch Hand
Posts: 1162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can accomplish everything you mentioned with just JSTL if you wanted.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not if he wants to adhere to modern best practices -- such as MVC structure. Doing SQL on a JSP, with or without JSTL, is not a recommended practice.
 
jai walia
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,Arvind for the comments.

Lets have some clear picture: There is a link [List Customers], which calls a servlet, do the processing and stores a ArrayList request attribute 'custList' and forwarded to list.jsp.

Here I can display all the emp details. but the problem is that all the static header viz. CustName,CustCity etc has to be do hardcoded in jsp, and which I really don't want.

I want some tag something like: <tisplayTable header = ".." data = ".."/>

Also I dont want to do any SQL processing in the view side (As per the MVC design).
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jai walia:
Here I can display all the emp details. but the problem is that all the static header viz.


Jai, please use real words when posting to the ranch.

"emp" is not a word in the English language and I have no idea what "viz" means.


Great decision not to use JSTL SQL tags.
As you've said, they have no place in an application that adheres to MVC.
 
jai walia
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ben, that was important (imp) not "emp" and viz means for example.
anyways..... ;)
Here is my small part of DAO code which return customer (cust) array list:

public static ArrayList <String> getCustomerList()
{
ArrayList <String> custList= new ArrayList();
ArrayList <String> custHeader= new ArrayList();

// DB connection code goes here ....

sql = "SELECT sCustId AS CustId,sCustName AS CustName,sCustCity AS CustCity FROM cust_master";
ResultSetMetaData meta = pStmt.getMetaData();
for(int j=1;j<=meta.getColumnCount();j++)
{
custList.add(meta.getColumnLabel(j));
}
if(totalRecords > 0)
{
while(rs.next())
{
CustomerTO custTO = new CustomerTO(); // Transfer Objects or Value Objects
custTO.setCustLoginId(rs.getString("CustId"));
custTO.setCustName(rs.getString("CustomerName"));
custTO.setCustCity(rs.getString("CustCity"));
custList.add(custTO);
}
}
return custList
}

Now I want to know how to add the metadata as a column header in the list or other collection with all customer details. In Short:

One Collection (custCollection) = Column Names + Customer Data

and in jsp by using "custCollection" I must be able to print the column headers and the customer data.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic