JAVA开发常用代码积累

1.Hibernate关联Oracle数据库使用GUID生成主键

@Id
@GeneratedValue(generator = "paymentableGenerator")       
@GenericGenerator(name = "paymentableGenerator", strategy = "guid") //使用oracle的GUID生成主键 

 2.修改Ext css文件改变grid的样式

(1).鼠标放在单元格上市整行加粗

.x-grid-row-over .x-grid-td {
    background-color: #efefef;
    font-weight: bold;
    color:blue;
}

效果:

3.一截截比较重要的常用Ext Tpl代码

//数据格式化
var getImgURL = function(data){
    var cat = data.category;
    if(cat=='标准间'){
        return BASEPATH+'images/rom2.png';
    }else if(cat=='总统套间'){
        return BASEPATH+'images/rom1.png';
    }
}
//取得鼠标所在位置坐标
function mousePosition(evt){
    var xPos,yPos;         
    evt=evt || window.event;
    if(evt.pageX){         
        xPos=evt.pageX;         
        yPos=evt.pageY;     
    } else {         
        xPos=evt.clientX+document.body.scrollLeft -document.body.clientLeft;
        yPos=evt.clientY+document.body.scrollTop-document.body.clientTop;     
    }
    return [xPos, yPos];
}
//鼠标移动在上面的事件
function fnover(o){
    o.style.border ='1px solid #D7E4F2';
    o.style.backgroundColor="#eeeeee";
    o.style.borderRadius ='8px';
}
//鼠标移除事件
function fnout(o){
    o.style.border ='none';
    o.style.backgroundColor="#ffffff";
}
//鼠标右键事件
function showMenu(o,e){
      //屏蔽右键菜单
      $.hideMouseUpMenu();
      if(e.button==2){
          //标识按下的事右键
          var ar = mousePosition(e);
          Ext.create('Ext.menu.Menu',{
                        plain:true,
                        baseCls:'x-plain',
                        items : [
                        {
                            text : '订房',
                            handler : function(btn){
                                var str = o.className;
                                var arr = str.split(',');
                                Ext.create('Ext.window.Window',{
                                    iconCls:'home',
                                    title:'订房操作:<font color=red>'+'房间号:'+o.id+','+arr[2]+'</font>',
                                    500,
                                    height:300,
                                    autoShow:true,
                                    modal:true,
                                    buttonAlign:'center',
                                    buttons:[
                                        {
                                            text:"确认"
                                        },
                                        {
                                            text:"重置"
                                        },
                                        {
                                            text:"取消",
                                            handler:function(b,e){
                                                b.up('window').close();
                                            }
                                        }
                                    ]
                                });
                            }
                        },{
                            text : '查看详细信息',
                            handler : function(btn){
                                
                            }
                        }]
                }).showAt(ar[0],ar[1]);
      }   
}  
//定义订房界面
Ext.define("AM.view.OrderView", {
            extend : 'Ext.panel.Panel',
            alias : 'widget.orderview',
            title:'空闲房间',
            autoScroll:true,
            items:{
                xtype:'dataview',
                  itemSelector: 'div.thumb-wrap',
                emptyText: '没有查到符合条件的数据',
                multiSelect: true,
                trackOver: true,
                overItemCls: 'x-item-over',
                store: 'OrderStore',
                tpl : Ext.create('Ext.XTemplate',
                    '<tpl for=".">',
                        '<div id={romnum} class={romnum},{seeuser},{category},{romphone},{romdesc},{romstate} onmouseover=fnover(this) onmouseout=fnout(this) onmouseup=showMenu(this,event) style="border:0px solid red;margin:5px;height:110px; 100px;float:left">',
                            '<div style="text-align:center;100px;height:60px;border:0px solid blue;"><img width=60 height=60 src={img_url} /></div>',
                               '<div style="text-align:center;100px;border:0px solid blue;margin-top:5px;">{romnum}:{category}</div>',
                               '<div style="text-align:center;100px;border:0px solid blue;margin-top:5px;">位置:{romdesc}</div>',
                        '</div>',
                    '</tpl>'
                ),
                 prepareData: function(data) {
                    Ext.apply(data,{
                        img_url:getImgURL(data)
                    });
                    return data;
                 }
            },
            tbar : [
                    '空闲房间列表,鼠标右键进行操作',
                    '->',
                    {
                        xtype : 'textfield',
                        id : 'key',
                        name : "key",
                        emptyText:'关键字',
                        width : 148
                    }, {
                        id : 'searchBtn',
                        iconCls : 'search',
                        text : '搜索'
                    }

            ],
            initComponent : function() {
                this.callParent(arguments);
            }
        });
View Code

运行截图:

原文地址:https://www.cnblogs.com/zhougaojun/p/3425487.html