2011年8月12日 星期五

Got an UiBinder useSafeHtmlTemplates warning on GWT compiling

When I was running a sample MVP application of GWT , show an error

[WARN] [helloMVP] Configuration property UiBinder.useSafeHtmlTemplates is false! UiBinder SafeHtml integration is off,
leaving your users more vulnerable to cross-site scripting attacks. This property will default to true in future releases of GWT



Solution is add one line in Contacts.gwt.xml


  







2011年8月10日 星期三

To decorate java code in google blogger with SyntaxHighlighter

  • Go to SyntaxHighlighter and download ( I used 3.0.83 release )
  • Unzip the file you download and  upload 
               the files(shCore.js、shBrushJava.js) in syntaxhighlighter_3.0.83\scripts               and (shCore.css、shCoreEclipse.css、shThemeEclipse.css) in syntaxhighlighter_3.0.83\styles
              to your web space ( On-line ) or https://sites.google.com/site/yours/

                                             I upload these files to my google site

 




                                              change the template in your blogger




add some html code as below

 
save the setting!

So , now you can decorate your code in blogger !
In editor of blogger , as following
<pre class="brush:java" name="code" >
      java code
</pre >

It is easy to use for html and javaScript and so on as above . See the configuration of SyntaxHighlighter for more advanced feature.









2011年8月8日 星期一

GWT Note 2

Event and Event handler

有四種方式來實作UI介面與事件觸發處理的關係
1.handler獨立成一個class,這樣會多很多class file不好review code和維護。
public class GwtEvents implements EntryPoint {
   ...
   public void onModuleLoad() {
     textfield = new TextBox();
     textfield.addKeyUpHandler(new MyHandler(this));
     ...
   }//end onModuleLoad
}//end class

public class MyHandler implements KeyUpHandler {
   ...
   public void onKeyUp(KeyUpEvent event) {
   ...
   }
}//end class

2.直接實作handler
public class GwtEvents implements EntryPoint, KeyUpHandler {
   ...
   public void onModuleLoad() {
     textfield = new TextBox();
     textfield.addKeyUpHandler(this);
     ...
    }

   public void onKeyUp(KeyUpEvent event) {
   ...
   }

}//end class


3. (Named)Inner class
public class GwtEvents implements EntryPoint { 
   public void onModuleLoad() { 
      textfield = new TextBox(); 
      textfield.addKeyUpHandler(new MyHandler()); 

   private class MyHandler implements KeyUpHandler { 
     public void onKeyUp(KeyUpEvent event) { 
     ... 
    } 

   }//end onModuleLoad 
}//end class 
4.Anonymous inner classes
public class GwtEvents implements EntryPoint { 
   ... 
   public void onModuleLoad() { 
     textfield = new TextBox(); 
     textfield.addKeyUpHandler(new KeyUpHandler() { 
     @Override 
     public void onKeyUp(KeyUpEvent event) { 
      ... 
     } 
    }); 
   }//end onModuleLoad 
}//end class 
請依情況選擇2、3的作法,避免用方法4。

GWT Note 1

今天遇到一個很怪的情況,怎麼加xxx.gwt.xml在已含有*.gwt.xml的project內就是會跑不起來,訊息如下:
[ERROR] [gwtevents1] - Unable to find 'gwtevents1.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
...
[ERROR] [gwtevents4] - Unable to find 'gwtevents4.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

這四個新加入的都出現一樣的錯誤,後來才找到問題:就是不要跑原先存留在eclipse內的執行設定,也就是刪除舊的執行設定 Run => Run Configurations => delete old configuration 或對project按右鍵=>Run As => Web Application

這種問題的解決挺難找的= = ,如果習慣用ant或maven來build,不要仰賴eclipse就不會遇到這種鳥事。

2011年8月5日 星期五

GWT Note

最近開始進入GWT的開發模式,所以一定會有不熟悉的地方,也就容易產生錯誤。
這邊就來把遇到的問題記起來吧!

在eclipse建立一個練習的GWT專案後,想要在這個專案跑一個以上的entry http://www.blogger.com/img/blank.gifpoint,http://www.blogger.com/img/blank.gif所以就會有一個以上的xxx.gwt.xml,那不想讓這兩個module(GWT是定義一個module一個entry point,討論12)包到彼此的client code,很簡單的方式就是切不同的path(或說package)

for example :
gwtapp1.gwt.xml
...
<module rename-to='gwtapp1'>
<source path='client/app1'/>
</module>

gwtapp2.gwt.xml
...
<module rename-to='gwtapp2'>
<source path='client/app2'/>
</module>

就是path不同,這樣就不會把gwtapp1的clinet code也被compile成gwtapp2的code了!

注意rename-to的值就是war內的一個目錄專放java to javaScipt的地方,還有就是path是用 / 斜線(slash or forward slash。 \ 反斜線是叫 backslash),我一開始是用"點" 所以會被google plugin的compiler說 "GWT compilation failed" 。= =;;;

2011年7月15日 星期五

Linux 換個power supply開不了機


公司某PC power supply壞了,過幾天換上新的後居然開不了機,
出現mkrootdev: label / not found
mount : error 2 mounting ext3
....
...
Kernel panic - not syncing:Attempted to kill init !
<如圖>

後來是因為CMOS電池也沒電,BIOS恢復default , BIOS沒調正確的硬碟代號,也就是原本是SATA的硬碟變成IDE硬碟,然後進入boot後就啟動失敗。改成有認成sda1就恢復了。OH~

/var 快塞爆了

今天發現server上/var快爆滿了
去查了一下到底是誰
du -s /var/* |sort -rn | head -5
才發現是/var/spool/clientmqueue 內有太多信因為sendmail沒啟動導致一些信沒寄出給root
加上似乎ssh被hacker瘋狂嘗試登入,然後一堆告警的訊息產生並通知給root。
用ls | xargs rm -rf 可以清除裡面龐大數量的檔案。除了這種訊息當然也可以去確保你的crontab的排程是否有加到> /dev/null 2>&1就不會有一些資料進到這個queue目錄內。
最後還是可以做個擋不正當的行為IP的人進入系統。

COVID-19 確診經歷紀實

原本以為真的是天選之人,就算先前家裡兩個小孩都確診都逃過了(可能有中獎但無症狀吧),不過就在2023年六月18日破解自認為天選之人的"心態",為什麼可以確認就是這天中獎的呢?因為在前都是居家上班,到人多的室內場所都會戴口罩,就剛好這天傍晚原本只想說要去附近的國...