Tuesday, March 15, 2011

IE 9 issue with Arabic

Have you tried IE9? well, it is released, and you can download from here

It is cool however, an obvious bug is seen while using Arabic text. Here is a sample HTML

<html>
       <head>
              <title name="jspx_generated_1" id="jspx_generated_1">               
              title>
              <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
              <meta http-equiv="Content-Language" content="ar-eg"/>
       head>
       <body dir="rtl" topmargin="0">
              <span style="font-style: italic; font-family: arial;">
              اقرأ كل الاخبار
              span>
       body>
html>


And this should produce the following:








And that what is obtained









To solve this, simply use on of the two style not both of them.

<span style="font-family: arial;">
              اقرأ كل الاخبار
              span>
 OR

<span style="font-style: italic;>
              اقرأ كل الاخبار
              span>


way to GO IE9!









Saturday, February 19, 2011

Jspx Build 1.1.0

Jspx build 1.1.0 is released. new features are added, few bugs are solved. and brand new demo project is added.  here are the new release notes of the build.


http://jspx-bay.sourceforge.net


What is new in jspx 1.1.0?
JSPX build 1.1.0 is an improvements in both UI and internal functionalities. It introduces many new features. Along with support for JBoss 5.1.0 and MySQL.
New Demo project is added.

Build 1.1.0 vs. 1.0.10
New Features:
1.  Support JBoss 5.1.0
2.  Support MySQL DB.
3.  Validations UI Improvements.
4.  Calendar UI improvements.
5.  DataTable has a Flickr like pagination.
6.  Sortable columns will have a default icon.
7.  Accepts any HTML outside the tag

Bugs Fixed:
1.      Remove NullPointerException in case the href is empty in anchor control.
2.      Supporting mailto in the anchor href.





Monday, December 13, 2010

Case Senstive DBMS

DataTable

Is a powerful Web Control that is connecting directly to the DB making full management of data without no single line of codes. DataTable is using plain sql statement that it has a place holders for parameters and variables.

Now let's consider the following SQL statement to run on MySql DB.



SELECT (g.NAME) AS g_name, (m.NAME) AS m_name, gen.NAME AS c_gender,
       bdb.NAME bdb_name, c.*
  FROM dcs.customer c,
       dcs.grade g,
       dcs.martial_status m,
       dcs.gender gen,
       dcs.boolean_db bdb
 WHERE c.grade = g.ID
   AND c.martial_status = m.ID
   AND c.gender = gen.ID
   AND bdb.ID = c.deleted
   AND c.ID = custid
   AND passport_num LIKE '%pass%'
   AND c.NAME LIKE '%custName%'
   AND phone LIKE '%custPhone%'
   AND gender = custgender
   AND (creation_date) >=str_to_date ('from_date 00:00:00', '%e/%m/%Y %H:%i:%s')
   AND (creation_date) <=str_to_date ('to_date 23:59:59', '%e/%m/%Y %H:%i:%s')
   AND job LIKE '%custJob%'
   AND grade = custgrade
   AND martial_status = custmart
   AND deleted = custdel
   AND (birth_date) >= str_to_date ('from_Bdate', '%e/%m/%Y')
   AND (birth_date) <= str_to_date ('to_Bdate', '%e/%m/%Y')


The highlighted conditions are used to limit the search to certain date window. The problem that the date formatter in Oracle is different than MySQL. in MySQL the formatter is case senstive. i.e. %Y is different than %y. Full description of the date formatting can found here


Jspx DataParam is used to inject user values into the place holders in the SQL statement. To do that, DataParam converts the Expression [ (birth_date) >= str_to_date ('from_Bdate', '%e/%m/%Y') ] to lower case, then replaces the variable [ from_Bdate] with the value . Changing the case will cause the format to work differently on MySQL. That when we decided to make the replacement case sensitive which will work for both MySql and Oracle. This simply make it difficult to developer as he has to write the DataParam attributes (Expression, name) case identical.

In order to solve this, a new Boolean attribute caseSensitive is added to the DataTable to decide if the Expression will be case sensitive or not. As usual, this parameter has a default value to false, which means that it will be backward compatible with what you have done before.

