Wednesday, 27 June 2007

JSF Basics Getting the value of an EL expression in code

You can use the following code to get the value of any EL expression defined inside your JSF page For example the following checks the value of the expression #{requestScope.requestRowKey}

        // access the faces context
        FacesContext fc = FacesContext.getCurrentInstance();

        ValueBinding vb = fc.getApplication().createValueBinding("#{requestScope.requestRowKey}");
        String rowKey = (String )vb.getValue(fc);

Assigning a new value can be preformed by using vb.setValue( Object o)

Tuesday, 26 June 2007

Wrong date and time format when depolying an Application

All the credit for this post should go to John Stegeman for providing the solution. I will just copy the main points here, so I can find it more easily.

The story goes like this. People are seeing different date and time formats after deploying and running their applications on an Oracle IAS rather than their embedded OC4J where the dates and times display correctly.

The solution appears to be the addition of a <locale-config> tag inside the faces-config.xml file. The entire thread that explains everything can be accessed from here. Furthermore John also posted a link with all the two letter ISO country codes which is available from

One final remark. I have been deploying applications on Oracle IAS running on Linux (SuSE Linux 8 and SLES9), since version 9i and never run into anything like it. Could that be a Windows issue ? :-)

Monday, 18 June 2007

ADF Tables. Setting an alternative sort property

Suppose you have an ADF table somewhere inside a JSF page and you wish it to be sortable. This is fine as long as you define two things.

  • The sortproperty property of the adf:column tag which has to be one of the column names of the table binding and tell the system how to change the order by clause of the underlying view.
  • The sortbale which has to be set to true or false and determines whether to allow sorting by clicking on the column header or not

So this is a perfectly good column definition for an attribute called Matnr athat corresponds to the notorious SAP material number.

<af:column sortProperty="Matnr" sortable="true"
    <af:outputText value="#{row.Matnr}"/>

If you now happen to have a transient attribute and you wish to sort the table based on this attribute, then you just can't do it. The way I see it, sorting means changing the order by clause and re executing the entire query. ADF complains that there is simply no attribute by that name and throws an SQLException that comes straight from the JDBC driver.

My suggestion for a workaround that works most of the times is this : Since 90% pf transient attributes usually serve as simple lexical transformations of real database attributes, changing the sortProperty of the adf:column tag to the value of the real column might solve the problem

Let's suppose that the ViewObject of the previous example has a transient attribute called DisplayMatnr that simply removes the leading zeros of the SAP oriented material number stored in column Matnr. It goes without saying that if Matnr is sorted then so is DisplayMatnr. Therefore writing something like ...

<af:column sortProperty="Matnr" sortable="true"
    <af:outputText value="#{row.DisplayMatnr}"/>

... might bring the desired effect. There is one last warning though the attribute that you wish to sort by must be a part of the table definition in the bindings page

Sunday, 17 June 2007

Nvidia Howto for SuSE Linux

Tried upgrading my home Linux KDE today. Not much of of update that was but since the wind of change was already blowing into my system, I thought of updating my NVidia driver as well.

Well it worked... YaST said there was a newer version, I selected it, installed it and failed. There was no way to start X again with Sax2 complaining about amissing screen configuration. Then I did two things.

For everyone else into the same kind of trouble my suggestion is Think before you click and the all time classic.RTFM.

Friday, 8 June 2007

Setting up a Virtual Host in Oracle IAS

Sooner or later it would have to come to this. We decided we wanted to setup our application server so that we would end up with two virtual hosts

  • One providing a set of j2ee applications that will be accessible via port 80. This will be used by intra net users
  • Another virtual host, providing an application named MyApp deployed into an OC4J Instance called OC4J_MYAPP that will be accessible via a different DNS name and used by internet users. The actual application will be accessed via SSL provided by a firewall / SSL Converter hosted on a different machine.

The first thing that needed to be done was to enable Apache to run as root and change the listening port to 80. See previous post Oracle IAS 10g 10.1.3.x Enable Apache to run as root and set the default HTTP port to 80 (non SSL)

The next thing was to set up the virtual host. environment. This includes creating a location for the static documents and he log files. In our case I created a websites directory and added a virtual-host-name directory with two subdirs named htdocs and logs.

You then have to go through the patching part and there is no way you can know this unless somebody from Oracle Support tells you. (Thanks Dan!) Out of the box Oracle IAS needs two patches to be applied one 5555875 is the one that will allow your virtual host to be able to mount OC4J exported applications and the second one 5669155 will be the one that will patch the opatch utility so it will install the first one. Both patchsets are available from Oracle metalink.

After you have successfully applied patch numbers 5669155 and 5555875 in sequence, you will have to modify the the httpd.conf file located in $ORACLE_HOME/Apache/Apache/conf/httpd.conf and add a VirtualHost entry to specify the details of your virtual host. My file looks more or less like this

# Defualt virtual host
NameVirtualHost *

# here is where you must enable acess to EM website and other applications 
# so they may be available from the default host
<VirtualHost *>

    Oc4jMountCopy on
    Oc4jMount /em home
    Oc4jMount /em/* home

# Virtual host for

Oc4jRoutingMode Static

<VirtualHost *>
#    Unique location where a unique index.html file exists:
     DocumentRoot /home/oracle/websites/

#    Name used for this VirtualHost:

#    For this purpose, we may need also access on port 80:
     Port 80


#    Must appear in one line
     CustomLog "|/home/oracle/product/
                 /bin/rotatelogs /home/oracle/websites/                     
                 43200" common

    Oc4jMountCopy off
    Oc4jMount /MyApp OC4J_MYAPP
    Oc4jMount /MyApp/* OC4J_MYAPP

More or less that does it.

The details can be found in the Apache documentation for virtual hosts, from where the basic idea is summarized as follows:

When a request arrives, the server will first check if it is using an IP address that matches the NameVirtualHost. If it is, then it will look at each section with a matching IP address and try to find one where the ServerName or ServerAlias matches the requested hostname. If it finds one, then it uses the configuration for that server. If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.

As a consequence, the first listed virtual host is the default virtual host. The DocumentRoot from the main server will never be used when an IP address matches the NameVirtualHost directive. If you would like to have a special configuration for requests that do not match any particular virtual host, simply put that configuration in a &th;VirtualHost> container and list it first in the configuration file.

So to finish it, Just restart the HTTP_Server ...

opmnctl restartproc process-type=HTTP_Server

and it works.

Just one final touch. Since the virtual server will be the home for a single j2ee application, it might be convinient that the static index.html page of the new virtual host directly sends visitors to the j2ee application URL. This is as easy as adding

<meta http-equiv="refresh" content="0; url=/MyApp">

And think that now we are ready.

Thursday, 7 June 2007

JDeveloper 10.1.3.x Screen display problems

I run into the topic on the Oracle JDeveloper forums and I thought I might keep the reference here.

A guy running JDeveloper on Windows using a laptop had serious problems with the display when the IDE tried to scroll as it was leaving visible marks. It ended up that the remedy was adding AddVMOption -Dsun.java2d.noddraw=true at the $JDEV_HOME/jdev/bin/jdev.conf file.

For anybody interested the entire thread can be found here