Category Archives: Java

Rich Text Editor in Java, JSP

Today my friend asking me to implement Rich Text Editor in Java. Their current application is standard Java web application.

Talking to my friend who use to talk using Ruby, he recommends me to use CKEditor. From the forum and the feedback this javascript library, I can say already mature.

They have implement also the taglib for JSP (either make this more complicated or easier is up to developer who uses it).

Since the friend who asks a help already implement in java way for the sake of maintaining purpose.

For anyone who still has doubt on how the Rich Text Editor (RTE) looks like, it is like this

1

The common use case when the RTE use is when we need to let user has a fancy post (like in Jira) , instead of writing  HTML code to draw a table and insert an image. Others use case is for in some web application that required the user admin to create an email template in a fancy way but easier.

So, now you have a solid reason to have the feature on your web application. The steps to implement it as follow.

I assume you use maven base project, and you can add ckeditor taglib library to the project


<!-- WYSWYG lib CK Editor -->
<dependency>
     <groupId>com.ckeditor</groupId>
     <artifactId>ckeditor-java-core</artifactId>
     <version>3.5.3</version>
</dependency>

After the jar is added (either trough maven or manual), download the ckeditor from here http://ckeditor.com/download/releases ( I used ckeditor 3.5.3)

and copy all to your javascript folder (later we use the location in our jsp). In my project will be like this

1

Once the javascript and all the ckeditor added into the project then we can start add and work on our jsp.

Add this snipped on top of your jsp, so you can start using the taglib


<%@ taglib uri="http://ckeditor.com" prefix="ckeditor" %>

 

within the form tag, you ckeditor:editor instead of textarea like below

<tr>
<td class="field-label" colspan="2">Void Email Template
<ckeditor:editor basePath="${contextPath}/js" editor="voidTemplate"         value="${settingForm.voidTemplate}" /></td>
</tr>

basePath=”${contextPath}/js is location where the ckeditor javascript located

Start deploying the application, you should be able to use the CK Editor as your RTE.

 

 

Advertisements

ESB Dengan Mule II

Saya beramsusi kamu mengahui kenapa musti menggunakan ESB, jika belom silahkan baca post sebelumnya di esb-dengan-mule-i.

Jika sudah tahu kenapa dan kapan kita membutuhkan maka mari kita kupas salah satu technology ESB dimulai dari installasi hingga mempeljari kasus per kasus.

Langkah pertama, unduh Anypoint studio (dulu di sebut studio) di http://www.mulesoft.org/ dan install di PC kamu.

Oh ya, sebelum menginstall pastikan kamu sudah menginstall Java JDK dan mengeset JAVA_HOME, minimal java version 7.

Seperti ini penampakan saat anypoint studio, jika kamu terbiasa menggunakan eclipse maka akan jauh lebih mudah, jika tidakpun tidak mengapa 🙂anypoint

Langkah selanjutnya adalah menginstall plugin community edition (by default Anypoint hanya memilki runtime untuk Enterprise edition)

installcommunity

Kemudian tambahkan mule studio runtime plugin atau update jika sudah ada

StudioRuntimes

Click tombol next, kamu bisa memilih versi CE yang kamu butuhkan

36CmtyEd

 

Jika sudah berhasil, maka kamu bisa memulai membuat project dengan menggunakan Anypoint Community edition seperti ini

36CEEEProject

Selamat mencoba 🙂

 

 

 

 

 

 

 

 

 

ESB Dengan Mule I

Kapan kamu membutuhkan ESB Enterprise Service Bus?

Pertanyaan ini untuk mempermudah kita memahami apa itu ESB.

1. Di saat kamu perlu mengintegrasikan 2 atau lebih aplikasi/sistem.

2. Kamu perlu mengekspose API untuk di gunakan oleh sistem lain yang notabene milik perusahaan lain

3. Berbagai legacy sistem dengan input atau output yang berbagai macam dan input/ouput ini perlu di gabungkan dan ‘berbicara’ antara satu dengan yang lainnya.

