Orange Pi Zero - node.js 설치

OS/Orange PI 2017.12.17 20:18 Posted by 파란크리스마스

출처 : orange-pi-gpio - npm
GitHub - BorisKotlyarov/orange-pi-gpio
Arduino Slovakia - Orange Pi Zero and Node.js

node.js 6.X 설치

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

node.js 8.X 설치

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

node.js 설치 확인

$ node -v
v8.9.3
$ npm -v
5.5.1

orange-pi-gpio 라이브러리 설치

출처 : GitHub - BorisKotlyarov/orange-pi-gpio

$ npm i orange-pi-gpio
npm WARN saveError ENOENT: no such file or directory, open '/home/pi/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/pi/package.json'
npm WARN pi No description
npm WARN pi No repository field.
npm WARN pi No README data
npm WARN pi No license field.
 
+ orange-pi-gpio@1.0.2
added 1 package in 6.975s

LED 제어

소스

const Gpio = require('orange-pi-gpio');

let gpio14 = new Gpio({pin:14, mode: 'out', ready: ()=>{
    let value = 1;

    setInterval(function() {
        process.stdout.write('\x1B[2J\x1B[0f\u001b[0;0H');

        if(value){
            console.log('\x1b[32m%s\x1b[0m', `ON`);
        } else {
            console.log('\x1b[31m%s\x1b[0m', `OFF`);
        }
        
        gpio14.write(value);
        value = +!value;
    }, 50);

}});

실행

$ node LEDDemo.js 

Orange Pi Zero - pi4j

OS/Orange PI 2017.12.17 19:19 Posted by 파란크리스마스

출처 : ORANGE PI ZERO PIN · Issue #333 · Pi4J/pi4j · GitHub

pi4 다운로드

$ wget http://get.pi4j.com/download/pi4j-1.2-SNAPSHOT.zip

pi4 압축풀기

$ unzip pi4j-1.2-SNAPSHOT.zip

LED 제어

소스

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

public class LEDDemo {

	public static void main(String[] args) throws InterruptedException {
		
		// GPIO controller
		final GpioController gpio = GpioFactory.getInstance();
		
		// 14번 핀 모드 변경
		GpioPinDigitalOutput myLed = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_14, // PIN NUMBER
				"My LED", // PIN FRIENDLY NAME (optional)
				PinState.LOW); // PIN STARTUP STATE (optional)
		
		// LED 켜기
		myLed.setState(PinState.HIGH);

		// 5초 대기
		Thread.sleep(5000);

		// LED 끄기
		myLed.setState(PinState.LOW);

		// GPIO controller 리스스 반환
		gpio.shutdown();
	}
}

컴파일

