類名:
? org.apache.commons.collections.BeanMap
用法:
? //...得到orderLine
? Map<String,Object> map = new BeanMap(orderLine);
? map.put("vendorDiscount",orderLine.getProduct().getVendor().getDiscount());
??//
得到orderLine
??Map<String,Object>?map?=?new?BeanMap(orderLine);
??map.put("vendorDiscount",orderLine.getProduct().getVendor().getDiscount()); 使用場景:
? dwr中可以直接把java對象轉(zhuǎn)換成js對象傳回,但是有時候需要在傳回的對象上附加屬性,例如在訂單項(訂單中的一行)中,我想附加相關(guān)
產(chǎn)品的
供應(yīng)商的
信用等級的
優(yōu)惠條件,如果直接把對象關(guān)系圖傳過去,需要傳4層,其實我只要在訂單項后附加一個屬性就行了。所以我就先把訂單項(OrderLine)轉(zhuǎn)化為一個map,向這個map中put新的屬性,這樣傳回到瀏覽器的對象還是和以前一樣的,只是附加了一個vendorDiscount:0.6 .
其一:
<div height="300px" style="overflow:scroll;">...</div>后滾動條死活不出來,如果寫成
<style>
.scrollbox{
? height:300px;
? overflow:scroll;
}
</style>
<div class="scrollbox">...</div>
就一切正常。
后來發(fā)現(xiàn)如果直接使用style屬性,應(yīng)該寫成<div style="height:300px; overflow:scroll;">...</div>
nnd,郁悶,不禁敬仰美工的工作。
其二:
為了圖簡便,直接用dwr調(diào)用了manager的方法時,manager中引用的其他manager總是null,仔細想想,發(fā)現(xiàn)manager是由spring管理的,所以應(yīng)該creator="spring",而不是creator="new"。得解。
這樣調(diào)用終歸不爽,還是應(yīng)該有services才行,看來偷懶是不行了。
另:昨晚看了一下dwr2.0,發(fā)現(xiàn)ajax終于走到正道上了。Reverse Ajax! 在java中設(shè)置界面控件的內(nèi)容,細粒度的請求和更新,由后臺來主導(dǎo)完整業(yè)務(wù)邏輯,而html就像c/s程序中的資源文件一樣被加載,這樣才能真正適合
企業(yè)應(yīng)用(網(wǎng)站還是用以前的才對)。環(huán)境已經(jīng)成熟,到應(yīng)用不知道還要等多久
今天無意中竟然下載到了Refactoring Databases,哎呀,貪財貪財!
開發(fā)過程中database
schema 的變化總是引起很多麻煩,希望這本書能有所幫助。
Ruby中遞歸層數(shù)好像有限制,如函數(shù)
def test(a)
?? if a==1
???? 1
?? else
???? a*test(a-1)
?? end
end?
puts test(780)
輸出:84972392897964072098249533940415832032901226147549483885937628906393387016759749166779390912108512193770727396731176148684817099219862241070518329897737419790700834153338358789804054247254662503406001643932256413944181262536626134781963753899870200241216683120301369375204827350328695627459108294334206019027913654171970749305552969884823232609436511764040695691647958710090181422374514248844937618454949350242415512115167050621676322866110695044767187626021475743251277035950696737988473189355598223688184822894258942937354547600827689072340880783574157611601536909313655637665907495308227315772813753604514703047972667545052382993341295609886125445821680344472136291787954204104578202488733326674486963013530280156726975853827440416172311405531398732685573114934257635906047009853269995109193159402626590282423997495520628272375213203911332399362264123774789131108251376802391556145557618075940012872003438523613025838162437433166091728438034202592564763334170361422871174553523479072202135150477947497462319792004248488747067669226929977889728474667753117513554197181549148693463434107347395476738175071015937790196691810903035212156632705787120639270121315037723516623976522946189161132382463371686857543746042274574224547052957738646625809966919808812294116127379399188579075359032740380579901160073141745025441935558361164158736914927029701136227557285045299271693750581590882877670856450852068994081414494717924806473008367067880435766156267541200120373117672789242005510204657433232442062443350842731528466220850546079536126591907570634996939687881634634077903962785409702209303560414980140946811644475359177263347973998479963954822343870777236845722878913093643097703061981548194975005332841862304172509388532508262400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
而
puts test(781)
輸出:
E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `*': stack level too deep (SystemStackError)
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
?... 727 levels...
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:5:in `test'
from E:/eclipse-SDK-3.2M6-win32/workspace/testruby/Test5.rb:9
Ruby一直被認為沒有好的IDE,今天把RDT跑起來了,還不錯,雖然還不能和JDT相比。
使用 Eclipse 插件 Ruby Development Tools
http://www-128.ibm.com/developerworks/cn/opensource/os-rubyeclipse/為何配合RDT,我特地下載了一個Eclipse3.2M6,界面好花哨,但用起來心虛虛的,干活還使用3.1踏實。