<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    七段

    無論怎樣,請讓我先感謝一下國家。

    BlogJava 首頁 新隨筆 聯系 聚合 管理
      35 Posts :: 2 Stories :: 7 Comments :: 0 Trackbacks

    #

    posted @ 2010-02-22 10:00 sevenduan 閱讀(243) | 評論 (0)編輯 收藏

    Navigation Practice Agenda:
    1, forward & redirect; Get & Post:
    How to choose between them? How to apply by JSF/JSP? what's default in JSF?
    How to resolve issue about resources not found caused by forward navigation?
    Does the request scope objects still available after redirect?
    2, done back
    How to done back in client side? browser history back; js history back manager
    How to done back at server side? JSF
    3, How to navigation only inside of page?
    scroll bar navigation: anchor? scroll bar ?
    focus on different DOM elements?
    4, How to do not navigate?
    refresh page, ajax refresh
    Could you make your page support Refresh with right navigate behavior?
    5, How to navigate among tabs and windows?
    form submit target:_blank,_self,_parent,_top,frameName
    6, JSF navigation management
    referrence: http://java.sun.com/dtd/web-facesconfig_1_1.dtd
    How does JSF choose navigation rule case when match mutiple cases?
    7, How to pass parameters during navigation?
    page, request, session, application

    posted @ 2010-02-08 14:45 sevenduan 閱讀(295) | 評論 (0)編輯 收藏

    I was told something about js module framework two years ago. But without a deep dive into it, so that I have to ride out large bundles of js files in a mess on our projects for a long time. After kejun’s YUI presentation on D2 2009, I thought that it’s time to change.

    Why use js module?

    1, better js organization, readable + flexible + dependencies ordering

    2, better performance, asynchronize loading JIT

    How we did it before?

    1, inline script in jsp : hard to unittest, make the file looks tedious and ugly

    2, separated js script file: bad organization, too many ugly import tag <script>

    What is the existed solution?

    1, YUI module: http://developer.yahoo.com/yui/yuiloader/

    2, Jawr: a tunable packaging solution for Javascript and CSS written in java

    3, jQuery getSscript: http://ejohn.org/blog/degrading-script-tags/

    4, jspkg: http://jspkg.sourceforge.net/docs/index.html

    5, module.js http://ajaxian.com/archives/modulesjs-a-new-stand-alone-javascript-module-loader

     to do ...

    posted @ 2010-01-04 23:41 sevenduan 閱讀(1564) | 評論 (0)編輯 收藏

    Pros and Cons:

    Pros:

    1, reduce configuration xml files

    2, readable by self-documenting

    Cons:

    1, it adds deployment context to classes, which should be generic enough.

    2, interfere with design principles such as IOC and dependency injection, because you need to introduce imports

    Usage (annotation works only when handled by related annotation processor):

    • Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings.
    • Compiler-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth.
    • Runtime processing — Some annotations are available to be examined at runtime.

      1 import java.io.IOException;
      2 import java.io.PrintStream;
      3 import java.lang.reflect.AnnotatedElement;
      4 import java.lang.annotation.Annotation;
      5 
      6 import java.util.Date;
      7 import java.lang.annotation.Documented;
      8 import java.lang.annotation.Inherited;
      9 import java.lang.annotation.Retention;
     10 import java.lang.annotation.RetentionPolicy;
     11 
     12 public class ReflectionTester {
     13 
     14   public ReflectionTester() {
     15   }
     16 
     17   public void testAnnotationPresent(PrintStream out) throws IOException {
     18     Class c = Super.class;
     19     boolean inProgress = c.isAnnotationPresent(InProgress.class);
     20     if (inProgress) {
     21       out.println("Super is In Progress");
     22     } else {
     23       out.println("Super is not In Progress");
     24     }
     25   }
     26 
     27   public void testInheritedAnnotation(PrintStream out) throws IOException {
     28     Class c = Sub.class;
     29     boolean inProgress = c.isAnnotationPresent(InProgress.class);
     30     if (inProgress) {
     31       out.println("Sub is In Progress");
     32     } else {
     33       out.println("Sub is not In Progress");
     34     }
     35   }
     36 
     37   public void testGetAnnotation(PrintStream out) 
     38     throws IOException, NoSuchMethodException {
     39 
     40     Class c = AnnotationTester.class;
     41     AnnotatedElement element = c.getMethod("calculateInterest"
     42                                   float.classfloat.class);
     43 
     44     GroupTODO groupTodo = element.getAnnotation(GroupTODO.class);
     45     String assignedTo = groupTodo.assignedTo();
     46 
     47     out.println("TODO Item on Annotation Tester is assigned to: '" + 
     48         assignedTo + "'");
     49   }
     50 
     51   public void printAnnotations(AnnotatedElement e, PrintStream out)
     52     throws IOException {
     53 
     54     out.printf("Printing annotations for '%s'%n%n", e.toString());
     55 
     56     Annotation[] annotations = e.getAnnotations();
     57     for (Annotation a : annotations) {
     58       out.printf("    * Annotation '%s' found%n"
     59         a.annotationType().getName());
     60     }
     61   }
     62 
     63   public static void main(String[] args) {
     64     try {
     65       ReflectionTester tester = new ReflectionTester();
     66 
     67       tester.testAnnotationPresent(System.out);
     68       tester.testInheritedAnnotation(System.out);
     69 
     70       tester.testGetAnnotation(System.out);
     71 
     72       Class c = AnnotationTester.class;
     73       AnnotatedElement element = c.getMethod("calculateInterest"
     74                                     float.classfloat.class);      
     75       tester.printAnnotations(element, System.out);
     76     } catch (Exception e) {
     77       e.printStackTrace();
     78     } 
     79   }
     80 }
     81 
     82 class Sub extends Super {
     83 
     84   public void print(PrintStream out) throws IOException {
     85     out.println("Sub printing");
     86   }
     87 }
     88 
     89 @InProgress class Super {
     90 
     91   public void print(PrintStream out) throws IOException {
     92     out.println("Super printing");
     93   }
     94 }
     95 
     96 @Documented
     97 @Retention(RetentionPolicy.RUNTIME)
     98 @interface GroupTODO {
     99 
    100   public enum Severity { CRITICAL, IMPORTANT, TRIVIAL, DOCUMENTATION };
    101 
    102   Severity severity() default Severity.IMPORTANT;
    103   String item();
    104   String assignedTo();
    105   String dateAssigned();
    106 }
    107 
    108 /**
    109  * Marker annotation to indicate that a method or class
    110  *   is still in progress.
    111  */
    112 @Documented
    113 @Inherited
    114 @Retention(RetentionPolicy.RUNTIME)
    115 @interface InProgress { }
    116 
    117 class AnnotationTester {
    118 
    119   @InProgress
    120   @GroupTODO(
    121     severity=GroupTODO.Severity.CRITICAL,
    122     item="Figure out the amount of interest per month",
    123     assignedTo="Brett McLaughlin",
    124     dateAssigned="04-26-2004"
    125   )
    126   public void calculateInterest(float amount, float rate) {
    127     // Need to finish this method later
    128   }
    129 }
    130 
    posted @ 2010-01-04 11:28 sevenduan 閱讀(1651) | 評論 (0)編輯 收藏

     Introduction:
    JSF:  MVC framework as Struts
    DWR: java Ajax framework
    Json: a data format definition like XML, YAML. We could use DWR or jsonlib to marshal/unmarshal between json and objects.

    How to use?
    1, when should we use json or not?
    do JSF as much as possible;
    only when dynamic collection size on page, do Json
    2, when should we use DWR json convertor configuration or customize json convertor by java?
    page scope update, do Ajax by DWR as much as possible;
    otherwise, do JSF action by json convertor (consolidate convertor by jsonlib or dwr?)


    DWR convertor VS Jsonlib convertor:
        DWR:
        convertor setting by xml, annotation or java;

        Jsonlib:
        convertor setting by java (only check @Transient), but more professional overall;

    Requirement:
    1, simple convertion, no VO or DTO:
        PO to json: 1, cycle detect; 2,include/exclude;
        Json to PO: 1, the same js handle; 2, ajax by dwr; jsf by hidden string
    2, one PO map into two JSON model for different domains (e.g. bind different convertor by spring to different domain serviceImpl)

    Not to do list:
    1, do not use duplicated convertors definition in java/xml/annotation
    2, do not DTO or VO when convert between json and objects
    3, do not parse or transfer useless fields, e.g. use include / exclude configuration instead during convert objects into json; use "delete" during convert json into object
    4, do not use json if could use JSF

    posted @ 2010-01-04 08:58 sevenduan 閱讀(1851) | 評論 (0)編輯 收藏

     1 var alltrue = [truetruetrue];// false
     2             var allfalse = [falsefalsefalse];// false
     3             var chaos = [truefalsetruefalse];// true
     4             //1,logic operation;2,shorten-cycle;
     5             function LogicXOR(){
     6                 var args = arguments;
     7                 if (args.length == 1) {
     8                     if (args[0].length) {
     9                         args = args[0];
    10                     }
    11                     else {
    12                         return args[0];
    13                     }
    14                 }
    15                 
    16                 var count = args.length;
    17                 while (--count > 0) {
    18                     if (!args[count] !== !args[count - 1]) 
    19                         return true;
    20                 }
    21                 return false;
    22             }
    23             
    24             alert(LogicXOR(alltrue))
    25             alert(LogicXOR(allfalse))
    26             alert(LogicXOR(chaos))
    27             alert(LogicXOR(truetruetrue))
    28             alert(LogicXOR(falsefalsefalse))
    29             alert(LogicXOR(truefalsetruefalse))
    posted @ 2009-12-22 15:59 sevenduan 閱讀(1264) | 評論 (0)編輯 收藏

    Collection>
        boolean contains(Object o):return true only if has (o==null ? e==null :o.equals(e))
        boolean removeAll(Collection<?> c); remove elements in c
        boolean retainAll(Collection<?> c); remove elements not in c
        Queue VS List VS Set
        List>
            ListIterator<E> listIterator();| Iterator<E> iterator();
            next() & previous()|only has next()
            add() & remove()|only has remove()
            * you can not use list.add() during both two iteration, otherwise,ConcurrentModificationException

    RandomAccess>
            Marker interface used by List implementations to indicate that they support fast (generally constant time) random access. e.g.
            for (int i=0, n=list.size(); i < n; i++)
                     list.get(i);
            runs faster than this loop:
                 for (Iterator i=list.iterator(); i.hasNext(); )
                     i.next();

    HashMap, HashSet, HashTable>
        HashMap(int initialCapacity, float loadFactor)        resize()
        HashSet(int initialCapacity, float loadFactor) {map = new HashMap<E,Object>(initialCapacity, loadFactor);}
        Hashtable(int initialCapacity, float loadFactor) extends Dictionary<K,V>  ; synchronized ;  rehash();
        hash = hash(key.hashCode());
        *TreeMap Red-black mechanics
    posted @ 2009-12-21 23:04 sevenduan 閱讀(823) | 評論 (0)編輯 收藏

    String>
        String|StringBuffer|StringBuilder
        immutable|mutable|mutable  <-- depends on the char[] value is final or not;
        thread-safe|thread-safe|single thread

    1, compile phase:
        constance will be directly written. OuerClass.constance not refer to it during runtime.
        + =after compiled=> StringBuilder

    2, Performance:
        usually, StringBuilder>StringBuffer>+; but need  to make sure the real generated class file.
        String.intern() is better if too many duplicated string instance.

    3, String <--> bytes
    decode: String(byte bytes[], int offset, int length, Charset charset)
    encode: String.getBytes(Charset charset)

    4, StringTokenizer | String.split
        better performance | RegEx
    posted @ 2009-12-21 22:36 sevenduan 閱讀(1340) | 評論 (0)編輯 收藏

    當IE中發生js對象與dom對象直接的循環引用,并且之后沒有引用指向他們,
    如果是IE 6, 內存泄漏,直到關閉IE進程為止
    如果是IE 7,內存泄漏, 直到離開當前頁面為止
    如果是IE 8, GC回收器回收他們的內存,無論當前是不是compatibility模式。

    為什么有內存泄漏?
    之前的IE js引擎里的GC回收器只能處理js對象,不能處理DOM對象。

    refer to: http://msdn.microsoft.com/en-us/library/dd361842%28VS.85%29.aspx#compat

    posted @ 2009-12-16 16:07 sevenduan 閱讀(1361) | 評論 (0)編輯 收藏


    1、 說話的時機:成事不說、遂事不諫、既往不咎
    2、 不同事情,不同說法:好事情,用播新聞的方式;壞事情,先說結果
    3、 試探性的說話:放話出去
    4、 見人說人話,見鬼說鬼話,不人不鬼說胡話
    摘選自:http://blog.csdn.net/zhaowei001/archive/2008/04/10/2279172.aspx
    posted @ 2009-12-15 22:34 sevenduan 閱讀(151) | 評論 (0)編輯 收藏

    僅列出標題
    共4頁: 上一頁 1 2 3 4 下一頁 
    主站蜘蛛池模板: 亚洲AV无码成人精品区在线观看 | 综合亚洲伊人午夜网 | 免费看国产精品3a黄的视频| 亚洲国产一区二区三区青草影视| jjizz全部免费看片| 亚洲成人激情在线| 久久不见久久见免费视频7 | 青苹果乐园免费高清在线| 亚洲伊人久久大香线蕉影院| 亚洲精品在线免费观看| 亚洲乱码一二三四区麻豆| 黄色永久免费网站| 狠狠综合久久综合88亚洲| 免费无码H肉动漫在线观看麻豆| 亚洲国产精品特色大片观看完整版 | 另类小说亚洲色图| 国产亚洲成人在线播放va| 中文字幕a∨在线乱码免费看| 天天摸天天碰成人免费视频| 亚洲欧洲日产国码av系列天堂| 亚洲大码熟女在线观看| 免费观看国产小粉嫩喷水| 一级女人18片毛片免费视频 | 亚洲伦理一二三四| 日本高清免费网站| 久久免费观看视频| 久久久婷婷五月亚洲97号色| 久久www免费人成精品香蕉| 久久精品国产亚洲av麻| 歪歪漫画在线观看官网免费阅读| 久久久久久久久无码精品亚洲日韩| 久久久久无码专区亚洲av| 亚欧日韩毛片在线看免费网站| 337p日本欧洲亚洲大胆裸体艺术| 日本一区午夜艳熟免费| 亚洲中文字幕乱码熟女在线| 最近中文字幕完整版免费高清| 亚洲精品无码mⅴ在线观看| 114一级毛片免费| 日韩在线视频免费| 亚洲国产成人精品91久久久|