Thursday, October 30, 2008

WOX - Web Objects in XML

WOX is an XML serializer for Java and C# objects. In other words, WOX is a library (woxSerializer.jar for Java, and woxSerializer.dll for C#) to serialize Java and C# objects to XML and back again. One of its main features is the generation of standard XML, which is language independant. This means that if we serialize a Java object to XML, we could take the generated XML to reconstruct the object back to C#; and viceversa.

WOX provides a simple and robust way of serializing objects to XML. It is easy to use, and you do not have to modify your source files with any special declarations. The source code is provided, and you are free to adapt it for your own purposes.

Features

Some of the WOX main features are listed below.

  • Easy to use. The Easy class provides serialization and de-serialization methods.
  • Simple XML. The XML generated is simple, easy to understand, and language independent.
  • Requires no class modifications. Classes do not require to have default constructors, getters or setters.
  • Field visibility. Private fields are serialized just as any other field. WOX serializes fields regardless their visibility.
  • Interoperability Java and C#. WOX can serialize a Java object to XML, and reconstruct the XML back to a C# object; and viceversa.
  • Standard XML object representation. This could potentially allow to have WOX serializers in different object-oriented programming languages.
  • WOX data types. The WOX mapping table specifies how primitive data types are mapped to WOX data types.
  • Robust to class changes. Defaults will be used for newly added fields.
  • Arrays. Handles arrays and multi-dimensional arrays of primitives and Objects.
  • Base-64. Byte arrays are base-64 encoded for efficiency.
  • Collection classes. Lists and Maps are provided as WOX data types. (ArrayList and HashMap in Java; ArrayList and Hashtable in C#).
  • Object references. Handles duplicate and circular object references with id/idref.
  • Class and Type. Objects of these classes are saved by their String name.
  • Small footprint. The woxSerializer.jar file (which contains only .class files) is only 25k.
Please look at the following link to find more example and documents.
http://woxserializer.sourceforge.net/index.html

Tuesday, October 28, 2008

Hiding and Un-hiding HTML table rows with out using DIV tag

Hiding and Un-hiding table rows with out using DIV

tag

Usually people will use DIV tag to hide and un-hide the control from the html page dynamically. But we can also use pure Java script to hide the controls.

Here I used Java script to hide and un-hide html table rows. I hope this may help some people.

Copy the following content and save it as an html file. Of-course image won't come....;-)

<html>
<SCRIPT type=text/javascript>

function showHideTR(tRow, no, image) {
var tbl,row,img;
if(document.getElementById && document.getElementsByTagName) { //1
tbl = document.getElementById('tblMain');
img = document.getElementById(image);
if(!tbl){
return;
}else{ //2
for (var x = 1; x <= no; x++){ //3
var rowId = tRow+'Child'+ x;
row = tbl.getElementsByTagName('tr')[rowId];
// alert(rowId);
// alert(row);
if(row) {
if(row.style.display != 'none') {
row.style.display = 'none';
if(img){
img.src = "authTable/icon_connect_plus1.gif";
}
} else {
try {
row.style.display = 'table-row';
} catch(e) {
row.style.display = 'block';
}
row.style.display = 'block';
if(img){
img.src = "authTable/icon_collapse_minus1.gif";
}
}
}
}//3end
}//2end
}//1 end
else if(document.all && document.all.tags) {
tbl = document.all.table1;
img = document.getElementById(image);
if(!tbl){
return;
}else{ //2
for (var x = 1; x <= no; x++){ //3
var rowId = tRow+'Child'+ x;
row = tbl.getElementsByTagName('tr')[rowId];
//alert(rowId);
//alert(row);
if(row) {
if(row.style.display != 'none') {
row.style.display = 'none';
if(img){
img.src = "authTable/icon_expand_end.gif";
}
} else {
try {
row.style.display = 'table-row';
} catch(e) {
row.style.display = 'block';
}
row.style.display = 'block';
if(img){
img.src = "authTable/icon_collapse_more.gif";
}
}
}
}//3end
}//2end
}
}
</SCRIPT>
<br/>
<form id="newUserForm" method="post" name="newUserForm">
<table name="tblMain" id="tblMain" width="100%">
<tb>
<tr bgcolor="#feefff">
<th width="11%">Modules</th>
<td align="center" valign="top" colspan=12><b>Roles</b></td> <!-- 4 * number of role) -->
</tr>
<tr bgcolor="#ffggff">
<td rowspan="2"></td>
<td align="center" colspan="4"><b>Admin</b></td> <!-- 12/3=4 here been used 3 may varie. So 3*4. 4 is constant-->
<td align="center" colspan="4"><b>publisher</b></td>
<td align="center" colspan="4"><b>Viewer</b></td>
</tr>
<tr>
<td align="center"><b>Create</b></td>
<td align="center"><b>Update</b></td>
<td align="center"><b>View</b></td>
<td align="center"><b>Delete</b></td>
<td align="center"><b>Create</b></td>
<td align="center"><b>Update</b></td>
<td align="center"><b>View</b></td>
<td align="center"><b>Delete</b></td>
<td align="center"><b>Create</b></td>
<td align="center"><b>Update</b></td>
<td align="center"><b>View</b></td>
<td align="center"><b>Delete</b></td>
</tr>
<!--Dynamic to be done from here -->
<!--Row 1 -->
<tr id='row'+'1'>
<td>
<A onclick="showHideTR('row'+'1', 2, 'row'+'1'+'Img'+'1');"
href=javascript:void(0)><img id='row1Img1' src="authTable/icon_collapse_minus1.gif" alt="+"/><b> Ananth</b></A>
</td>
<td align="center">
<input type="checkbox"></br>
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
</tr>
<!-- ChildRow 1-->
<tr id="row1Child1">
<td align="right">
<img src="authTable/icon_collapse_more.gif" alt="-"/> Data1
</td>
<td align="center">
<input type="checkbox"></br>
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
</tr>
<!-- -->
<!-- ChildRow 2-->
<tr id='row1Child2'>
<td align="right">
<img src="authTable/icon_collapse_end.gif" alt="-"/> Data2
</td>
<td align="center">
<input type="checkbox"></br>
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
<td align="center">
<input type="checkbox">
</td>
</tr>
<!-- -->
<tr><td bgcolor="#feefff" colspan="13">'</td></tr>
</tb>
</table>
</form>
</html>