Mittwoch, 16. Juli 2014

DB2 show version in Servlet

The JDBC-Driver is provided by the J2EE-Container. So your Web-Applications doesn't really know which Version of a Driver is used. If you Google you will find following advice:
java -cp ./db2jcc.jar com.ibm.db2.jcc.DB2Jcc -version
This is a way to display the used Version on Console. e.g. if you are a Server-Admin and you what to know which driver version is installed on the system.
String[] errorSoon = {"-version"}; DB2Jcc.main(errorSoon);
The problem is, that DB2Jcc.main does not return a String which you ca pass to the Servlet. So you want to know what DB2Jcc does.
The String you want to get generated by calling a static method qp.d();
import com.ibm.db2.jcc.am.qp; qp.d() ;
Of course, this is only working if you use DB2. So it is a good idea to Write a separate Servlet - in case that your app uses a another JDBC-Driver (Another Vendor or Version of DB2) that does not use this internal method.

Donnerstag, 6. Juni 2013

jquery ui tabs tab selected callback

If you are using the tabs()-element of the jqueryui you might want to perform a custom action after the selection of the tab. The tab()-element is offering different methods.
  1. is executed before the tab switches. You have the possiblity to cancel the action.
  2. is executed after the tab has switched. You got e.g. the option to set the focus to a specific element
http://api.jqueryui.com/1.8/tabs/#event-show An other option is just to bind the tabsshow http://api.jqueryui.com/1.8/tabs/#event-select

Freitag, 8. Februar 2013

using jquery's spinner in custom component


Assumtion/prerequirements
  1. You are using jQuery
  2. You are using jQuery UI

By using jquery ui's autocomplete you get this nice spinner in your input-tag.
It is pretty easy to reuse the spinner in you own component.





$('#user_id').addClass( "ui-autocomplete-loading");





$('#user_id').removeClass( "ui-autocomplete-loading");




In my case I used an following ajax-call:

$('#user_suchen').click(function() {
  $('#user_id').addClass( "ui-autocomplete-loading" );
  var userId = $('#user_id').val();
  $.ajax({
    url : '${getUserData}',
    data : { "userId" : userId },
    dataType : "json",
    success : function(data, textStatus, jqXHR) {
      $('#name').val(data.name);
      $('#oe').val(data.oe_bezeichnung);
      $('#user_id').val(data.userId);
      $('#user_id').removeClass( "ui-autocomplete-loading" );
    },
    error : function( jqXHR, jqXHR, textStatus,errorThrown ) {
      $('#user_id').removeClass( "ui-autocomplete-loading" );
    }
  });
});

Mittwoch, 30. Januar 2013

WAS choose faces implementation

Because WAS7 ist JEE5 compiant -
and every JEE5 container need to deliver a JSF 1.2 .
WAS7 gives you the option to choose which JSF-Implementation you want to provide for the app.

The following Screenshot tells you how to do this.

By the way - Did you notice that IBM does not offer the option to choose an IBM-Implementation of JSF 1.2
That's the reason why we have to deal with the old JSF 1.1 version in our app.
Migration is very difficult.
>
I read that with JEE7 (comming mai 2013) - JSF 2.2 will be part of the spezifikation.

Dienstag, 29. Januar 2013

OpenJPA DB2 hellojpa

In order to execute the sample app, you need to create the table in your Database.
In our case the user/owner ist called TESTUSR.
The table definition works fine with the sample, and it has soem adtional features.
CREATE TABLE TESTUSR.MESSAGE (
 ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY,
 CREATED DATE DEFAULT CURRENT_DATE NOT NULL,
 MESSAGE VARCHAR(2000) NOT NULL
);
INSERT INTO TESTUSR.MESSAGE (MESSAGE ) VALUES  ( 'hi2' )
don't forget the configuration of your persistence.xml.
In our case we set 4 parameters.
It is also possible to use a datasource in hosted appserverenvironment.
Because we are assuming the simple we choose to set the minimal necessary parameters.

Freitag, 25. Januar 2013

WAS7 enable debugging



In order to connect to a remote java process. The JVM must be started in debugging-mode.

Application servers > server1 > Process definition > Java Virtual Machine











Mittwoch, 9. Januar 2013

Drucken-Link

Um eine HTML-Seite zu drucken kann man einen Link in seine HTML-Seite einfügen.
window.print();
Seite-Drucken