If this attribute is set to true, then your expression should contain the place holder variable as the same case as the name attribute.


<dataparam name="from_Bdate" control="bdFrom" id="dp1" expression="(BIRTH_DATE) >= STR_TO_DATE('from_Bdate','%e/%m/%Y')"/>

in case there a casing diffrence, you will get the exception


DataParam [dp1] has the Expression [(BIRTH_DATE) >= STR_TO_DATE('from_Bdate','%e/%m/%Y')] that does not contain the name [from_bdate] Please make sure of the name exists and match case


Despite that fact that this attribute caseSensitive is related to the DataParam behavior, it is a property in DataTable. The reason for that, is that this property is consistent over the DB. So why it is not a property a cross the application instead of repeating it on every DataTable? The answer is, this will allow to have your application connecting to different DBMS (Oracle, MySQL) based on your DataTable.






Tuesday, November 23, 2010

DeniedRoles

Jspx integrates with JAAS APIs providing an easy to use Authentication/Authorization module. Full Details about this can be found here jaas-on-web-control-level

In the currently under developing build, jspx has added new attribute to both Page and WebControl.


DeniedRoles

This attribute can be used the same way as AllowedRoles has been used. So, if the value is set to * then no one can access this Page/Control.

 A list of Roles can be concatenated to the value like DeniedRoles="System Admin,Super User,Guest"

This will allow all users does not have any of the roles listed above.



This new attribute is planned to be released on the upcomming build of Jspx.










Wednesday, November 3, 2010

MySQL 5.1

DataTable is a powerful control that is connecting to DB directly. Business cases like search, add, edit and delete from a DB table can be implemented without single line of Java Code.

Jspx is being tested against MySQL DB. DataTable worked fine with normal quires like



However, with quires like this,


SELECT (g.NAME) AS g_name, (m.NAME) AS m_name,
       (CASE c.gender
           WHEN 1
              THEN 'male'
           WHEN 2
              THEN 'female'
           ELSE c.gender
        END
       ) AS c_gender,
       c.*
  FROM dcs.customer c, dcs.grade g, dcs.martial_status m
 WHERE c.grade = g.ID
   AND c.martial_status = m.ID
   AND ID = custid
   AND passport_num LIKE '%pass%'
   AND NAME LIKE '%custName%'
   AND phone LIKE '%custPhone%'
   AND gender = custgender
   AND TRUNC (creation_date) >= str_to_date ('from_date', '%d/%m/%Y')
   AND TRUNC (creation_date) <= str_to_date ('to_date', '%d/%m/%Y')
   AND job LIKE '%custJob%'
   AND grade = cutgrade
   AND martial_status = custmart
   AND deleted = custdel


we noticed that it could not retrieval the full columns returned. To know the reason, let's dive under the Hood, while JSPX  is executing the search SQL, it constructs a hashmap of the returned records


public static List<Hashtable<String, DataField>> search(String datasource, String sql, int start, int size) throws Exception

where the DataField is storing the column name , type and value. The hash map representing one record of the result set is indexed by the column name.

Inside the above method, the column name is retrieved as


if (resultSet.absolute(start + 1))
{
int colCount = resultSet.getMetaData().getColumnCount();
      do
      {
            cols = new Hashtable<String, DataField>();
            for (int i = 1; i <= colCount; i++)
            {
                  fieldName = resultSet.getMetaData().getColumnName(i).trim().toLowerCase();
                  cols.put(fieldName, new DataField(fieldName, resultSet.getObject(i)));
                  }
            rows.add(cols);
      }
      while (resultSet.next() && (++counter < size));
}

The method getColumnName(i) in MySQL JDBC driver returns the original name of the column instead of the alias name in the SQL statement, so assume you have table Customer with column "NAME" and you have table JOB with Filed "NAME".
Creating aliasing for the filed "NAME" in JOB Table as "JOB_NAME" will return the column "NAME" from JOB table under the label "JOB_NAME". But JSPX will get "NAME" as the name of the column.

Instead of  this method we used the getColumnLabel(i) method to get the correct name of the column.