Total Pageviews

2011/06/04

JasperSoft Integrates iReport Into Eclipse Development Platform

Intall JasperSoft into Eclipse

1. Open Eclipse --> Help --> Eclipse Marketplace

2. Choose "Eclipse Marketplace" --> Next

3. Use "ireport" as keyword and click "Go"-->Click "Install"

4. Please be patient.

5. Click "Next"

6. Choose "I Accept...", Click "Finish"

7. Installing Software...

8. Click "Restart Now" to restart Eclipse

Open Eclipse Again
1. Open jrxml file

2. See. You can edit jrxml in eclipse, do not need to open iReport again.

how to Set JavaBean DataSource in iReport

Setup Classpath

1. iReport --> Preferences

2. Click Classpath tab --> Click "Add Folder"

3. Choose class folder --> Click "Choose"

4. Check "Reloadable" checkbox --> Click OK

Create a new report template
1. File --> New


2. Choose "Blank A4" --> Click "Open This Template"

3. Assign report name and location, Click "Next"


4. Click Finish

5. Right Click -->Edit Query

6. Choose "JavaBean DataSource"-->Assign "class name"-->Click Read Attriutes

7. Choose "selected attributes" --> Click "add selected attributes"

8. Click OK

9. Unfold "Fields", then you can see the attributes we added before will show under Fields

10. Drag "Department" field into template. Then DONE.


2011/06/02

利用enumeration type來做下拉選單

我們在開發的時候,會遇到某些下拉選單不是從資料庫抓出來的,寫死在jsp好像不太恰當,寫在property file再抓出來又有點麻煩,如下圖所示,輸出格式、法務科別、下授類別等,下拉單內容很固定、又不需要放在資料庫:


這邊我建議用Java的enumeration type來建立下拉選單。步驟如下(以法務科別為例):

1. 建立enumeration class (若下選選單有增減,只要修改enumeration即可)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
   package gov.fdc.nig.enumeration;
   
   /**
    * 法務科別 enumeration
    *
    * @author albert
    *
    */
   public enum LegalSectionEnum {
   
       SECTION1("1.法務一科", "1"), SECTION2("2.法務二科", "2"), ALL("3.全部", "3");
   
       private final String label;
       private final String value;
   
       public String getLabel() {
           return label;
       }
   
       public String getValue() {
           return value;
       }
   
       private LegalSectionEnum(String label, String value) {
           this.label = label;
           this.value = value;
       }
   
       public static void main(String args[]) {
           LegalSectionEnum[] enumArr = LegalSectionEnum.values();
           for (LegalSectionEnum enumeration: enumArr) {
               System.out.println("label=" + enumeration.getLabel() + ", value=" +
                   enumeration.getValue());
           }
       }
   }

2. 在NIGUtilsConroller增加一個method來抓取enumeration中所定義的values
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
   /**
    * 取得法務科別下拉單
    * 
    * @param res loadDelegationUnitList
    * @param session HttpSession
    * @throws IOException if exception happens
    */
   @RequestMapping(value = "/loadLegalSectionList", method = RequestMethod.POST)
   public @ResponseBody
   void loadLegalSectionList(final HttpServletResponse res, final HttpSession session)
   throws IOException {
       final JSONArray jsonArray = new JSONArray();
   
       try {
           final LegalSectionEnum[] enumArr = LegalSectionEnum.values();
   
           for (LegalSectionEnum enumeration: enumArr) {
               Map map = new HashMap();
               map.put("value", enumeration.getValue());
               map.put("name", enumeration.getLabel());
   
               jsonArray.add(map);
           }
       } catch (FDCDataAccessException e) {
           LoggerFactory.getLogger(this.getClass()).debug(
               "loadExportFormatList exception: " + e.getMessage());
       }
   
       res.setContentType(NigAccessKey.JKEY_CONTENT_TYPE);
       res.getWriter().write(jsonArray.toString());
   }


3. 在nig.utils.js增加一個function來取得法務科別下拉單


4. 在功能相對應的js,呼叫nig.utils.js所定義的JavaScript function


JavaScript function所定義的id,與下拉選單的id需要對應

2011/05/31

eclipse-fonts

Easily control Eclipse fonts size. Update site: http://eclipse-fonts.googlecode.com/svn/trunk/FontsUpdate/

Shortcuts -

CTRL+= : Increase fonts

CTRL+- : Decrease fonts

2011/05/28

My Travel Brain

Travel Map
I've been to 38 cities in 11 countries
Asia
China: Shenzhen
Hong Kong (SAR): Hong Kong Island
Japan: Asahikawa
Japan: Fukuoka
Japan: Hakodate
Japan: Hokkaido
Japan: Kyoto
Japan: Nagano
Japan: Nagoya
Japan: Onuma
Japan: Sapporo
Japan: Sendai
Japan: Tokyo
Malaysia: Kuala Lumpur
Singapore: Singapore
South Korea: Seoul
Taiwan: T'ai-nan
Taiwan: T'ai-pei
Taiwan: T'ao-yuan
Taiwan: Yilan City
Europe
France: Arles
France: Avignon
France: Carcassonne
France: Entrevaux
France: Gordes
France: Le Fugeret
France: Nice
France: Nimes
France: Paris
France: Roussillon
France: Saint-Paul
France: Sorgues
Italy: Milano
Monaco: Monte-Carlo
North America
Canada: Toronto

Utilize Commons BeansUtils to do copy object


2011/05/27

2011/5 France

摩納哥

尼斯

蔚藍海岸

St. Paul

Aix(Aix-en-Provence的首都)

Roussillon一隅

Gordes

Fontaine-de--Vaucluse(沃克呂姿碧泉村)

Pont St. Benezet(亞維農斷橋)

嘉德水道橋(Pont du Gard)

凱旋門

Carcasonne

Eiffel Tower

羅浮宮

聖母院

Eiffel Tower夜景


2011/04/07

Utilize Recursive Java Decompiler to Decompile Jar File



2. Unzip jd-gui-0.3.3.windows.zip and execute jd-gui.exe

3. assign jar file which you want to do decompile



4. File --> Save All Sources




6. Install Doxygen

7. Assign project name, source code directory, destination directory. And check "Scan
recursively"


8. Change to "Mode", and do some configuration

9. Change to "Output", and do some configuration

10. Change to "Diagram", and do some configuration

11. Click "Run" tab, and click "Run doxygen"

12. Check result