$ javac -cp .:pi4j-1.2-SNAPSHOT/lib/* -d . LEDDemo.java

실행

$ sudo java -cp .:pi4j-1.2-SNAPSHOT/lib/* -Dpi4j.linking=dynamic LEDDemo

Orange Pi Zero - WiringOP

OS/Orange PI 2017.12.17 00:05 Posted by 파란크리스마스

출처 : GitHub - xpertsavenue/WiringOP-Zero: WiringPi / WiringPi / WiringOP libary for the Orange Pi Zero with 26 pin GPIO header

WiringOP-Zero 설치

WiringOP-Zero 소스 다운로드

$ git clone https://github.com/xpertsavenue/WiringOP-Zero.git

WiringOP-Zero 컴파일및 설치

$ cd WiringOP-Zero
$ chmod +x ./build
$ sudo ./build
 
.. 생략 ...
 
[Install Headers]
[Install Dynamic Lib]
 
WiringPi Devices Library
[UnInstall]
make: Nothing to be done for 'all'.
[Install Headers]
[Install Dynamic Lib]
 
GPIO Utility
[Link]
[Install]
 
All Done.
 
NOTE: To compile programs with wiringBP v2, you need to add:
    -lwiringPi
  to your compile line(s) To use the Gertboard, MaxDetect, etc.
  code (the devLib), you need to also add:
    -lwiringPiDev
  to your compile line(s).

설치 확인

$ gpio readall
 +-----+-----+----------+------+--Orange Pi Zero--+---+------+---------+-----+--+
 | H2+ | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | H2+ |
 +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
 |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |
 |  12 |   8 |    SDA.0 | ALT5 | 0 |  3 || 4  |   |      | 5V       |     |     |
 |  11 |   9 |    SCL.0 | ALT5 | 0 |  5 || 6  |   |      | 0v       |     |     |
 |   6 |   7 |   GPIO.7 | ALT3 | 0 |  7 || 8  | 0 | ALT5 | TxD3     | 15  | 198 |
 |     |     |       0v |      |   |  9 || 10 | 0 | ALT5 | RxD3     | 16  | 199 |
 |   1 |   0 |     RxD2 | ALT5 | 0 | 11 || 12 | 0 | ALT3 | GPIO.1   | 1   | 7   |
 |   0 |   2 |     TxD2 | ALT5 | 0 | 13 || 14 |   |      | 0v       |     |     |
 |   3 |   3 |     CTS2 | ALT3 | 0 | 15 || 16 | 0 | ALT4 | GPIO.4   | 4   | 19  |
 |     |     |     3.3v |      |   | 17 || 18 | 0 | ALT4 | GPIO.5   | 5   | 18  |
 |  15 |  12 |     MOSI | ALT5 | 0 | 19 || 20 |   |      | 0v       |     |     |
 |  16 |  13 |     MISO | ALT5 | 0 | 21 || 22 | 0 | ALT3 | RTS2     | 6   | 2   |
 |  14 |  14 |     SCLK | ALT5 | 0 | 23 || 24 | 0 | ALT5 | CE0      | 10  | 13  |
 |     |     |       0v |      |   | 25 || 26 | 0 | ALT3 | GPIO.11  | 11  | 10  |
 +-----+-----+----------+------+---+---LEDs---+---+------+----------+-----+-----+
 |  17 |  30 | STAT-LED |  OUT | 0 | 27 || 28 |   |      | PWR-LED  |     |     |
 +-----+-----+----------+------+---+-----+----+---+------+----------+-----+-----+
 | H2+ | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | H2+ |
 +-----+-----+----------+------+--Orange Pi Zero--+---+------+---------+-----+--+

LED 제어

GPIO 모드 변경

$  gpio mode 14 out

LED 켜기

$ gpio write 14 1

LED 끄기

$ gpio write 14 0

Orange Pi Zero 512MB

OS/Orange PI 2017.12.15 00:58 Posted by 파란크리스마스

Orange PI Zero

출처 : 스터디메이크 :: 오렌지파이 제로 보드 간단 사용기
Xunlong Orange Pi Zero

 

OS 설치

OS 다운로드 - Orange Pi Zero – armbian

UART USB 케이블 연결

부팅후 계정 설정

Ubuntu 16.04.3 LTS orangepizero ttyS0

orangepizero login: root
Password: [1234]
You are required to change your password immediately (root enforced)
Changing password for root.
(current) UNIX password: [1234]
Enter new UNIX password: [orangepi]
Retype new UNIX password: [orangepi]
  ___                               ____  _   _____              
 / _ \ _ __ __ _ _ __   __ _  ___  |  _ \(_) |__  /___ _ __ ___  
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | |   / // _ \ '__/ _ \ 
| |_| | | | (_| | | | | (_| |  __/ |  __/| |  / /|  __/ | | (_) |
 \___/|_|  \__,_|_| |_|\__, |\___| |_|   |_| /____\___|_|  \___/ 
                       |___/                                     

Welcome to ARMBIAN 5.35 user-built Ubuntu 16.04.3 LTS 3.4.113-sun8i   
System load:   0.03 0.14 0.07   Up time:       4 min
Memory usage:  6 % of 494MB     IP:            
CPU temp:      46°C           
Usage of /:    71% of 1.4G   

[ General system configuration (beta): armbian-config ]

Warning: a reboot is needed to finish resizing the filesystem  
Please reboot the system as soon as possible  
New to Armbian? Check the documentation first: https://docs.armbian.com


Thank you for choosing Armbian! Support: www.armbian.com

Creating a new user account. Press  to abort

Please provide a username (eg. your forename): pi
Trying to add user pi
Adding user `pi' ...
Adding new group `pi' (1000) ...
Adding new user `pi' (1000) with group `pi' ...
Creating home directory `/home/pi' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: [orangepi]
Retype new UNIX password: [orangepi]
passwd: password updated successfully
Changing the user information for pi
Enter the new value, or press ENTER for the default
        Full Name []: pi
        Room Number []: 
        Work Phone []: 
        Home Phone []: 
        Other []: 
Is the information correct? [Y/n] 

Dear pi, your account pi has been created and is sudo enabled.
Please use this account for your daily work from now on.



Warning: a reboot is needed to finish resizing the filesystem  
Please reboot the system now  

root@orangepizero:~# 

Wifi 설정

출처 : 014. Raspberry Pi 라즈베리 파이 - wheezy무선랜 ... - Tsunami - Tistory

$ cd /etc/ifplugd/action.d/
$ sudo mv ifupdown ifupdown.bk
$ sudo cp /etc/wpa_supplicant/ifupdown.sh ./ifupdown

armbian 와이파이 설정

출처 : 오렌지파이 제로 무선인터넷 설정 1.2 암비안 와이파이 설정

$ sudo nmtui

SD 확장

SD 확장전 용량확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            181M     0  181M   0% /dev
tmpfs            50M  1.2M   49M   3% /run
/dev/mmcblk0p1  7.2G  1.1G  6.1G  15% /
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs           248M     0  248M   0% /tmp
log2ram          50M  1.3M   49M   3% /var/log
tmpfs            50M     0   50M   0% /run/user/1000

SD FDisk

pi@orangepizero:~$ sudo fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa3a6ea09

Device         Boot Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       8192 15213343 15205152  7.3G 83 Linux

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-31116287, default 2048): 8192
Last sector, +sectors or +size{K,M,G,T,P} (8192-31116287, default 31116287): 

Created a new partition 1 of type 'Linux' and of size 14.9 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

pi@orangepizero:~$ sudo shutdown -r now

SD 확장

$ sudo resize2fs /dev/mmcblk0p1
[sudo] password for pi: 
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/mmcblk0p1 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p1 is now 3888512 (4k) blocks long.

SD 확장 확인

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            181M     0  181M   0% /dev
tmpfs            50M  1.2M   49M   3% /run
/dev/mmcblk0p1   15G  1.1G   14G   8% /
tmpfs           248M     0  248M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           248M     0  248M   0% /sys/fs/cgroup
tmpfs           248M     0  248M   0% /tmp
log2ram          50M  1.5M   49M   3% /var/log
tmpfs            50M     0   50M   0% /run/user/1000

JDK 설치

출처 : Install Java 8 on Armbian (Orange Pi Lite or higher) • DIY Projects

저장소 추가

$ sudo add-apt-repository ppa:webupd8team/java

추가한 저장소 반영

$ sudo apt-get update

JDK 설치

$ sudo apt-get install oracle-java8-installer

JAVA_HOME 환경변수 추가

$ sudo vi /etc/profile

내용 추가 export JAVA_HOME=/usr/lib/jvm/java-8-oracle

export JAVA_HOME=/usr/lib/jvm/java-8-oracle

JDK 설치 확인

$ $JAVA_HOME/bin/java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) Client VM (build 25.151-b12, mixed mode)

CentOS - nodejs

분류없음 2017.12.10 10:34 Posted by 파란크리스마스

출처 : n 을 이용한 nodejs 설치 및 관리 CentOs yum install ... - Blue Breeze
linuxism :: node.js - CentOS에서 설치(install in linux)

node.js 설치 확인

# rpm -qa | grep nodejs
# node -v
-bash: node: command not found

node.js 설치

오류 확인

# yum install nodejs
Loaded plugins: fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: ftp.kaist.ac.kr
 * extras: ftp.kaist.ac.kr
 * updates: ftp.kaist.ac.kr
base                                                                                                  | 3.7 kB     00:00     
extras                                                                                                | 3.4 kB     00:00     
updates                                                                                               | 3.4 kB     00:00     
No package nodejs available.
Error: Nothing to do

오류 해결

# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

## Installing the NodeSource Node.js 6.x repo...
 
... 생략 ...
 
## Run `yum install -y nodejs` (as root) to install Node.js 6.x and npm.
## You may also need development tools to build native addons:
##   `yum install -y gcc-c++ make`

node.js 설치

# yum install -y nodejs

node.js 라이브러리 컴파일용 g++설치 (옵션)

# yum install -y gcc-c++ make

node.js 설치확인

# node -v
v6.12.2

WeMos - D1

OS/Arduino 2017.12.10 00:43 Posted by 파란크리스마스

출처 : 아두이노 WeMos 환경 셋팅 및 기본예제 | 프로젝트 | 메이크위드
CodeBlog: ESP8266, WeMos D1 R1, D1 R2 and D1 Mini pins

아두이노 IDE에 보드 추가하기

COM 포트가 추가된 것을 확인

메뉴 [파일] -> [환경설정] 선택

[환경설정]창에서 Additional Board Manager URLs 항목 설정

보드관련 정보가 있는 URL를 http://arduino.esp8266.com/stable/package_esp8266com_index.json 붙여넣기

메뉴 [도구] -> [보드] -> [Boards Manager...] 선택

[Boards Manager] 창에서 esp8266 검색하고, [Install] 버튼 석택

메뉴 [도구]에서 보드와 포트 선택

LED 켜기

// LED가 연결된 PIN번호
int led = D15;

// 초기화
void setup() { 
  pinMode(led, OUTPUT); 
}

// 무한 반복
void loop() {
  digitalWrite(led, HIGH); // LED 켜기
  delay(1000); // 1초 대기
  digitalWrite(led, LOW); // LED 끄기
  delay(1000); // 1초 대기
}

PWM 예제

아두이노에서는 analogWrite 함수를 통해서 이러한 PWM 출력을 제공하는데, analogWrite 함수의 인자 범위는 아두이노 우노 R3의 경우 0~255까지의 정수를 사용하지만, D1의 경우 0~1023까지의 정수를 사용한다.

// LED가 연결된 PIN번호
int ledPin = D6;
 
// 초기화
void setup() {
  // 출력 모드 설정
  pinMode(ledPin, OUTPUT);   // sets the pin as output
}
 
// 무한 반복
void loop() {
  // 25 단위로 반복 / PWM 번위 0~1023
  for(int angle = 0; angle < 1023; angle=angle+5) {
    // PWM 출력
    analogWrite(ledPin, angle);
    delay(15);
  }
}

SG90 서브모터 제어

[Arduino|아두이노] 서보모터(SG90) 구동하는 방법 (Tower Pro, Micro Servo, B10K, 가변저항) - 젠트의 프로그래밍 세상

#include <Servo.h> 

Servo servo;
 
int servoPin = D3;
int angle = 0; // servo position in degrees 

// 초기화
void setup() { 
  servo.attach(servoPin);
} 

// 무한 반복
void loop() { 
  // rotate from 0 to 180degrees
  for(angle = 0; angle < 180; angle++) { 
    servo.write(angle); 
    delay(15); 
  } 
}

RC Car - L298N Dual H-Bridge

Reference · ESP8266 Arduino Core

//모터A 컨트롤
int enA = D3;
int IN1=D4;
int IN2=D5;
 
//모터B 컨트롤
int enB = D10;
int IN3=D8;
int IN4=D9;

#define MOTER_SPEED 1023 // MAX 1023
 
void setup() {
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT);
  pinMode(IN3,OUTPUT);
  pinMode(IN4,OUTPUT);
}
 
void loop() {
  
  analogWrite(enA, MOTER_SPEED);
  analogWrite(enB, MOTER_SPEED);
  
  /*
  digitalWrite(enA,HIGH);
  digitalWrite(enB,HIGH);
  */
  bothMotorStart(); // 전진
  delay(3000);
  turnLeft(); // 왼쪽으로 턴
  delay(3000);
  turnRight(); // 오른쪽으로 턴
  delay(3000);
  motorA_Rotation(); // 오른쪽만 정방향
  delay(3000);
  motorB_Rotation(); // 왼쪽만 정방향
  delay(3000);
  motorA_Reverse(); // 오른쪽만 역방향
  delay(3000);
  motorB_Reverse(); // 왼쪽만 역방향
  delay(3000);
  stopAllMotor(); // 정지
  delay(3000);
}
 
