• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Displaying Tabular data using custom tags

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"jai", please check your private messages for an important administrative matter.
 
Bear Bibeault
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can accomplish everything you mentioned with just JSTL if you wanted.
 
Bear Bibeault
Sheriff
Posts: 67641
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: <t:DisplayTable header = ".." data = ".."/>

Also I dont want to do any SQL processing in the view side (As per the MVC design).
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic