3.2.0

TagLib for ActiveWidgets Grid

Guys, I'm working on TagLib for ActiveWidgets Grid. Basic functionalities are coded already and tested too. Wanting bit more feedback from the community before releasing the TagLib.

TLD:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
  <tlib-version>1.0</tlib-version>
  <jsp-version>1.2</jsp-version>
  <short-name>grid</short-name>
  <uri>http://thej2ee.com/taglib/grid</uri>
  <display-name>ActiveWidgets Grid Taglib</display-name>
  <description>
    This is JSP TagLib implementation of ActiveWidgets Grid
  </description>

  <tag>
    <name>grid</name>
    <tag-class>com.thej2ee.grid.GridTag</tag-class>
    <body-content>empty</body-content>
    <description>
      This instantiates a ActiveWidgets Grid.
    </description>
    <attribute>
      <name>id</name>
      <required>true</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
      <name>columnCount</name>
      <required>true</required>
      <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>

  <tag>
    <name>header</name>
    <tag-class>com.thej2ee.grid.HeaderTag</tag-class>
    <body-content>JSP</body-content>
    <description>
      This holds grid header.
      </description>
    <attribute>
      <name>name</name>
      <required>true</required>
      <rtexprvalue>true</rtexprvalue>
      <description>
        Same id given in earlier grid declaration &lt;grid:grid id="myGrid" columnCount="5" /&gt;
      </description>
    </attribute>
  </tag>

  <tag>
    <name>data</name>
    <tag-class>com.thej2ee.grid.DataTag</tag-class>
    <body-content>JSP</body-content>
    <description>
      This holds grid data rows.
      </description>
    <attribute>
      <name>name</name>
      <required>true</required>
      <rtexprvalue>true</rtexprvalue>
      <description>
        Same id given in earlier grid declaration &lt;grid:grid id="myGrid" columnCount="5" /&gt;
      </description>
    </attribute>
  </tag>

  <tag>
    <name>row</name>
    <tag-class>com.thej2ee.grid.RowTag</tag-class>
    <body-content>JSP</body-content>
    <description>
      This holds a data row.
    </description>
  </tag>

  <tag>
    <name>item</name>
    <tag-class>com.thej2ee.grid.ItemTag</tag-class>
    <body-content>JSP</body-content>
    <description>
      This holds a data cell.
    </description>
    <attribute>
      <name>index</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
      <description>
        Sets the item index in a row.
        Default value is one higher than highest used before.
      </description>
    </attribute>
    <attribute>
      <name>trim</name>
      <description>
        Trims the content and JS encode it.
        Options are 'true' and 'false' - default is 'true'.
      </description>
    </attribute>
  </tag>

  <tag>
    <name>write</name>
    <tag-class>com.thej2ee.grid.WriteTag</tag-class>
    <body-content>JSP</body-content>
    <description>
      This writes grid content in javascript array.
    </description>
    <attribute>
      <name>name</name>
      <required>true</required>
      <rtexprvalue>true</rtexprvalue>
      <description>
        Same id given in earlier grid declaration &lt;grid:grid id="myGrid" columnCount="5" /&gt;
      </description>
    </attribute>
    <attribute>
      <name>trim</name>
      <description>
        Compress the generated code (may not be readable).
        Options are 'true' and 'false' - default is 'false'.
      </description>
    </attribute>
    <attribute>
      <name>writeLibrary</name>
      <description>
        Options are 'true' and 'false' - default is 'false'.
      </description>
    </attribute>
    <attribute>
      <name>writeHeader</name>
      <description>
        Options are 'true' and 'false' - default is 'true'.
      </description>
    </attribute>
    <attribute>
      <name>writeData</name>
      <description>
        Options are 'true' and 'false' - default is 'true'.
      </description>
    </attribute>
    <attribute>
      <name>writeGrid</name>
      <description>
        Options are 'true' and 'false' - default is 'true'.
      </description>
    </attribute>
  </tag>

</taglib>