//모터A,B 정회전
void bothMotorStart()
{
    digitalWrite(IN1,HIGH);
    digitalWrite(IN2,LOW);
    digitalWrite(IN3,HIGH);
    digitalWrite(IN4,LOW);
}
 
//모터A,B Stop
void stopAllMotor()
{
    digitalWrite(IN1,LOW);
    digitalWrite(IN2,LOW);
    digitalWrite(IN3,LOW);
    digitalWrite(IN4,LOW);
}
 
//모터A 역회전, 모터B 정회전
void turnLeft()
{
    digitalWrite(IN1,LOW);
    digitalWrite(IN2,HIGH);
    digitalWrite(IN3,HIGH);
    digitalWrite(IN4,LOW);
}
 
//모터A 정회전, 모터B 역회전
void turnRight()
{
    digitalWrite(IN1,HIGH);
    digitalWrite(IN2,LOW);
    digitalWrite(IN3,LOW);
    digitalWrite(IN4,HIGH);
}
 
//모터A 정회전, 모터B Stop
void motorA_Rotation()
{
    digitalWrite(IN1,HIGH);
    digitalWrite(IN2,LOW);
    digitalWrite(IN3,LOW);
    digitalWrite(IN4,LOW);
}
 
//모터A Stop, 모터B 정회전
void motorB_Rotation()
{
    digitalWrite(IN1,LOW);
    digitalWrite(IN2,LOW);
    digitalWrite(IN3,HIGH);
    digitalWrite(IN4,LOW);
}
 
//모터A 역회전, 모터B Stop
void motorA_Reverse()
{
    digitalWrite(IN1,LOW);
    digitalWrite(IN2,HIGH);
    digitalWrite(IN3,LOW);
    digitalWrite(IN4,LOW);
}
 
//모터A Stop, 모터B 역회전
void motorB_Reverse()
{
    digitalWrite(IN1,LOW);
    digitalWrite(IN2,LOW);
    digitalWrite(IN3,LOW);
    digitalWrite(IN4,HIGH);
}


