Sunday, June 30, 2013

How to create database view with Oracle SQL Developer Data Modeler


In this post will show how to create database view, the creation of database view in Oracle SQL Developer Data Modeler is different with the creation of database view, and it is missing from the previous posts.

Steps:
1. Make sure the SQL Developer Data Modeler is showing the relational view.
a) click on the New View icon
b) move the cursor to the workspace (top-right pane) to bring up the View Properties dialog.
Click New View icon

Saturday, June 29, 2013

How to backup Oracle SQL Developer Data Modeler project


Once we have completed the data modeling project with Oracle SQL Developer Data Modeler, normally we will need to backup the files or future reference or it could be backup and then save it with our team members or superiors.

platform:
1. Oracle SQL Developer Data Modeler

There are 2 ways to backup the data modeling project.
1. With the "Save As..." feature of the data modeler
2. Manual

Saturday, June 22, 2013

How to programmatically append "WHERE" keyword

When querying database from program (Java, .Net, PHP, etc) with criteria (WHERE and/or AND clause), normally we will need to check the existence of WHERE or whether this is the first criteria and programmatically append the WHERE or AND keyword before search criteria..
eg.
String myQuery = "SELECT * FROM TABLE_A";
if(!myQuery.contains("WHERE")) {
    myQuery.append(" WHERE ");
} else {
    myQuery.append(" AND ");
}
// append criteria

Sunday, June 16, 2013

How to export data model to DDL with Oracle SQL Developer Data Modeler


This post will show post-action after the relational data model has been created.
The main purpose is to export the relational model as DDL, and this DDL is runnable SQL script to generate the database schema.
Besides that, it could help us to validate the correctness of data model during DDL generation.

Steps:

Saturday, June 15, 2013

How to add Sequence Generator to a table in Oracle SQL Developer Data Modeler


Nowadays, most of the database design will use a running sequence number as the table's Primary Key instead of a code column, especially for compound key to reduce the complexity to reference to the table.

Thus, this post will show how to define a Sequence Generator for a table in Oracle SQL Developer Data Modeler.

Assumed that a table already created, with a number type column as the PK shown below.
table with PK is number type

Tuesday, June 11, 2013

How to create relational data model with Oracle SQL Developer Data Modeler


This tutorial shows how to create a relational data model by creating tables, adding columns to tables, defining relationships between tables, etc. 

Pre-requisite
1. JRE is installed.
2. Oracle SQL Developer Data Modeler is installed.

1. Create table.
    Make sure you are in relational tab > click table() icon > move the pointer to the white empty space.
data modeler relational tab

Sunday, June 9, 2013

Getting started with Oracle SQL developer Data modeler


Oracle SQL Developer Data Modeler is free tool from Oracle.
As mentioned in the name, this is a free database modeling tool.
Below are some of the features provided:
- Create logical data model
- Create relational data model
- Convert logical data model to relational data model
- Convert relational data model to logical data model
- Export data model to SQL scripts
- etc.

Saturday, June 8, 2013

Handling Many-to-Many relationship in relational model


When doing database design with logical model, we are allowed to create many-to-many (M:N) relationship.
M:N relationship ER modeling

But M:N relationship is not available in relational model. 

In this case, we have break the many-to-many relationship to two (2) one-to-many (1:M) relationship and add an intermediary in between the two entities.

How to install PrimeFaces Extensions in a PrimeFaces project

I was looking to install PrimeFaces Extensions into my PrimeFaces project, but I failed to find any website that mention how PrimeFaces Extensions install into a PrimeFaces project.

Thus, I have to try and error by myself. 


Then I copied the primefaces-extensions-0.6.2.jar into my PrimeFaces project and start the Tomcat.
Unfortunately, the application failed to start and showing the following error.
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringEscapeUtils
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
 at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Unknown Source)
 at com.sun.faces.util.Util.loadClass(Util.java:273)
 at com.sun.faces.config.processor.AbstractConfigProcessor.loadClass(AbstractConfigProcessor.java:311)
 at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processFunctions(FaceletTaglibConfigProcessor.java:616)
 ... 14 more

