Thursday, 11 October 2012

Component Frameworks


Welcome to the world of components!!!

Today, we are heading towards the component world. Everything we get in terms of component.Rather we are building everything as a component. Why I am saying this is because the kind of frameworks I came across.

I started my carrier with Struts framework. This is most popular MVC framework of that time. As it is today as well.But there were very few other frameworks competing with Struts.

At that time i didn't heard anything in terms of component.But later on I moved to other organizations and  started working on JSF.At that time JSF was the emerging framework. It was known as the component framework for fast web application development.It also had in built support for Ajax.

After that I came across another framework Apache Wicket. This is another frame that I learnt. This framework was quite different from JSF. As a Java developer u need not have to write anything on the HTML side or in JSP. There is a VERY nice separation of presentation and logic. Here HTML will remain as HTML. I enjoyed working on this framework.

Currently I am using the ExtJS which is another JavaScript framework which is also a component framework.

Yesterday I read about some other framework like "Vaadin", "KendoUI".These are the other emerging component based framework.There are many more in the market which are known as component framework. By using which u can fasten the development and it eases the maintenance of software.

I m not comparing these frameworks here. Just wanted share and highlight that the Technology world is moving fast and everything in coming to us in terms of "Component"...

Wednesday, 26 September 2012

MultiKeyMap

It uses multiple keys to store the value.

This MultiKeyMap is not synchronized and is not thread-safe.

Add the jar "commons-collections-3.2.1.jar".

Example is :


MultiKeyMap multiKeyMap = new MultiKeyMap();
multiKeyMap.put("DocumentName","DocumentRef","DocumentAuthor");
multiKeyMap.put("DocumentName1","DocumentRef1","DocumentAuthor1");
multiKeyMap.put("DocumentName2","DocumentRef2","DocumentAuthor2");
multiKeyMap.put("DocumentName3","DocumentRef3","DocumentAuthor3");

// later retireve the value
System.out.println(multiKeyMap.get("DocumentName","DocumentRef"));  
System.out.println(multiKeyMap.get("DocumentName1","DocumentRef1"));
System.out.println(multiKeyMap.get("DocumentName2","DocumentRef2"));
System.out.println(multiKeyMap.get("DocumentName3","DocumentRef3"));

the output is :


DocumentAuthor
DocumentAuthor1
DocumentAuthor2
DocumentAuthor3

Tuesday, 22 May 2012

How to index data in solr from database automatically?

As most of the application store the data in relational databases and once the data size gets larger the option comes to solr. Index the data of database using solr DIH. It requires you to configure the data-config.xml. All the required info about setting up solr and data-config.xml is available at
http://abhijitbashetti.blogspot.in/2011/09/apache-solr-set-up-for-tomcat-on-linux.html and

the other useful link is http://abhijitbashetti.blogspot.in/2011/09/indexing-database-with-solr-34-from.html

Now the question comes how to automize the same. I have used the JBoss for scheduling the same.

In the data-config.xml use the last_index_time as the variable resolver. Or add a new column to the table from where you are fetching the data for indexing e.g last_modification_date.

For the next scheduling which will be invoked for updating the index for the updated data in your database. It will check the last_modification_date with last_index_time and update the index accordingly.

Here you can use the jboss scheduling mechanism by firing different url to your solr server.

i.e. Add the variable resolver in your query and send those data in the http URL to solr.

Your database query would be like ...



select  doc.document_id as id,
        doc.name as name,
        doc.author as author,
        from   ds_document_c doc
        where doc.last_modification_date >= to_date(${dataimporter.request.last_index_time}, 'DD/MM/YYYY HH24:MI:SS');


and the http url for the solr would like

http://localhost:8080/solr/select?qt=/dataimport&command=full-import&clean=false&commit=true&verbose=true&last_index_time='12/05/2012'


This will help you to automate your database indexing ....











Friday, 4 May 2012

modify an existing check constraint in oracle?

Drop and Recreate it.



Oracle "alter table" syntax to drop constraints.


ALTER TABLE TEST_TABLE DROP constraint TEST_TABLE_CC1;


Oracle "alter table" syntax to add a check constraint.


ALTER TABLE TEST_TABLE ADD CONSTRAINT TEST_TABLE_CC1 CHECK ( PAYMENT_MODE IN ( 'CASH' , 'NET_BANKING' , 'CHEQUE' ) );

Tuesday, 17 April 2012

IFRAME Example


The <iframe> tag specifies an inline frame.
An inline frame is used to embed another document within the current HTML document.

I wanted to have the "src" to be changed dynamically. 

Here is the example of IFRAME where in source can be changed though TextField. 
Whatever you enter into the text box will be given to the Iframe and iframe window will render that page.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>TEST Page</title>
</head>
<script type="text/javascript" >
function iframeMethod() {
var srcValue =  document.getElementById("text");
var iframe   =  document.getElementById("frame");
iframe.setAttribute('src', srcValue.value);
}
</script>
<body>
<iframe src="http://www.google.com" name="frame" id="frame"
frameborder=0 style="overflow:visible; width:100%; height:600; scrolling="no">
</iframe>
<input type="text" name="text" id="text" target="frame"/>
<input type="submit" name="submit" id="submit" value="Submit" onclick="javascript:iframeMethod();"/>
</body>
</html>

Monday, 9 April 2012

How to set JAVA_HOME environment variable in Ubuntu


    Open /etc/bash.bashrc using sudo command
    e.g. sudo gedit /etc/bash.bashrc.
   
   go to the end of the file and add following lines:

    JAVA_HOME=/usr/lib/jvm/name_of_your_java_folder(e.g. java,open-6-jdk etc.)
    export JAVA_HOME
   
    PATH=$PATH:$JAVA_HOME/bin
    export PATH

   Done. Just reboot your computer.


    echo $JAVA_HOME
    it shows something like this:/usr/lib/jvm/name_of_your_java_folder(e.g. java,open-6-jdk etc.)
 
    echo $PATH
    it shows something like this::/usr/lib/jvm/name_of_your_java_folder(e.g. java,open-6-jdk etc.)/bin 

Thursday, 22 March 2012

Unique constraint and index relationship in Oracle

Dropping Unique Key does not drop the index created for it in Oracle.

I am not very sure for which all versions it happens.

But when I explicitly run the

Drop Index <indexName>;

After execution the same , my unique constraint violation exception issue is fixed.