TOMCAT - jmx 로 monitoring

Programming/Java 2017.12.07 23:46 Posted by 파란크리스마스

출처 : 아파치 톰캣(apache tomcat) 을 jmx 로 monitoring 하기

catalina-jmx-remote.jar 파일 Tomcat이 설치된 디렉토리의 lib디렉토리에 복사

https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.23/bin/extras/

$ cd /usr/local/apache-tomcat-8.5.23/lib
$ wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.23/bin/extras/catalina-jmx-remote.jar

IP 확인

$ ifconfig | grep "inet addr"
          inet addr:192.168.0.24  Bcast:192.168.0.255  Mask:255.255.255.0
          inet addr:127.0.0.1  Mask:255.0.0.0

setenv.sh 파일 생성

$ cd /usr/local/apache-tomcat-8.5.23/bin

setenv.sh 파일 내용

$ vi setenv.sh
  • -Dcom.sun.management.jmxremote.authenticate=false / 인증하지 않음
  • -Djava.rmi.server.hostname=192.168.0.24 / 톰캣이 구동되는 서버의 IP
  • -Dcom.sun.management.jmxremote.ssl=false / SSL 을 사용하지 않음
#!/bin/sh

JMX_OPTS=" -Dcom.sun.management.jmxremote \
                 -Dcom.sun.management.jmxremote.authenticate=false \
                 -Djava.rmi.server.hostname=192.168.0.24 \
                 -Dcom.sun.management.jmxremote.ssl=false "
CATALINA_OPTS=" ${JMX_OPTS} ${CATALINA_OPTS}"

conf/server.xml 수정 - Listener 추가

<Server port="8005" shutdown="SHUTDOWN">

<!-- 생략 --->

<Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener"
        rmiRegistryPortPlatform="9840" rmiServerPortPlatform="9841"/>

jdk의 jconsole.exe 실행

권한파일(jmxremote.access)과 로그인 암호파일(jmxremote.password) 생성

$ cd /usr/local/apache-tomcat-8.5.23/
$ echo -e "monitorRole readonly\ncontrolRole readwrite" > conf/jmxremote.access
$ cat conf/jmxremote.access
monitorRole readonly
controlRole readwrite
$ echo -e "monitorRole tomcat\ncontrolRole tomcat" > conf/jmxremote.password
$ cat conf/jmxremote.password
monitorRole tomcat
controlRole tomcat

setenv.sh 파일 수정

$ cd /usr/local/apache-tomcat-8.5.23/bin
$ vi setenv.sh

#!/bin/sh

JMX_OPTS=" -Dcom.sun.management.jmxremote \
           -Dcom.sun.management.jmxremote.authenticate=true \
           -Dcom.sun.management.jmxremote.password.file=$CATALINA_BASE/conf/jmxremote.password  \
           -Dcom.sun.management.jmxremote.access.file=$CATALINA_BASE/conf/jmxremote.access  \
           -Djava.rmi.server.hostname=192.168.0.24 \
           -Dcom.sun.management.jmxremote.ssl=false "
CATALINA_OPTS=" ${JMX_OPTS} ${CATALINA_OPTS}"

setenv.bat 파일 내용 - Windows 용

set JMX_OPTS=-Dcom.sun.management.jmxremote ^
-Dcom.sun.management.jmxremote.authenticate=true ^
-Dcom.sun.management.jmxremote.password.file=%CATALINA_HOME%/conf/jmxremote.password ^
-Dcom.sun.management.jmxremote.access.file=%CATALINA_HOME%/conf/jmxremote.access ^
-Djava.rmi.server.hostname=192.168.0.31 ^
-Dcom.sun.management.jmxremote.ssl=false

set CATALINA_OPTS=%JMX_OPTS% %CATALINA_OPTS%

Nexacro - 공통라이브러리, 공통 팝업 사용하기

Programming/Nexacro 2017.12.03 14:38 Posted by 파란크리스마스

출처 : 넥사크로플랫폼(nexacro platform) HTML5 API 설치

기존 Nexacro 프로젝트 폴더에서 frame, image, lib 폴더를 복사해서 현재 프로젝트에 붙여넣기

복사한 폴더 등록 (서비스 등록)

TypeDefinition 더블 클릭

[Services] 텝 [Add] 버튼 선택

frame 추가

image 추가

lib 추가

추가된 목록

등록 확인

공통 라이브러리 참조

include "lib::comLib.xjs"

Nexacro - Grid에 CheckBox 추가 하기

Programming/Nexacro 2017.12.03 11:59 Posted by 파란크리스마스

출처 : 파트 IV. 컴포넌트 / 16. Grid 16.10그리드 행/열 합계 - 넥사크로플랫폼 ...
농부지기 :: Nexacro.Grid - all Checked 처리
농부지기 :: Nexacro.Grid - grid header

Dataset에 Checkbox의 체크값을 저장하기 위한 컬럼 추가

컬럼 추가 버튼 선택

chk 컬럼 추가

Grid의 컬럼 추가

[Insert] 버튼을 선택하여 Grid에 컬럼을 추가

컬럼헤더의 text 수정

컬럼의 expr, text 수정

  • expr : expr:chk=='Y'?'1':'0'
  • text : bind:chk

컬럼의 displaytype, edittype를 checkbox로 수정

  • displaytype : checkbox
  • edittype : checkbox

Grid의 Checkbox 컬럼의 체크 값 변경시 Dataset에 반영되도록 스크립트 작성

Nexacro 의 체크박스는 체크가 된 경우 1 / 체크가 되지 않은 경우 0의 Dataset의 체크값을 변경하기 위해서 스크립트 작성

this.Dataset00_oncolumnchanged = function(obj:Dataset, e:nexacro.DSColChangeEventInfo)
{
	// chk 컬럼인 경우
	if(e.columnid == "chk") {
		// 다른 이벤트가 동작하지 않도록 설정
		obj.enableevent = false;  //false can stop event temporarily  
		// 변경된 값이 1(체크가 된 경우)인경우
		if(e.newvalue == '1') {
			// 1인 경우 Dataset의 chk 값을 Y로 변경
			obj.setColumn(e.row,"chk",'Y');
		} else if(e.newvalue == '0') {
			// 0인 경우 Dataset의 chk 값을 N로 변경
			obj.setColumn(e.row,"chk",'N');  
		}
		// 다시 이벤트가 정상 동작하도록 설정
		obj.enableevent = true;
	}
}

