Author Archives: ikungolf

About ikungolf

just a developer

Salesforce วิธีเช็คว่า String เท่ากับ ช่องว่าง, null บน Apex Class

[Apex class]

การตรวจสอบค่าใน Apex class controller

กำหนดให้รับค่า id มาเก็บไว้ในตัวแปรประเภท String(id)

String id;
id = System.currentPageReference().getParameters().get(‘id’);  

ถ้าต้องการตรวจสอบค่าของ id ว่ามีค่าหรือไม่ เพื่อจัดการตัวแปร ใน Controller

if(id==”){
System.debug(‘Mode: create’);
}elsle{
System.debug(‘Mode: edit‘);
}

จาก code ด้านบน เมื่อ id มีค่าเป็น “null” 
โปรแกรมจะไม่เข้าการทำงานในส่วนของ if แต่จะทำงานในส่วนของ else แทน

ดังนั้น วิธีการเช็ค empty(”) value == ” ไม่สามารถใช้กับค่า null ได้นั่นเอง

ถ้าต้องการตรวจสอบค่า ทั้ง ช่องว่าง empty(”) และ ค่า null เราสามารถใช้ function มาตราฐานที่ให้มาได้เลยครับ

isBlank();

if(String.isBlank(id)){
    System.debug(‘
Mode: create‘);
}else{
    System.debug(‘
Mode: edit‘);
}

ตัวอย่างโค๊คด้านบน แม้ว่าค่า id จะเป็น null ก็จะเข้าทำงานในส่วนของ if





Ref: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm

How to install Oracle JDK 8 (Java 8) on Ubuntu manually?

Corangu Web

http://www.oracle.com/us/assets/java-download-button-header-1708837.jpgInstalling JDK: [Manually using .tar.gz]

1. Go to Oracle JDK

2. Select “JDK Download”

3. “Accept the license terms” and download .tar.gz file based on your OS type

  1. Linux X86 (32 bit)
  2. Linux X64 (64 bit)

4. After you download the file, right-click the file and select “Extract here”

5. You will find a folder with the name similar to “jdk_1.8_version”

6. Open the terminal (ctrl+alt+t)

7. sudo mv /path/to/your/jdk_folder/ /usr/lib/jvm

8. The complete folder “jdk_1.8_version” will be moved to /usr/lib/jvm

9. Now we need to inform Ubuntu to use this JDK.

10. sudo gedit /etc/profile.d/oracle_jdk8.sh

11. Gedit would open a blank file for you. Write the following code in the file.

export J2SDKDIR=/usr/lib/jvm/oracle_jdk8
export J2REDIR=/usr/lib/jvm/oracle_jdk8/jre
export PATH=$PATH:/usr/lib/jvm/oracle_jdk8/bin:/usr/lib/jvm/oracle_jdk8/db/bin:/usr/lib/jvm/oracle_jdk8/jre/bin
export JAVA_HOME=/usr/lib/jvm/oracle_jdk8
export DERBY_HOME=/usr/lib/jvm/oracle_jdk8/db

12. Save the file. Close it.

13. Once you restart the changes will be made.

14. To force the changes to happen in the current session, without restarting…

View original post 15 more words

[OA Framework] findIndexedChildRecursive, findChildRecursive ใช้ต่างกันอย่างไร

findIndexedChildRecursive หรือ
public OAWebBean findIndexedChildRecursive(String name)
ใช้สำหรับค้นหา component ด้วย index จาก child/grandchild ด้วยการระบุชื่อ
findChildRecursive หรือ
public OAWebBean findChildRecursive(String name)
ใช้สำหรับค้นหา component ทั้ง Index และ Name จาก child/grandchild ด้วยการระบุชื่อ
ทั้งสอง method จะคืนค่า null หากไม่พบ component ตรงกับชื่อที่ต้องการค้นหา
ปล. หากเราไม่แน่ใจว่าชื่อที่เราต้องการค้นหาเป็น Index หรือ Name ของ component ขอแนะนำให้ใช้ findChildRecursive ในการค้นหาครับ เพราะจะค้นหาทั้ง index และ name

[OA Framework] findIndexedChildRecursive, findChildRecursive ใช้ต่างกันอย่างไร

findIndexedChildRecursive หรือ
public OAWebBean findIndexedChildRecursive(String name)

ใช้สำหรับค้นหา component ด้วย index จาก child/grandchild ด้วยการระบุชื่อ

findChildRecursive หรือ
public OAWebBean findChildRecursive(String name)

