Friday, July 23, 2010

ExtJS - adding a asterisk '*' sign in red color for all required or mandatory field.

Well there was a requirement in ExtJS where all the mandatory/required fields in the application (i.e allowNull is false) should have a * sign in red color.

Here is the code which adds a * (asterisk) sign in red color to the field label while rendering for all the required fields in your application.

// This code adds the * sign for all the field labels if the fields are mandatory
Ext.apply(Ext.layout.FormLayout.prototype, {
originalRenderItem: Ext.layout.FormLayout.prototype.renderItem,
renderItem: function(c, position, target){
if (c && !c.rendered && c.isFormField && c.fieldLabel && !c.allowBlank) {
c.fieldLabel = c.fieldLabel + " ((c.requiredFieldCls !== undefined) ? 'class="' + c.requiredFieldCls + '"' : 'style="color:red;font-size: 11px;"') +
">*
";
}
this.originalRenderItem.apply(this, arguments);
}
});

Monday, March 1, 2010

Differences ....

Here are few varied differences one would like to know abt :

Iterator Vs ListIterator
Iterator iterates only in forward direction
List iterator can navigate bidirectional

ServletRequest Vs ServletContext RequestDispatcher
ServletRequest RequestDispatcher can take relative path
ServletContext RequestDispatcher cannot take relative path

Clob Vs Blob
Clob stores huge character type data like xml,txt, etc files
Blob stores huge binary type data like jpeg files, etc

Threads :
yeild() - returns to ready state
sleep() - returns to wait state
notify() - invoke wait state thread to ready state
notifyAll() - invoke all wait state thread to ready state

Sleep Vs Wait
sleep holds the thread till the time specified and cant be revoked within that time whereas wait holds the thread till specified time but can be revoked in the within time.

DB Cursor Vs RefCursor
Cursor :
No return type
Static
Can assign to single query
RefCursor :
Has return type
Dynamic
Can assign to multiple queries

Differences between Collections :
List :

Ordered
Contain duplicates
Vector :
Growable array
Synchronized
Multi thread
Default size to 10
Set :
Unordered
No duplicates
Hashtable :
Key-value
Synchronized
No NULLS
Ordered
Use enumerator
Arraylist :
Heterogeneous
Unsynchronized
Allow NULLS
Uses array structure to store
No default size
Map :
Interface
Associate key with Value
Hashmap :
No order
Unsynchronized
Allow NULLS
Use Iterator
Default size is 8
LinkedList :
Faster to insert/delete in between.

Thursday, August 6, 2009

How do you know whether the index is analyzed or not in a table ...?

Many of times we create indexes and forget to analyze them. Here is a simple way to find out whether your indexes or tables have been analyzed alteast once or not ...

- To find if a table is analyzed, check the "AVG_ROW_LEN" column of the USER_TABLES table. If it is non-zero, the 'analyze' or 'dbms_stats' command has been run at least once on this table.

- To find if an index is analyzed, check the "COLUMN_LENGTH " column of the USER_IND_COLUMNS table. If it is non-zero, the 'analyze' or 'dbms_stats' command has been run at least once on this index.

But why do we need to analyze the indexes or tables ??
Because oracle uses the cost based optimizer to give the best performance in most of the cases. And the cost based optimizer needs data to decide the access plan, and this data is generated by the analyze command or the newer dbms_stats package.

So always analyze or dbms_stats the table and indexes.
If you analyze a table, then its current indexes are automatically analyzed too. If you analyze a index, then the table is not analyzed.

Monday, August 3, 2009

JBoss still uses old .class files even after replacing them with new class files....

Was facing an issue with jboss when i tried to redeploy an ear by replacing few .class files with new compiled .class files (the class files are mostly interfaces containing constants defined in it). But the jboss failed to pickup the new .class files, rather it was referring to the old class files still.

I tried every possibility like redeploying the ear, clearing the cache of jboss, etc but it didn't helped out. But if updating the class which is 'implementing' the interface, it would then refer to new .class files.

The possible reasons could be
- Jboss compiler is possibly failing to recognize the changed interfaces as the implemented class is not been updated.
- The Jboss is not cleaning it weekly hashmapped reference of the classes.

But the point what i learned is that defining constants in an interface is a bad practice as you can end up in such trouble. Interfaces are meant to expose the method definitions.

Tuesday, June 9, 2009

Changing the ip address on Oracle server.

Recently my system's ip got changed and the after effect is when i tried to up my applications, it was unable to connect to the oracle database.

If your system's ip address have been changed then you got to test whether your oracle db is properly starting up or not and whether your applications which connect to Oracle are able to connect to oracle.
If you got a problem then you got to change the ip address of Oracle.

For changing the ip address on the oracle server, we need to change the following 2 files.
1. tnsnames.ora
2. listener.ora

You can find both the files in "oracle\product\10.2.0\db_1\NETWORK\ADMIN" path.
Replace the old ip address to new one.

Tuesday, June 2, 2009

URL Encoder.

Here is the perfect link which help you to find the encoding special characters which can exists in the url like a space,^,<,>, etc.

http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

In this site, you got a live encoding converter too which tell whether the char is safe string or need to encode :)

Thursday, May 21, 2009

Getting "registry editing has been disabled by your Administrator" error ?

Getting "registry editing has been disabled by your Administrator" error ?

When you try to Start -> Run -> regedit and if you get this error the just go to the following link and follow the steps :
http://www.online-tech-tips.com/windows-xp/registry-disabled-by-administrator/