체크값 전달을 위해서 SampleVO 클래스에 chk 변수 추가

public class SampleVO extends DefaultVO implements Serializable {
	
	private java.lang.String chk;

// ... 생략 ...

	public java.lang.String getChk() {
		return chk;
	}

	public void setChk(java.lang.String chk) {
		this.chk = chk;
	}


... 생략 ...

컬럼 헤더 클릭시 체크박스 전부 선택되도록 스크립트 작성

this.Grid00_onheadclick = function(obj:Grid, e:nexacro.GridClickEventInfo)
{
	// 첫 번째 컬럼인 경우
	if (e.col == 0) { 
		// Dataset의 레코드 개수 만큼 반복
		for(var nRow=0; nRow < this.Dataset00.getRowCount(); nRow++) {
			// chk 컬럼의 값을 Y로 변경
			this.Dataset00.setColumn(nRow, "chk", 'Y');
		}
	}
}

체크값 확인

package bizservice.nexa.sample.service;

public class EgovSampleServiceXpImpl extends AbstractServiceImpl implements EgovSampleServiceXp {

	 public void multiDataModifyService(List<Object> tranInfo,
				Map<String, Object> inVar, Map<String, List<Object>> inDataset,
				Map<String, Object> outVar, Map<String, Object> outDataset)
				throws Exception {
				
			//서비스단 개발
			List<Object> list = inDataset.get("input1");
			
			for (int i = 0; i < list.size(); i++) {
				Object obj = list.get(i);
				if (obj instanceof SampleVO){
					SampleVO row = (SampleVO)obj;
					System.out.println("pk.post_id = " + row.getPost_id() + "/체크여부 = " + row.getChk());
					// 추가 작업 구현
				}
			}

조회 SQL문 수정 (src\main\resources\egovframework\sqlmap\bizservice\sample\Sample.xml) - 불필요한 작업

	<!-- Sample resultObject -->
	<resultMap id="sample" class="bizservice.nexa.sample.vo.SampleVO">
		<result property="chk" column="CHK" />  <!-- chk 컬럼 추가 -->

<!-- 생략 -->
        
	<select id="sampleDAO.selectSampleVOList" parameterClass="searchVO" resultMap="sample">
		SELECT 'N' chk,
		       A.num AS num,
 		       A.TITLE AS TITLE, 
		       A.REG_ID AS REG_ID, 
 		       A.REG_DATE AS REG_DATE, 
		       A.POST_ID AS POST_ID, 
		       A.CONTENTS AS CONTENTS, 
		       A.COMMUNITY_ID AS COMMUNITY_ID,
		       A.COUNT AS COUNT
		  FROM XP_BOARD A
		 WHERE 1=1
	</select>

<!-- 생략 -->

CentOS - Tomcat 서비스로 등록

분류없음 2017.12.03 03:26 Posted by 파란크리스마스

출처 : RHEL/CentOS tomcat7 init.d service script. · GitHub

tomcat 서비스 스크립트 작성

$ sudo vi /etc/init.d/tomcat

tomcat 내용

#!/bin/sh
#
# /etc/init.d/tomcat7 -- startup script for the Tomcat 7 servlet engine
#
# Written by Miquel van Smoorenburg .
# Modified for Debian GNU/Linux	by Ian Murdock .
# Modified for Tomcat by Stefan Gybas .
# Modified for Tomcat6 by Thierry Carrez .
# Modified for Tomcat7 by Ernesto Hernandez-Novich .
# Additional improvements by Jason Brittain .
#
### BEGIN INIT INFO
# Provides:          tomcat7
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Should-Start:      $named
# Should-Stop:       $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Tomcat.
# Description:       Start the Tomcat servlet engine.
# sudo update-rc.d tomcat defaults
# sudo update-rc.d tomcat remove
# ls /etc/rc0.d
### END INIT INFO

set -e

## Source function library.
#. /etc/rc.d/init.d/functions
export PROCESS_NAME=tomcat-real
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-1.b12.el6_9.x86_64
export JAVA_OPTS="-Dfile.encoding=UTF-8 \
  -Dcatalina.logbase=/var/log/tomcat \
  -Dnet.sf.ehcache.skipUpdateCheck=true \
  -XX:+DoEscapeAnalysis \
  -XX:+UseConcMarkSweepGC \
  -XX:+CMSClassUnloadingEnabled \
  -XX:+UseParNewGC \
  -Xms1024m -Xmx2048m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=512m -XX:MaxPermSize=512m -XX:+DisableExplicitGC"
export PATH=$JAVA_HOME/bin:$PATH
export TOMCAT_USER=root
export TOMCAT_HOME=/opt/tomcat
export SHUTDOWN_WAIT=20

tomcat_pid() {
  echo `ps aux | grep ${PROCESS_NAME} | grep -v grep | awk '{ print $2 }'`
}

start() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ] 
  then
    echo "Tomcat is already running (pid: $pid)"
  else
    # Start tomcat
    echo "Starting tomcat"
    ulimit -n 100000
    umask 007
    /bin/su - $TOMCAT_USER -c "$TOMCAT_HOME/bin/startup.sh -Dprocessname=${PROCESS_NAME}"
  fi


  return 0
}

stop() {
  pid=$(tomcat_pid)
  if [ -n "$pid" ]
  then
    echo "Stoping Tomcat"
    /bin/su - $TOMCAT_USER -c $TOMCAT_HOME/bin/shutdown.sh

    let kwait=$SHUTDOWN_WAIT
    count=0;
    until [ `ps -p $pid | grep -c $pid` = '0' ] || [ $count -gt $kwait ]
    do
      echo -n -e "\nwaiting for processes to exit";
      sleep 1
      let count=$count+1;
    done

    if [ $count -gt $kwait ]; then
      echo -n -e "\nkilling processes which didn't stop after $SHUTDOWN_WAIT seconds\n"
      kill -9 $pid
    fi
  else
    echo "Tomcat is not running"
  fi
 
  return 0
}

case $1 in
start)
  start
