类名:
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对象转换成js对象传回,但是有时候需要在传回的对象上附加属性,例如在订单项(订单中的一行)中,我想附加相关
产品的
供应商的
信用等级的
优惠条件,如果直接把对象关系图传过去,需要传4层,其实我只要在订单项后附加一个属性就行了。所以我就先把订单项(OrderLine)转化为一个map,向这个map中put新的属性,这样传回到浏览器的对象还是和以前一样的,只是附加了一个vendorDiscount:0.6 .
其一:
<div height="300px" style="overflow:scroll;">...</div>后滚动条死活不出来,如果写成
<style>
.scrollbox{
height:300px;
overflow:scroll;
}
</style>
<div class="scrollbox">...</div>
就一切正常。
后来发现如果直接使用style属性,应该写成<div style="height:300px; overflow:scroll;">...</div>
nnd,郁闷,不禁敬仰美工的工作。
其二:
为了图简便,直接用dwr调用了manager的方法时,manager中引用的其他manager总是null,仔细想想,发现manager是由spring管理的,所以应该creator="spring",而不是creator="new"。得解。
这样调用终归不爽,还是应该有services才行,看来偷懒是不行了。
另:昨晚看了一下dwr2.0,发现ajax终于走到正道上了。Reverse Ajax! 在java中设置界面控件的内容,细粒度的请求和更新,由后台来主导完整业务逻辑,而html就像c/s程序中的资源文件一样被加载,这样才能真正适合
企业应用(网站还是用以前的才对)。环境已经成熟,到应用不知道还要等多久
今天无意中竟然下载到了Refactoring Databases,哎呀,贪财贪财!
开发过程中database
schema 的变化总是引起很多麻烦,希望这本书能有所帮助。
Ruby中递归层数好像有限制,如函数
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踏实。