JSP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" 
%><%@ taglib uri="http://thej2ee.com/taglib/grid" prefix="grid" 
%><%@ page language="java" import="java.lang.*,java.util.*"
%>
<html>

  <head>
    
    <title> Grid Tag Test </title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    
    <meta http-equiv="keywords" content="mytag,trim,thej2ee">
    <meta http-equiv="description" content="This is my test page">
    
    <link rel="stylesheet" type="text/css" href="style.css"> 
    
  </head>
  
  <body>

    This is my Grid Tag.
    
    <grid:grid id="myGrid" columnCount="5" />
    <grid:header name="myGrid">
      <grid:item> Ticker </grid:item>
      <grid:item> Company Name </grid:item>
      <grid:item> Market Cap. </grid:item>
      <grid:item> $ Sales </grid:item>
      <grid:item> Employees </grid:item>
    </grid:header>
    <grid:data name="myGrid">
      <grid:row>
        <grid:item> MSFT </grid:item>
        <grid:item> Microsoft Corporation </grid:item>
        <grid:item> 314,571.156 </grid:item>
        <grid:item> 32,187.000 </grid:item>
        <grid:item> 55000 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> ORCL </grid:item>
        <grid:item> Oracle Corporation </grid:item>
        <grid:item> 62,615.266 </grid:item>
        <grid:item> 9,519.000 </grid:item>
        <grid:item> 40650 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> SAP </grid:item>
        <grid:item> SAP AG (ADR) </grid:item>
        <grid:item> 40,986.328 </grid:item>
        <grid:item> 8,296.420 </grid:item>
        <grid:item> 28961 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> CA </grid:item>
        <grid:item> Computer Associates Inter </grid:item>
        <grid:item> 15,606.335 </grid:item>
        <grid:item> 3,164.000 </grid:item>
        <grid:item> 16000 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> ERTS </grid:item>
        <grid:item> Electronic Arts Inc. </grid:item>
        <grid:item> 14,490.895 </grid:item>
        <grid:item> 2,503.727 </grid:item>
        <grid:item> 4000 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> SFTBF </grid:item>
        <grid:item> Softbank Corp. (ADR) </grid:item>
        <grid:item> 14,485.840 </grid:item>
        <grid:item> .000 </grid:item>
        <grid:item> 6865 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> VRTS </grid:item>
        <grid:item> Veritas Software Corp. </grid:item>
        <grid:item> 14,444.272 </grid:item>
        <grid:item> 1,578.658 </grid:item>
        <grid:item> 5647 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> SYMC </grid:item>
        <grid:item> Symantec Corporation </grid:item>
        <grid:item> 9,932.483 </grid:item>
        <grid:item> 1,482.029 </grid:item>
        <grid:item> 4300 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> INFY </grid:item>
        <grid:item> Infosys Technologies Ltd. </grid:item>
        <grid:item> 9,763.851 </grid:item>
        <grid:item> 830.748 </grid:item>
        <grid:item> 15400 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> INTU </grid:item>
        <grid:item> Intuit Inc. </grid:item>
        <grid:item> 9,702.477 </grid:item>
        <grid:item> 1,650.743 </grid:item>
        <grid:item> 6700 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> ADBE </grid:item>
        <grid:item> Adobe Systems Incorporate </grid:item>
        <grid:item> 9,533.050 </grid:item>
        <grid:item> 1,230.817 </grid:item>
        <grid:item> 3341 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> PSFT </grid:item>
        <grid:item> PeopleSoft, Inc. </grid:item>
        <grid:item> 8,246.467 </grid:item>
        <grid:item> 1,941.167 </grid:item>
        <grid:item> 8180 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> SEBL </grid:item>
        <grid:item> Siebel Systems, Inc. </grid:item>
        <grid:item> 5,434.649 </grid:item>
        <grid:item> 1,417.952 </grid:item>
        <grid:item> 5909 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> BEAS </grid:item>
        <grid:item> BEA Systems, Inc. </grid:item>
        <grid:item> 5,111.813 </grid:item>
        <grid:item> 965.694 </grid:item>
        <grid:item> 3063 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> SNPS </grid:item>
        <grid:item> Synopsys, Inc. </grid:item>
        <grid:item> 4,482.535 </grid:item>
        <grid:item> 1,169.786 </grid:item>
        <grid:item> 4254 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> CHKP </grid:item>
        <grid:item> Check Point Software Tech </grid:item>
        <grid:item> 4,396.853 </grid:item>
        <grid:item> 424.769 </grid:item>
        <grid:item> 1203 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> MERQ </grid:item>
        <grid:item> Mercury Interactive Corp. </grid:item>
        <grid:item> 4,325.488 </grid:item>
        <grid:item> 444.063 </grid:item>
        <grid:item> 1822 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> DOX </grid:item>
        <grid:item> Amdocs Limited </grid:item>
        <grid:item> 4,288.017 </grid:item>
        <grid:item> 1,427.088 </grid:item>
        <grid:item> 9400 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> CTXS </grid:item>
        <grid:item> Citrix Systems, Inc. </grid:item>
        <grid:item> 3,946.485 </grid:item>
        <grid:item> 554.222 </grid:item>
        <grid:item> 1670 </grid:item>
      </grid:row>
      <grid:row>
        <grid:item> KNM </grid:item>
        <grid:item> Konami Corporation (ADR) </grid:item>
        <grid:item> 3,710.784 </grid:item>
        <grid:item> .000 </grid:item>
        <grid:item> 4313 </grid:item>
      </grid:row>
    </grid:data>

    <grid:write name="myGrid" />
    
  </body>
  