;; 
stop)   
  stop
;; 
restart)
  stop
  start
;;
status)
  pid=$(tomcat_pid)
  if [ -n "$pid" ]
  then
    echo "Tomcat is running with pid: $pid"
  else
    echo "Tomcat is not running"
  fi
;; 
esac    
exit 0

tomcat 파일 실행권한 부여

$ sudo chmod u+x /etc/init.d/tomcat

tomcat 서비스 등록

$ sudo chkconfig --add tomcat

tomcat 서비스 삭제

$ sudo chkconfig --del tomcat

Nexacro - Controller 호출

Programming/Nexacro 2017.11.26 18:49 Posted by 파란크리스마스

출처 : 전자정부 표준프레임워크 3.2 기반 넥사크로 플랫폼 개발자 가이드

Nexacro - 서버 호출 Button 이벤트

this.Button00_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var sSvcID          = "list";                   
    var sController     = "blueController.do";
    var sInDatasets     = "";  
    var sOutDatasets    = "";
    var sArgs="";
    
    // 서비스 아이디
    var strSvcID = {id:sSvcID, outDatasets:sOutDatasets};
    
    // 서비스 변수 값 가지고 오기
    var sSvcUrl = application.services["svcurl"].url;
    // 서버 호출 주소 생성
    var strURL = sSvcUrl + sController;

    // Ex.core.tran(this, sSvcID, sController, sInDatasets, sOutDatasets, sArgs);
    this.transaction(strSvcID, strURL, sInDatasets, sOutDatasets, sArgs, "received", true, false);
}

this.received = function(id, code, message)
{
    alert(code);
}

Server - Controller 클래스 생성

package bizservice.nexa.cmmn.map.controller;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import egovframework.rte.cmmn.ria.nexacro.NexacroConstant;
import egovframework.rte.cmmn.ria.nexacro.map.DataSetMap;
import egovframework.rte.cmmn.ria.nexacro.map.NexacroMapDTO;

@Controller
public class BlueController {

	protected Log logger = LogFactory.getLog(this.getClass());

	@RequestMapping("/blueController.do")
	public ModelAndView operate(NexacroMapDTO xpDto, Model model) throws Exception {

		ModelAndView mav = new ModelAndView("nexacroMapView");

		try {
			DataSetMap tranInfo 				= xpDto.getTranInfoMap();
			Map <String, Object> inVar 			= xpDto.getInVariableMap();
			Map <String, DataSetMap> inDataset 	= xpDto.getInDataSetMap();
			Map <String, Object> outVar 		= xpDto.getOutVariableMap();
			Map <String, DataSetMap> outDataset = xpDto.getOutDataSetMap();
			
			System.out.println("tranInfo : " + tranInfo);
			System.out.println("inVar : " + inVar);
			System.out.println("inDataset : " + inDataset);
			System.out.println("outVar : " + outVar);
			System.out.println("outDataset : " + outDataset);
			
			mav.addObject(NexacroConstant.ERROR_CODE, "0");
			mav.addObject(NexacroConstant.ERROR_MSG, "");

		} catch (Exception e) {
			e.printStackTrace();
			mav.addObject(NexacroConstant.ERROR_CODE, "-1");
			mav.addObject(NexacroConstant.ERROR_MSG, e.toString());
		}
		return mav;
	}
}

서버 로그

tranInfo : egovframework.rte.cmmn.ria.nexacro.map.DataSetMap@10c2d26
inVar : {PAGE={}, serverType=local, USER={}}
inDataset : {}
outVar : {}
outDataset : {}

Nexacro - 서버 호출 Button 이벤트 - 파라미터 구성 추가

this.Button00_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var sSvcID          = "list";                   
    var sController     = "blueController.do";
    var sInDatasets     = "";  
    var sOutDatasets    = "";
    
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    // 파라미터 구성
    var sArgs="";
    sArgs += Ex.util.setParam("method","getList");
    sArgs += application.gfn_setParam("sqlId","blueDAO.getList");
    sArgs += Ex.util.setParam("inputClass","bizservice.nexa.domain.Dept");
    sArgs += Ex.util.setParam("outputClass","bizservice.nexa.domain.Dept");
    
    // 서비스 아이디
    var strSvcID = {id:sSvcID, outDatasets:sOutDatasets};
    
    // 서비스 변수 값 가지고 오기
    var sSvcUrl = application.services["svcurl"].url;
    // 서버 호출 주소 생성
    var strURL = sSvcUrl + sController;

    // Ex.core.tran(this, sSvcID, sController, sInDatasets, sOutDatasets, sArgs);
    this.transaction(strSvcID, strURL, sInDatasets, sOutDatasets, sArgs, "received", true, false);
}

Server - 서버 로그

tranInfo : egovframework.rte.cmmn.ria.nexacro.map.DataSetMap@1a80f5c
inVar : {PAGE={}, method=getList sqlId=blueDAO.getListVO inputClass=bizservice.nexa.domain.Dept outputClass=bizservice.nexa.domain.Dept , serverType=local, USER={}}
inDataset : {}
outVar : {}
outDataset : {}

Nexacro - application 내장 함수 만들기

호출 과정을 정리 해본것으로 실제 사용시 Eco, Ex 라이브러리를 사용 필요

스크립트 창 열기

this.gv_op = "OP";

this.gfn_isNull = function(value)
{
    return value === null;
}
 
this.gfn_isUndefined = function(value)
{
    return value === undefined;
}
 
/**
 * 공백으로치환
 * @param {string} 체크할  파리미터명
 * @return {string} 공백으로 치환값
 * @example
 *    trace(Eco.isEmpty("")); (output) ""
 * @memberOf Ex.util
 */    
this.gfn_isReplaceEmpty = function(strArg)
{
      if( this.gfn_isNull(strArg) || this.gfn_isUndefined(strArg)) return "";
       else
       return strArg;
}
 
this.gfn_setParam = function (p_name, p_value)
{          
    return p_name + "="+this.gfn_isReplaceEmpty(p_value)+ " ";
}

