Wednesday 31 October 2007

* How you can access the class from other project under eclipse

* How you can access the class from other project under eclipse

- Scenario
*** Project1
------ com.ssr1.yy (package)
------------ a1a.java
------------ b1b.java
------ com.ssr2.yy (package)
------------ a2a.java
------------ b2b.java

*** Project2
----- com.rr1.yy (package)
------------ cc1.java


you are supposed developing "project2" with eclipse like above enviroment.

Now you are trying to access some class that is located in "Project1" , suppose it is a1a.java

You want to access or create "a1a.java"(Project1) object from "cc1.java"(Project2)

Then you should customize some of enviroment (MANIFEST.MF) .

1. open MANIFEST.MF from Project1

2. Click "Runtime" tab on the bottom

3. Click "Add" button under "Exported Packages" title

4. select or type "com.ss1.yy" because "a1a.java" file is located under that pacakge name.

5. click ok and save it

6. Compile it
-----------------------
7. open MANIFEST.MF from Project2

8. Click "Dependencies" tab

9. click "Add" button under "Required Plug-in"

10. select or type "Project1" because a1a.java file is located under that project

11. click ok and save it

== Now you can create or access a1a.java file from cc1.java file ====

Monday 29 October 2007

Dom & ArrayList example

package com.samsung.dpd.everest.presentation.sespsdk.sample.loginapp.authn.localdb;

import java.io.File;
import java.util.ArrayList;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import com.samsung.dpd.everest.presentation.sespsdk.sample.loginapp.ui.LocalDbLocalUiServlet;

public class XMLparsing {

//private static final String _USER_DB_ = LocalDbLocalUiServlet._AUTHN_ +"/users.xml";
private static final String _USER_DB_ = "users.xml";

public XMLparsing() {
// TODO Auto-generated constructor stub
}

public static void main (String args []){
ArrayList v1 = new ArrayList();

UserAll ua = new UserAll();
XMLparsing s = new XMLparsing();
v1 = s.getInfoAll();
System.out.println("======================================");
for (int i =0 ; i < v1.size(); i++){
ua = (UserAll)v1.get(i);
System.out.println("11 : "+ ua.getUname());
}
}

public ArrayList getInfoAll() {

ArrayList v = new ArrayList();

try {
File file= new File(XMLparsing._USER_DB_);
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(file);
doc.getDocumentElement().normalize();
System.out.println("Root element : "+doc.getDocumentElement().getNodeName());
NodeList nodeList = doc.getElementsByTagName("user");
System.out.println("Information of all users");

for (int s = 0; s < nodeList.getLength(); s++){
UserAll ua = new UserAll();
Node fstNode = nodeList.item(s);

if (fstNode.getNodeType() == Node.ELEMENT_NODE){
Element fstElmnt = (Element)fstNode;
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName("username");
Element fstNmElmnt = (Element)fstNmElmntLst.item(0);
NodeList fstNm = fstNmElmnt.getChildNodes();
System.out.println("user name : "+((Node)fstNm.item(0)).getNodeValue());
ua.setUname(((Node)fstNm.item(0)).getNodeValue());


NodeList fstNmElmntLst2 = fstElmnt.getElementsByTagName("userpassword");
Element fstNmElmnt2 = (Element)fstNmElmntLst2.item(0);
NodeList fstNm2 = fstNmElmnt2.getChildNodes();
System.out.println("user userpassword : "+((Node)fstNm2.item(0)).getNodeValue());
ua.setUpassword(((Node)fstNm2.item(0)).getNodeValue());

NodeList fstNmElmntLst3 = fstElmnt.getElementsByTagName("email");
Element fstNmElmnt3 = (Element)fstNmElmntLst3.item(0);
NodeList fstNm3 = fstNmElmnt3.getChildNodes();
System.out.println("user email : "+((Node)fstNm3.item(0)).getNodeValue());
ua.setUemail(((Node)fstNm3.item(0)).getNodeValue());

NodeList fstNmElmntLst4 = fstElmnt.getElementsByTagName("role");
Element fstNmElmnt4 = (Element)fstNmElmntLst4.item(0);
NodeList fstNm4 = fstNmElmnt4.getChildNodes();
System.out.println("user role : "+((Node)fstNm4.item(0)).getNodeValue());
ua.setUrole(((Node)fstNm4.item(0)).getNodeValue());
}
v.add(ua);
}


} catch (Exception e){
e.printStackTrace();
}

return v;
}

}

Sunday 28 October 2007

[HTML TIP] Create layout in Table

[table style="width:100%; height:100%; table-layout:fixed;border:0px solid;margin:0 auto"]
[tr][td valign="top"]
[div id="workformListDivId" style="overflow:auto;width:100%;height:96%;border:0;"]
[/div]tothe
[/td][/tr]
[/table]

......

key - word : table-layout and style="overflow:auto;width:100%;height:96%;border:0;"


=============== Example ====================
<table style="width:100%; height:100%; table-layout:fixed;border:0px solid;margin:0 auto">
<tr><td valign="top">
<div id="workformListDivId" style="overflow:auto;width:100;height:100;border:0;">
<table>
<tr>
<td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td>
</tr>
<tr>
<td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td>
</tr>
<tr>
<td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td>
</tr>
<tr>
<td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td>
</tr>
<tr>
<td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td><td>ssrfdas</td>
</tr>
</table>
</div>tothe
</td></tr>
</table>

Thursday 25 October 2007

simple Drag and drop example

* This is a simple example for drag and drop in limited area.

see here

Thursday 18 October 2007

Install JDK under linux

Install JDK under linux

1. download jdk installation file such as "jdk-6u3-linux-i586.rpm.bin"

2. open terminal and run "chmod a+x jdk-6u3-linux-i586.rpm.bin

3. ./j2sdk-1_4_2_-linux-i586.rpm.bin

4. agree the license

5. rpm -iv j2sdk-1_4_2_-linux-i586.rpm

Monday 15 October 2007

ENUM example in JAVA

** ENUM Example

==== ENUM_Season.java =====
public enum ENUM_Season {
SPRING, SUMMER, FALL, WINTER
}


==== ENUM_Season01_A.java ===

public class ENUM_Season01_A {
public static void main(String[] args) {
ENUM_Season season = ENUM_Season.SUMMER;
System.out.println(season);
if (season.equals(ENUM_Season.SPRING) == true) {
System.out.println("the current season is SPRING.");
}else {
System.out.println("the current season is not SPRING.");
}
}
}

===== Output ===
SUMMER
the current season is not SPRING.

Wednesday 3 October 2007

web developing with eclipse, my-sql

* web developing with eclipse, my-sql
eclipse 3.3 - WTP
DB - My-sql 5.0 (http://www.mysql.com/downloads)
Web server - Tomcat 6.0

This example describe how we can create web project under eclipse with my-sql.

See here

Tuesday 2 October 2007

Tomcat + eclipse error handle

* Tomcat 6.0 + eclipse 3.3 (WTP)

======= Error message ==========
Servlet.service() for servlet jsp threw exception
java.lang.NoClassDefFoundError: javax/el/ELResolver
...
...

> there are no el-api.jar file in jdk 1.x ext folder

Solution
- Please copy el-api.jar file from Tomcat_Home\lib
- paste el-api.jar file to JAVA_HOME\jre\lib\ext