</html>


Result is very much similar to simple.htm example !!!

<grid:item>Microsoft Corporation</grid:item>
or
<grid:item> Microsoft Corporation </grid:item>
or
<grid:item> Microsoft 
Corporation </grid:item>
or
<grid:item>
  Microsoft Corporation
</grid:item>
or
<grid:item>
  Microsoft
  Corporation
</grid:item>


All of the above will produce same result (i.e. "Microsoft Corporation") :-D This makes it easily workable with JSTL even maintaining better code formatting and readability.

---
Sudhaker Raj
Sudhaker Raj
July 27,
The main reason of writing this tag was code readability, standardization and JSTL integration. Following is JSTL powered code for the same.

<grid:grid id="myGrid" columnCount="5" /> 

<grid:header name="myGrid"> 
  <grid:item> Ticker </grid:item> 
  <grid:item> Company Name </grid:item> 
  <grid:item> Market Cap. </grid:item> 
  <grid:item> $ Sales </grid:item> 
  <grid:item> Employees </grid:item> 
</grid:header> 

<grid:data name="myGrid">
<c:forEach var="company" items="${companies}">
  <grid:row>
    <grid:item><c:out value="${company.ticker}" /></grid:item>
    <grid:item><c:out value="${company.name}" /></grid:item>
    <grid:item><c:out value="${company.marketCap}" /></grid:item>
    <grid:item><c:out value="${company.sales}" /></grid:item>
    <grid:item><c:out value="${company.employees}" /></grid:item>
  </grid:row>
</c:forEach>
</grid:data>

<grid:write name="myGrid" />


Specify index if setting items out of order

...
<grid:data name="myGrid">
<c:forEach var="company" items="${companies}">
  <grid:row>
    <grid:item index="1">
      <c:out value="${company.name}" />
    </grid:item>
    <grid:item index="0">
      <c:out value="${company.ticker}" />
    </grid:item>
    <%-- item index will continue from largest used before --%>
    <grid:item><c:out value="${company.marketCap}" /></grid:item>
    <grid:item><c:out value="${company.sales}" /></grid:item>
    <grid:item><c:out value="${company.employees}" /></grid:item>
  </grid:row>
</c:forEach>
</grid:data>
...


Sudhaker Raj
July 27,
Things will be added soon

Enable row mouseover effect
Enable/disable sorting
Enable/disable resizing
Enable/disable arrow key nevigation
Enable 'no select'/'single select'/'multi select' property
Row selection related event handler.
Columns to display (with order)
Columns width (should be here or leave it for CSS?)
Rows to diplay
Support for custom code

Which one looks more logical place to put these aatributes?
grid:grid or grid:write ?

Sudhaker Raj
July 27,
Firslty - I look forward to seeing the results of this - let me know if you need help testing this out.

As for your last question, I would put all of the config/setup attributes in the grid:grid tag, and leave the grid:write as a simple tag
Dean
August 5,
Hy can you try and create a grid based on the the JSF (Java Server Faces )Tag-libs.... it is like JSTL but it is more comprehensive (it is the future of taglibs...)....... I willl help you if you like , we can work together We can try .... at least... I have written some components using TAGlib and JSF TAGLIB please caontact me at costin@prodinf.ro or costin_a@hotmail.com
Plastik
August 7,

Basic taglib is tested and working fine. Enhancement mentioned in 3rd post is under progress during my free times as my manager didn't approve the enhancement (we have other things to do first). I was confused in choosing the multiple way of implementing it.

1. Printing raw JS code inside java code
2. Template file using JSTL (java will set grid object and JSTL will render JS code)
3. Any light weight template engine (java.text.MessageFormat or something else), JS code is inside some resource bundle.

I will have to take a look at JSF before saying anything about it. Heard a lot about it!!!

It's great that I'm getting a team ;-) Should we reserve a sourceforge project for it? Or try to merge with the same project.