this.gfn_transaction = function(obj, svcID, sController, inDatasets, outDatasets, argument, callbackFunc)
{
    // Service ID Merge
    var strSvcID = {id:svcID, callbackFunc:callbackFunc, outDatasets:outDatasets};
    var strInDatasets = inDatasets;
    var strOutDatasets = outDatasets;
    var strArgument = argument;
    var strCallbackFunc = callbackFunc;
    
    // 서비스 변수 값 가지고 오기
    var sSvcUrl = this.services["svcurl"].url;
    // 서버 호출 주소 생성
    var strURL = sSvcUrl + sController;

    // 
    obj.transaction(strSvcID, strURL, strInDatasets, strOutDatasets, strArgument, strCallbackFunc, true, false);
}

Nexacro - 서버 호출 Button 이벤트

this.Button00_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var sSvcID          = "list";                   
    var sController     = "blueController.do";
    var sInDatasets     = "";  
    var sOutDatasets    = "";
    
     ///////////////////////////////////////////////////////////////////////////////////////////////////
    // 2015.06.12 VO방식 테스트
    var sArgs="";
    sArgs += application.gfn_setParam("method","getList");
    sArgs += application.gfn_setParam("sqlId","blueDAO.getList");
    sArgs += application.gfn_setParam("inputClass","bizservice.nexa.domain.Dept");
    sArgs += application.gfn_setParam("outputClass","bizservice.nexa.domain.Dept");
    
    //
    application.gfn_transaction(this, sSvcID, sController, sInDatasets, sOutDatasets, sArgs, "received");
}

this.received = function(id, code, message)
{
    alert(code);
}

Server - 서비스 구현

서비스 인터페이스

package bizservice.nexa.cmmn.map.service;

import java.util.Map;

import egovframework.rte.cmmn.ria.nexacro.map.DataSetMap;

public interface BlueService {

	void getList(
			DataSetMap tranInfo,
			Map<String, Object> inVar, Map<String, DataSetMap> inDataset,
			Map<String, Object> outVar, Map<String, DataSetMap> outDataset) throws Exception;
}

서비스 구현

package bizservice.nexa.cmmn.map.service;

import java.util.Map;

import org.springframework.stereotype.Service;

import egovframework.rte.cmmn.ria.nexacro.map.DataSetMap;

@Service("blueService")
public class BlueServiceImpl implements BlueService {

	public void getList(DataSetMap tranInfo,
			Map<String, Object> inVar, Map<String, DataSetMap> inDataset,
			Map<String, Object> outVar, Map<String, DataSetMap> outDataset)
		throws Exception 
	{
		// DAO 호출 구현
	}
}

서비스 호출 Controller 구현

package bizservice.nexa.cmmn.map.controller;

import java.lang.reflect.Method;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import bizservice.nexa.cmmn.map.service.BlueService;
import egovframework.rte.cmmn.ria.nexacro.NexacroConstant;
import egovframework.rte.cmmn.ria.nexacro.map.DataSetMap;
import egovframework.rte.cmmn.ria.nexacro.map.NexacroMapDTO;

@Controller
public class BlueController {

	protected Log logger = LogFactory.getLog(this.getClass());
	
	@Resource(name="blueService")
	BlueService blueService;

	@RequestMapping("/blueController.do")
	public ModelAndView operate(NexacroMapDTO xpDto, Model model) throws Exception {

		ModelAndView mav = new ModelAndView("nexacroMapView");

		try {
			DataSetMap tranInfo 				= xpDto.getTranInfoMap();
			Map <String, Object> inVar 			= xpDto.getInVariableMap();
			Map <String, DataSetMap> inDataset 	= xpDto.getInDataSetMap();
			Map <String, Object> outVar 		= xpDto.getOutVariableMap();
			Map <String, DataSetMap> outDataset = xpDto.getOutDataSetMap();
			
			for (Map map : tranInfo.getRowMaps()) {
				System.out.println("tranInfo.map : " + map);
			}
			System.out.println("inVar : " + inVar);
			System.out.println("inDataset : " + inDataset);
			System.out.println("outVar : " + outVar);
			System.out.println("outDataset : " + outDataset);
			
			// 서비스 객체
			Object bean = blueService;
			Method method = getMethod(bean, (String)inVar.get("method"));
			
			try{
				// 메소드 호출
				method.invoke(bean, new Object[] {tranInfo, inVar, inDataset, outVar, outDataset});
			} catch (Exception e){
				Throwable te = e.getCause();
				logger.debug("Can not invoke a dispatch method name", te);
				throw new Exception(te.getMessage(), te);
			}
			
			mav.addObject(NexacroConstant.ERROR_CODE, "0");
			mav.addObject(NexacroConstant.ERROR_MSG, "");

		} catch (Exception e) {
			e.printStackTrace();
			mav.addObject(NexacroConstant.ERROR_CODE, "-1");
			mav.addObject(NexacroConstant.ERROR_MSG, e.toString());
		}
		return mav;
	}
	
	private Method getMethod(Object bean, String methodName) throws Exception{
		Method[] methods = bean.getClass().getMethods();

		for(int i = 0 ; i < methods.length ; i++) {
			if( methods[i].getName().equals(methodName)) {
				return methods[i];
			}
		}
		throw new Exception("Cann't find " + methodName + ".");
	}
}

Server - 서비스 구현 - DAO 호출

package bizservice.nexa.cmmn.map.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import bizservice.nexa.cmmn.map.dao.BlueDAO;
import egovframework.rte.cmmn.ria.nexacro.map.DataSetMap;

@Service("blueService")
public class BlueServiceImpl implements BlueService {
	
	@Resource(name="sqlMapBlueDAO")
	BlueDAO blueDAO;

	public void getList(DataSetMap tranInfo,
			Map<String, Object> inVar, Map<String, DataSetMap> inDataset,
			Map<String, Object> outVar, Map<String, DataSetMap> outDataset)
		throws Exception 
	{
		// DAO 호출 구현
		// List<Map> records = blueDAO.getList("blueDAO.getList", inVar);
		List<Map> records = blueDAO.getList((String)inVar.get("sqlId"), inVar);
		System.out.println("records = " + records.size());
			
		DataSetMap outDsMap = new DataSetMap();
		outDsMap.setRowMaps(records);
		outDataset.put("output1", outDsMap);
	}
}

DAO 인터페이스

package bizservice.nexa.cmmn.map.dao;