It's required me to add in commons-lang3-3.1.jar into the project and restart again.

this time I was successfully start the Tomcat server, and tested the PrimeFaces Extensions with the following code.
<pe:inputNumber id="input2" value="#{testBean.numberValue}"
                symbol=" CHF" symbolPosition="s"
                decimalSeparator="," thousandSeparator=".">
    <p:ajax event="blur" />
</pe:inputNumber>

Output:
pe:inputText component

Conclusion:

copy the following jar into the existing PrimeFaces project and test the PrimeFaces Extensions again
1. primefaces-extensions-0.6.2.jar
2. commons-lang3-3.1.jar

It should works!



Done!!

Thursday, June 6, 2013

Authorization in JSF with Facelets View Handler

According to wikipedia, authorization is the function of specifying access rights to resources.
Authorization is important to protect sensitive against different users.

The simplest way is to provide the access right to the targeted fields/components directly
for readOnly access,
<h:outputText id="authorizedId" value="#{bean.authorizedValue}" readonly="#{bean.authorizedReadonly}" />

for viewable access,
<h:outputText id="authorizedId" value="#{bean.authorizedValue}" disabled="#{bean.authorizedDisabled}" />

but the above solution is NOT feasible if there are many pages and fields/components to be authorized;
NOT flexible, if there are access right changes, re-coding is required.

Another feasible way is through FaceletsViewHandler.
In JSF with Facelets view handling, we can actually place all the authorization controls to the FaceletsViewHandler as the control central.

Sunday, June 2, 2013

Richfaces oncomplete not working in Liferay

The oncomplete attribute is a very common and useful in RichFaces application to invoke a javascript function after calling a server side action.

<a4j:commandButton value="Some Action" action="#{testBean.someAction}" oncomplete="oncompleteScript" />

But this attribute is ignored in RichFaces portlet in Liferay.

The root cause is the Liferay portlet bridge.
When we create RichFaces 4 portlet in Liferay with Liferay IDE, it comes with the default Liferay jar (bridge-api, bridge-impl, portal, util)

The version of Liferay portlet bridge bundled with the Liferay IDE causing the oncomplete attribute being ignored.

JSF number validator with regular expression

Although we can use <f:validateLongRange /> and <f:validateDoubleRange /> to validate number in JSF, but  that are simple enough and unable to validate complex number format.

To be able to validate more complex number, regular expression is recommended.
The core idea is to create a facelets composite component from <f:validateRegex /> validator by providing default regular expression to validate desired number format.

some useful number regular expression in the table below
FormatRegular expression
number with comma^(\d|,)*\.?\d*$
positive number only^\d{1,7}$
Percentage ^(0*100{1,1}\.?((?<=\.)0*)?%?$)|(^0*\d{0,2}\.?((?<=\.)\d*)?%?)$
currency^\$?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$
for more information about number regular expression, please refer here.

Now let's start building the number validator with the chosen regular expression.

Saturday, June 1, 2013

How to add Tomcat server plugin in Eclipse

Tomcat is a popular opensource application server for java web application; Eclipse is a popular opensource  IDE for java development.
Both of them be configured to work together to increase our efficient for development.

Platform:
1. Eclipse Juno
2. Tomcat 7.x

Error handling in jQuery Validation Plugin

Regarding the error handling in jQuery validation plugin, it could be split to the following types of handling.
1. error styleClass
    - highlight the error element
2. error placement
    - field level - placing the error message together with the error element. - errorPlacement
    - form level - placing the error message in screen header or footer. - errorContainer

Now let's go through each of the handling.

1. error styleClass

define the following styleClass,
input.error { background: #FFD2D2; color:#000000; border: 1px solid red; }
and it will produce the following output
error styled input

LinkWithin

Related Posts Plugin for WordPress, Blogger...