dojo中元素用法

  1.导入CSS样式
               
               
       
        2.添加dojo.js库
       

        3.导入组件
       
       
        4.用户名和密码
           
                   
                       
                   
                   
                       
                   
               
               
                   
                       
                   
                   
                       
                   
               
               
                注:文本框用 dojoType="dijit.form.TextBox" 使用Ajax功能时,
                如果使用form:'formId'的方法时必须要有name属性,
                如果使用content:dojo.byId('').value则不必设置name属性
               
            5.单选按钮
           
           
               
                   
                       
                   
                   
                                                    id="sex1" value="男" checked="checked"/>
                       
                                                    id="sex2" value="女" />
                       
                                                    id="sex3" value="2" />
                       
                   
               
               
                注:
                必须导入组件 dojo.require("dijit.form.CheckBox");
                可以设置指定的元素获取焦点
                使用单选按钮时须指定类型 dojoType="dijit.form.RadioButton" type="radio"
                使用时name的值必须一样
               
                6.数字输入
               
               
                   
                       
                   
                   
                                                    value="18"
                            class="medium"
                            constraints="{max:100,places:0}"
                            name="age"
                            id="age"
                            required="true">
                   
               
               
                注:
                必须导入组件 dojo.require("dijit.form.NumberSpinner");
                可以设置指定的元素获取焦点
                value="18" 指定初始值
                class="medium" 方法类(用于验证)
                constraints="{max:100,places:0}" 约束最大值,小数位保留几位,0表示不用小数
                required="true" 必须填写
                invalidMessage="输出的验证信息" 可以通过该属性自定义验证的信息
               
                7.日历
               
               
                   
                       
                   
                   
                                                dojoType="dijit.form.DateTextBox"
                        constraints="{min:'1900-01-01',max:'today',formatLength:'long'}"
                        required="true"
                        trim="true"/>
                   
               
               
                注:
                必须导入组件 dojo.require("dijit.form.DateTextBox");
                可以设置指定的元素获取焦点
                value="1900-01-01"指定初始值
                constraints="{min:'1900-01-01',max:'today',formatLength:'long'}" 约束日期范围
                required="true"必须填写
                trim="true"去掉左右空格
                promptMessage="YYYY年MM月DD日" 提示消息,可以不用
                invalidMessage="输出的验证信息" 可以通过该属性自定义验证的信息
                简化类型:
               
               
               
                8.多项选择按钮
               
               
                   
                       
                   
                   
                                                    name="interest" id="interest1" value="电脑">
                       
                                                    name="interest" id="interest2" value="游泳">
                       
                                                    name="interest" id="interest3" value="网球">
                       
                                                    name="interest" id="interest4" value="看书">
                       
                   
               
               
                注:
                必须导入组件    dojo.require("dijit.form.CheckBox");
                可以设置指定的元素获取焦点
                类型为dojoType="dijit.form.CheckBox" 其他和HTML表单元素一样使用,name属性值要相同,后台使用String [] interest = request.getParameterValues("interest");获取
               
                9.下拉列表
               
               
                   
                       
                   
                   
                       
                   
               
               
                注:
                必须导入组件    dojo.require("dijit.form.FilteringSelect");
                hasDownArrow="true" 允许下拉
                类型为 dojoType=dijit.form.FilteringSelect 其他和HTML基本相同
                特别注意:必须这样的格式,如下
               
                这样的格式将无法显示内容
           
                10.email验证
               
               
                   
                       
                   
                   
                                                    dojoType="dijit.form.ValidationTextBox"
                            regExpGen="dojox.regexp.emailAddress"
                            trim="true"
                            required="true"
                            invalidMessage="E-mail地址是非法的。" />
                   
               
               
                注:
                必须导入组件
                dojo.require("dijit.form.ValidationTextBox");
                   dojo.require("dojox.validate.regexp");
                   dojo.require("dojo.parser");
                  
                   11.后台数据获取处理
                   request.setCharacterEncoding("utf-8");
                response.setCharacterEncoding("utf-8");
       
                String username = request.getParameter("username");
                String password = request.getParameter("password");
                String sex = request.getParameter("sex");
                Integer age = Integer.parseInt(request.getParameter("age").toString()
                        .trim());
                String birthday = request.getParameter("birthday");
                String[] interest = request.getParameterValues("interest");
                String nationality = request.getParameter("nationality");
                String email = request.getParameter("email");
       
                StringBuilder data = new StringBuilder();
                data.append(username).append("
").append(password).append("
")
                        .append(sex).append("
").append(age).append("
")
                        .append(birthday).append("
");
                for (int i = 0; i < interest.length; i++) {
                    data.append(interest[i]).append(" ");
                    if (i==interest.length-1){
                        data.append("
");
                    }
                }
                data.append(nationality).append("
").append(email);
       
                response.getWriter().write(data.toString());


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ttt015651/archive/2009/05/31/4227218.aspx

你可能感兴趣的:(dojo中元素用法)