import java.util.List;

import bizservice.nexa.exception.NexaDaoException;

public interface BlueDAO {

	public List getList(String queryId, Object objVo) throws NexaDaoException;

}

DAO 인터페이스 구현

package bizservice.nexa.cmmn.map.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import bizservice.nexa.exception.NexaDaoException;
import egovframework.rte.psl.dataaccess.EgovAbstractDAO;

@Repository("sqlMapBlueDAO")
public class SqlMapBlueDAO extends EgovAbstractDAO implements BlueDAO {

	public List getList(String queryId, Object objVo) throws NexaDaoException {
		List<Object> list = new ArrayList();
		list = getSqlMapClientTemplate().queryForList(queryId, objVo);
		return list;
	}

}

SQL Map 파일 생성 - nexacroplatform\src\main\resources\egovframework\sqlmap\bizservice\sample\Blue.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd">

<sqlMap namespace="Blue">

	<!-- code -->
	<select id="blueDAO.getList" parameterClass="java.util.HashMap" resultClass="java.util.HashMap">
		SELECT *
		  FROM XP_DEPT
	</select>

</sqlMap>

추가한 SQL Map 파일 Config에 추가 - nexacroplatform\src\main\resources\egovframework\sqlmap\bizservice\sql-map-config.xml

<sqlMap resource="egovframework/sqlmap/bizservice/sample/Blue.xml" />

Nexacro - Grid 추가, 삭제, 저장

Programming/Nexacro 2017.11.25 20:39 Posted by 파란크리스마스

출처 : 농부지기 :: Nexacro.Dataset - 한줄 추가.삭제
농부지기 :: Nexacro.Grid - excel exort

화면배치

  • Button : id : BtnAdd / text : 추가
  • Button : id : BtnDel / text : 삭제
  • Button : id : BtnSave / text : 저장

Grid 컬럼 속성의 edit 속성 변경

Grid를 더블클릭해서 Grid 컬럼 설정 화면으로 이동

title 컬럼의 edittype : normal 로 변경

contents 컬럼의 edittype : normal 로 변경

추가버튼(BtnAdd) 구현

this.BtnAdd_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var nRow = this.Dataset00.addRow();
	trace("nRow===>> " + nRow + " :" + this.Dataset00.saveXML());
}

삭제버튼(BtnDel) 구현

this.BtnDel_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var nRow = this.Dataset00.rowposition;
	this.Dataset00.deleteRow(nRow);
}

저장버튼(BtnSave) 구현

this.BtnSave_onclick = function(obj:Button,  e:nexacro.ClickEventInfo)
{
	var sSvcID        	= "save";                    
    var sController   	= "egovSampleModifyVO.do";

    var sInDatasets   	= "input1=Dataset00:U";
	var sOutDatasets  	= "";
	var sArgs = "";	
	
	///////////////////////////////////////////////////////////////////////////////////////////////////
    // 2015.06.12 VO방식 테스트
    var sArgs="";
    sArgs += Ex.util.setParam("method","multiDataModifyService");
    sArgs += Ex.util.setParam("sqlId","sampleDAO.insertSampleVO");
    sArgs += Ex.util.setParam("inputClass","bizservice.nexa.sample.vo.SampleVO");
    sArgs += Ex.util.setParam("outputClass","bizservice.nexa.sample.vo.SampleVO");
    sArgs += Ex.util.setParam("forceSqlFlag","N");
    /////////////////////////////////////////////////////////////////////////////////////////////////
	
	//addInDataSet(this,  0, "ds_input","egovframework.rte.sample.service.XPSampleVO");
	//addOutDataSet(this, 0, "ds_output","egovframework.rte.sample.service.XPSampleVO");
	  
	Ex.core.tran(this,sSvcID, sController, sInDatasets, sOutDatasets, sArgs);
}

Spring Service 구현

package bizservice.nexa.sample.service;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;

import bizservice.nexa.sample.dao.SampleDAO;
import bizservice.nexa.sample.vo.SampleVO;

import com.nexacro.xapi.data.DataSet;

import egovframework.rte.cmmn.ria.nexacro.vo.RowType;
import egovframework.rte.fdl.cmmn.AbstractServiceImpl;
import egovframework.rte.fdl.idgnr.EgovIdGnrService;

@Service("sampleServiceXp")
public class EgovSampleServiceXpImpl extends AbstractServiceImpl implements EgovSampleServiceXp {
	protected Log logger = LogFactory.getLog(this.getClass());

	/** SampleDAO */
	@Resource(name = "sampleDAO")
	private SampleDAO sampleDAO;

	/** ID Generation */
	@Resource(name = "egovIdGnrService")
	private EgovIdGnrService egovIdGnrService;

	public List<?> sampleSelectVOList(SampleVO searchVO) throws Exception {
		// TODO Auto-generated method stub
		return sampleDAO.selectSampleVOList(searchVO);
	}

	/**
	 * 
	 * <PRE>
	 * 1. 메소드명 : saveData
	 * 2. 설    명 : DataSet의 rowType별로 Insert, Update, Delete가 수행되는 서비스이다.
	 * 3. 작 성 자 : 
	 * 4. 작 성 일 : 2016. 6. 11.
	 * </PRE>
	 * 
	 * @return ModelAndView
	 **/
	public void multiDataModifyService(
			List<Object> tranInfo, 
			Map<String, Object> inVar, 
			Map<String, List<Object>> inDataset, 
			Map<String, Object> outVar,
			Map<String, Object> outDataset) throws Exception 
	{
		// 서비스단 개발
		List<Object> list = inDataset.get("input1");

		for (int i = 0; i < list.size(); i++) {
			Object obj = list.get(i);
			if (obj instanceof RowType) {

				RowType rowType = (RowType) obj;
				if (rowType.getRowType() == DataSet.ROW_TYPE_INSERTED) {
					sampleDAO.insertSample(obj);
				} else if (rowType.getRowType() == DataSet.ROW_TYPE_UPDATED) {
					sampleDAO.updateSample(obj);
				} else if (rowType.getRowType() == DataSet.ROW_TYPE_DELETED) {
					sampleDAO.deleteSample(obj);
				}
			}
		}
	}
}


 

티스토리 툴바