ใช้สำหรับค้นหา component ทั้ง Index และ Name จาก child/grandchild ด้วยการระบุชื่อ

ทั้งสอง method จะคืนค่า null หากไม่พบ component ตรงกับชื่อที่ต้องการค้นหา

ปล. หากเราไม่แน่ใจว่าชื่อที่เราต้องการค้นหาเป็น Index หรือ Name ของ component ขอแนะนำให้ใช้ findChildRecursive ในการค้นหาครับ เพราะจะค้นหาทั้ง index และ name

Credit: http://www.betterdevelopers.com/article/45347312/Use+of+findChildRecursive,+findIndexedChildRecursive,+findIndexedChild

นั่งรถตู้ไปทำงาน (เริ่มชิน)

หลังจากย้ายจาก มทส. เข้ามาอยู่ในเมือง การเดินทางต่างๆ สะดวกมากขึ้น หากวันไหนขึ้นรถ บ. ไม่ทัน

ยังมีรถประจำทางให้บริการอีกมากมาย วิ่งต่อเดียวถึงเลยด้วย

การเดินทางของผม ง่ายขึ้นมากเลย หลังจากนี้ก็เหลือพัฒนาเรื่อง เวลาตื่น แล้วเวลาทำกิจกรรมตอนเช้าให้ไวขึ้นเท่านี้ก็น่าจะดีขึ้นแล้ว

ก้าวต่อไปครับ

Ubuntu on VirtualBox screen resolution problem

ตอนที่เราติดตั้ง Ubuntu ลงบน VirtualBox on Windows มักจะพบกับปัญหาเรื่องขนาดของหน้าจะที่เล็กเกินไป ที่ผมเจอ ขนาดหน้าจะตอน login จะเป็น

ติดตั้งโปรแกรมโดยใช้คำสั่งทั้ง 3 ข้างล่าง

$sudo apt-get install virtualbox-guest-utils 

$sudo apt-get install virtualbox-guest-x11

$sudo apt-get install virtualbox-guest-dkms

หลังจากติดตั้งโปรแกรมเรียบร้อยแล้วก็ reboot

ทดลอง login อีกครั้งหนึ่ง

เท่านี้ก็เรียบร้อยแล้วเราสามารถปรับ ตั้งค่า screen resolution ของ Ubuntu ใน VirtualBox ได้แล้วครับ

Credit: http://askubuntu.com/questions/73589/higher-screen-resolution-for-virtualbox

How to get value from textarea jQuery

สร้าง Textarea โดยกำหนด id ให้เป็น textarea (ทำไม id ถึงสำคัญ เพราะ jQuery อ่างอิง element ต่างๆ ด้วย Id นั่นเอง)

<textarea id=”textarea” rows=”3″></textarea>

เราสามารถดึงข้อมูลจาก Textarea ด้วยการใช้ function val().

$(“#textarea”).val();

การกำหนดค่าให้กับ Textarea ด้วยการใช้ method val() เช่นเดียวกัน

var new_textarea_value = ‘New  value’;

$(‘#textarea’).val(new_textarea_value);

Credit::http://www.jquerytutorials.net/jquery-textarea.html

How to set Currency Format on TotalRow in OAAdvancedTable

เจอปัญหาในการใส่ Format ให้กับจำนวนเงิน สำหรับ Total Row ใน OAAdvancedTable

OAAdvancedTable
Id: showDetailTb
Id: column1

Total Value: True
Id: TrxAmount
View Attribute: TrxAmount

ถึงเราจะใส่ Format ให้กับ OAMessagedStyledTextBean id TrxAmount

Formatter formatter = new OADecimalValidater("#,###,###,##0.00;(#,###,###,##0.00)", "#,###,###,##0.00;(#,###,###,##0.00)");

OAAdvancedTableBean adTable = (OAAdvancedTableBean) webBean.findChildRecursive("showDetailTb");

OAMessageStyledTextBean trxAmountTotal = (OAMessageStyledTextBean) adTable.findChildRecursive("TrxAmount");
trxAmountTotal.setAttributeValue(ON_SUBMIT_VALIDATER_ATTR, formatter);

แต่จำนวน Total ก็ยังไม่อยู่ในรูป Format

หลังจากลองผิดลองถูก เข้าไป set format ในเกือบทุก objects ที่อยู่ภายใต้ OAAdvancedTable ก็ได้เข้าใจว่าถ้าต้องการให้เลขใน TotalRow อยู่ในรูปแบบที่จัด Format แล้วเราต้องไปตั้งค่าที่ …

Continue reading