zoukankan      html  css  js  c++  java
  • Extjs2.2 Itemselector的使用示例

    我的广告单元,有空点一下哦,谢谢!

    该窗体的js代码如下,(事前,请引用Itemselector相关的js文件,相css,图片,等)

    Ext.namespace("Neo");
    Ext.namespace(
    "Neo.frontdesk");

    Neo.frontdesk.SendMsg
    = Ext.extend(Ext.Window, {
    title :
    '消息发送',
    layout :
    'fit',
    width :
    650,
    height :
    320,
    id :
    'sendmsgWin',
    draggable :
    true,
    modal :
    true,
    frame :
    true,
    resizable :
    true,
    initComponent :
    function() {
    var cbmydstore =new Ext.data.Store( {
    id:
    "cbmydstore",
    autoLoad :
    true,
    proxy :
    new Ext.data.HttpProxy({url:"mgr/tsjy.htm?action=GetAllUser"}),
    reader:
    new Ext.data.JsonReader({
    root:
    "data"},
    [{name:
    "fullname"}])
    });
    Ext.apply(
    this, {
    buttons : [{
    text :
    '发送',
    id :
    'btnSubmit',
    handler :
    function() {
    var isForm=Ext.getCmp('sendmsgform');
    if(isForm.form.findField('msgdetails').getValue().trim().length<=0)
    {
    Ext.ux.Toast.msg(
    '提示', '消息不能为空。');
    return;
    }
    if(isForm.form.findField('itemselector').getValue().trim().length>0){
    Ext.Ajax.request({
    url :
    'mgr/tsjy.htm?action=addMsgs',
    success :
    function() {
    Ext.ux.Toast.msg(
    '提示', '消息群发成功。');
    Ext.getCmp(
    'sendmsgWin').close();
    var msggrid = Ext.getCmp('msgMenu');
    msggrid.getStore().reload();
    },
    failure :
    function(action) {
    if (action.failureType =='server') {
    obj
    = Ext.util.JSON
    .decode(action.response.responseText);
    Ext.Msg.alert(
    '错误:', obj.errors.reason);
    }
    },
    params : {
    receivers : isForm.form.findField(
    'itemselector').getValue(),
    msgdetails : isForm.form.findField(
    'msgdetails').getValue()
    }
    });
    }
    else{
    Ext.ux.Toast.msg(
    '提示', '找不到信息接收者。');
    }
    }

    }, {
    text :
    '取消',
    id :
    'btnCancel',
    handler :
    function() {
    Ext.getCmp(
    'sendmsgWin').close();
    }
    }],
    items :
    new Ext.form.FormPanel({
    id :
    'sendmsgform',
    frame :
    true,
    bodyStyle:
    'padding:10px;',
    items:[{
    layout :
    'column',
    border :
    false,
    items:[
    {
    layout :
    'form',
    columnWidth : .
    5,
    items:[{
    xtype:
    "itemselector",
    name:
    "itemselector",
    fieldLabel:
    "消息接收用户",
    hideLabel :
    true,
    dataFields:[
    "fullname"],
    msWidth:
    120,
    msHeight:
    200,
    toData:[],
    valueField:
    "fullname",
    displayField:
    "fullname",
    imagePath:
    "public/scripts/extjs/ux/images/",
    toLegend:
    "已选择用户列表",
    fromLegend:
    "后台用户列表",
    fromStore:cbmydstore
    }]
    },
    {
    columnWidth : .
    5,
    layout :
    'form',
    xtype :
    'fieldset',
    collapsible :
    false,
    height:
    200,
    autoScroll:
    false,
    align :
    "center",
    title :
    '消息内容',
    labelWidth:
    3,
    items : [{
    fieldLabel :
    '',
    hideLabel :
    false,
    xtype :
    'textarea',
    name :
    'msgdetails',
    id :
    'msgdetails',
    width :
    "99%",
    height :
    170,
    allowBlank :
    false,
    emptyText :
    '该项值不能为空',
    blankText :
    '该项值不能为空'
    }]
    }]
    }]
    })

    });
    Neo.frontdesk.SendMsg.superclass.initComponent.apply(
    this,
    arguments);

    }
    });

    Ext.reg(
    'sendmsg', Neo.frontdesk.SendMsg);




    Java代码:

    public
    void addMsgs(HttpServletRequest request, HttpServletResponse response)
    throws Exception {

    log.info(
    "Someone come from ip address <"+ request.getRemoteAddr()
    +">");
    log.debug(
    "reach addMsgs");
    request.setCharacterEncoding(
    "UTF-8");
    response.setContentType(
    "text/json;charset=utf-8");
    String receivers
    = (String) request.getParameter("receivers").trim();
    String details
    =(String)request.getParameter("msgdetails").trim();

    SecurityContext ctx
    = SecurityContextHolder.getContext();
    User user
    = (User) ctx.getAuthentication().getPrincipal();
    Operator operator
    = businessService.findOperatorByOpUserName(user.getUsername());
    //获得群发人员名单
    String[] receiver=receivers.split(",");
    System.out.println(receiver.length);
    for(int i=0;i<receiver.length;i++)
    {
    System.out.println(receiver[i].toString());
    if(operator.getFullName().equals(receiver[i].toString())){}
    else{
    Msg msg
    =new Msg();
    msg.setReceiver(receiver[i].toString());
    msg.setSender(operator.getFullName());
    msg.setMsgdetails(details);
    msg.setSendtime(setTime());
    msg.setIsread(
    "0");
    businessService.addNewMsg(msg);
    }
    }
    response.getWriter().write(
    "{success: true}");

    }

      

  • 相关阅读:
    IOS 中的MVC设计模式
    iOS开发中@selector的理解
    ***UML类图几种关系的总结
    使用 Storyboard Segue 实作 UIViewController 的切换
    LINUX下如何查看tomcat运行状态,判断其是否启动
    为什么很多应用都安装在/usr/local目录下
    linux进程地址空间--vma的基本操作【转】
    Linux高端内存映射(上)【转】
    linux中高端内存和低端内存的概念【转】
    Linux中断(interrupt)子系统之五:软件中断(softIRQ)【转】
  • 原文地址:https://www.cnblogs.com/qidian10/p/2143765.html
Copyright © 2011-2022 走看看