Kata kunci dari kebutuhan-kebutuhan di atas adalaha INTEGRASI, API dan MULTI SYSTEM.

 

Integrasi bisa dalam bentuk yang paling sederhana yaitu pertukaran file hingga dalam bentuk Web Service (ini yang paling umum).

Bisa saja integrasi ini dilakukan dengan mendevelop aplikasi setelah kedua aplikasi sepakat bagaimana integrasi dan formatnya jika (jika itu file).  Hanya saja solusi ini tidak praktis, karena setiap ada perubahan, misal penambahan field akan butuh effort yang banyak. Selain itu jika yang di integrasikan lebih banyak aplikasi dan banyak inbound dan outbound (istilah dalam ESB yang mewakili endpoint atau invoker/pemanggill), develop aplikasi sendiri akan sangat tidak mantainable.

ESB menawarkan sebagai solusi untuk integrasi banyak aplikasi dengan mudah, baik aplikasi itu sudah dalam produks (legacy) ataupun jika hendak mengekspose API agar sistem lain bisa ‘komunikasi’ dengan sistem kita.

 

Ubuntu Environment Preparation as web server

Install JAVA

============

sudo apt-get purge openjdk*

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java7-installer

Install  Apache + Tomcat

========================

http://thetechnocratnotebook.blogspot.ae/2012/05/installing-tomcat-7-and-apache2-with.html

sudo apt-get install apache2

sudo apt-get install tomcat7

sudo apt-get install libapache2-mod-jk

sudo vim /etc/tomcat7/server.xml

–un comment the line below

<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ />

sudo vim /etc/apache2/workers.properties

# Define 1 real worker using ajp13

worker.list=worker1

# Set properties for worker (ajp13)

worker.worker1.type=ajp13

worker.worker1.host=localhost

worker.worker1.port=8009

sudo vim /etc/apache2/mods-available/jk.conf

change the JkWorkersFile property to /etc/apache2/workers.properties

sudo vim /etc/apache2/sites-enabled/000-default

JkMount /tomcat-demo* worker1

Install MySQL

============

https://help.ubuntu.com/12.04/serverguide/mysql.html

sudo apt-get install mysql-server

vim /etc/mysql/my.cnf

bind-address            = 192.XX.X.X

sudo service mysql restart

TOMCAT Detail:

————–

Tomcat Path: cd /var/lib/tomcat7/webapps

/usr/share/tomcat7

Develop Portal using liferay I-Develop Portlet

Lets begin on  how to build a portal with liferay. Familiarize with below term while develop portal:

  1. Portlet.
  2. Theme
  3. Hook
  4. Layout

Capability on develop those four components is necessary in order to build a portal.

I assume you familiar with Java in order to develop portlet while 3 others component is good to have but not mandatory.

Preparation

Install it liferay eclipse plugin(http://releases.liferay.com/tools/ide/latest/stable/)

Download liferay SDK  and extract it

Download liferay tomcat bundled (6.2 CE edition) and extract it

Configure Eclipse for SDK liferay and tomcat bundled refer to image below for this step

Image

 

Now let’s rock by creating a project for a portlet

Create new project (we will use ant instead of maven since its easier.

Image

Image

The generated code will be like this

Image

Start to deploy your first portlet

 

 

Image

Start Server

 

Image

 

Check if Ojolali portlet is deployed

Image

In view mode after added into a page looks like below

 

 

 

Image

Now you can start build your own portlet. 🙂

The source code for article can be downloaded from

 

 

Exposing Simple REST Service

Exposing Simple REST Service.

Mule Studio, adding Community Edition Lib

Mule Studio by default is using

 

In order to install Community Edition following is the step:

1.  Click Help=>Install New Sofware.

2. Shoose All Available Sites

3. Click in tick box for MuleStudio Community Runtimes

4. Click Next keep continue 🙂

 

Here is the screenshoot that might help you guys

 

 

Screenshot_1

 

 

Happy Muleeeee