Grid itself is the greatest thing for most of us :-D But without a standard server side library, it’s not very easy to implement it in practical purposes.

I am also planning Smarty (http://smarty.php.net) plug-in for this Grid, which can make PHP developer’s life also easy (I like PHP equally).
Sudhaker Raj
August 9,
Hi Sudhaker.

Just wondering how the development of this was coming? I have a struts project where I'd like to include the grid. Will your taglib work with struts?

Regards,
Brian Fredette
August 18,

Yes, It will !!! Struts encourages people to write beans and hence JSTL enabled code. So, I thing this library will be a ‘Must Have’ for anyone using Struts and ActiveWidgets grid.

Struts or any framework usually forwards request to some JSP (View). This TagLib will fit in JSP and save you from writing complex code required to generate JavaScript header array, data array and grid code. When using JSTL, it generates output with lots of blanks and new-lines, which is not liked by JavaScript.

For example:
<c:choose>
<c:when test=”${employee.type == 1}”>
    Employee
</c:when>
<c:when test=”${employee.type == 2}”>
    Consultant
</c:when>
<c:otherwise>
    Unknown
</c: otherwise >
</c:choose>


You easily guess that it’s not simply possible to assign output of this block to a JavaScript variable. A possible work around for this is

var employeeType = "<c:choose><c:when test="${employee.type == 1}">Employee</c:when><c:when test="${employee.type == 2}">Consultant</c:when><c:otherwise>Unknown</c: otherwise ></c:choose>";


or

Putting spaces and line break inside JSTL tags for formatting.

Any of the above work around will result a highly dirty, unmanageable and unreadable code. This is the main reason behind developing this TagLib.

The following code can easily take care of above mentioned problem while maintaining readability of the code. There are many other advantage of using it… I’ll document it sometime latter…

<grid:item>
<c:choose>
<c:when test=”${employee.type == 1}”>
    Employee
</c:when>
<c:when test=”${employee.type == 2}”>
    Consultant
</c:when>
<c:otherwise>
    Unknown
</c: otherwise >
</c:choose>
</grid:item>



I’m using primitive version of the same in my current project. I’ll try setting up a “demo site” and “alpha release” sometime soon. Stay tuned to http://thej2ee.com/x2/modules/newbb/viewforum.php?forum=6 for more details. You can also subscribe to first sticky thread. That way you can get notified by e-mail whenever something new is posted in that thread.

Cheers,

Sudhaker Raj
August 18,

I have put the basic TagLib on demo. Please check -
http://thej2ee.com/x2/modules/mylinks/visit.php?cid=0&lid=9

It's running on Tomcat connected using 768/128 DSL (may be very slow sometime).
Sudhaker Raj
August 20,
Excellent! :)
one thing...can you implement an alternative color value so that results come with alternate colors? or maybe if this functionality exist can you pls provide an example?
Also if you could implement the pagination found in the patches directory .
Then it will be incredibly cool!
Fernando
April 26,
another thing to be cool is for rows to be preformated for date sorting
Fernando
April 26,
I have actually added to the tag the ability for pagination, color alternance and formatting (good when you want to sort base on date)
if anyone is interested i can supply the source code
Nando
April 26,
Hi Nando,

Would be greatly appreciated if you could share your source code on the work you have done for the TAGlib. Kindly, send it via email or post it on this forum.

Thanks

S

Email: sshaikh1970@yahoo.com
GuiBuilder
April 26,
I will email you GuiBuilder cuz dont know how to post attachments here
Fernando
April 26,
can we post it in here? does any one know?
Fernando
April 26,
@Sudhaker Raj or @Fernando
hy, i'm also interessed for these taglibs for active widgets. but link

http://thej2ee.com/x2/modules/mylinks/visit.php?cid=0&lid=9

doesnt work. can you helb me to get the taglib?

thanks

lorenzo

lorenzo.bono@besonet.ch
lorenzo
September 22,
Hi all,

I am interested in looking at this grid control. However, when trying the link for the taglib it doent seem to work. I like the grid and would really like to see the taglib before i make a purchase.

Does anyone know where the lib is keep these days?
March 1,
Hi All

I am just integrating the ActiveWidgets with struts framework for Web Application which retrives a lot of server side data in form of xml data as well as objects.Please enable the following link or send the war file so that i can atleast desploy and test and learn how to integrate with struts.
Thanks
Vikramaditya Garg
vikramadityagarg@gmail.com
vikramaditya.garg@fidelity.co.in
Vikramaditya Garg
April 26,

This topic is archived.

See also:


Back to support forum