NutzCN Logo
问答 关于代码生成器的html页面模板支持更多类型的问题
发布于 210天前 作者 liumaobudao 164 次浏览 复制 上一个帖子 下一个帖子
标签:

这个是add.html.vm页面 判断column为日期类型生成相应日期控件的代码,貌似无效求指点。。。。。

#if ($column.isBoolean())
							<form:select path="${column.FieldName}" class="${column.ValidationFormClass}" placeholder="$temp">
								<form:option value="true">${msg['globals.table.column.true']}</form:option>
								<form:option value="false">${msg['globals.table.column.false']}</form:option>
							</form:select>
#elseif ($column.isDate())
                            <div class="input-group date form_date"  data-date="1979-09" data-date-format="MM yyyy" data-link-field="${column.FieldName}">
                                <input type="text" size="16" readonly class="form-control" value=" " data-date-format=" MM yyyy" data-parsley-required="true">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                            </div>
                            <input type="hidden" id="${column.FieldName}" name="${column.FieldName}" value="${@date.getDate()}" />
#else
                            <input type="text" id="${column.FieldName}" class="form-control" name="${column.FieldName}" data-parsley-required="true" placeholder="$temp">
#end
                            </div>
3 回复

好吧 自己动手! 增加了 日期控件和下拉框
ColumnDescriptor.java类

    public String cuntomType;//添加
    public String getJavaType() {//修改
        if ("tinyint".equalsIgnoreCase(dataType) && size == 1) {
            return boolean.class.getName();
        }
        if ("enum".equalsIgnoreCase(dataType)) {
            return getUpperJavaFieldName();
        }
        if ("DATE".equalsIgnoreCase(dataType)) {
            return "DATE";
        }
        if ("VARCHAR(200)".equalsIgnoreCase(cuntomType)) {
            return "VARCHAR(200)";
        }
        Class<?> type = typeMapping.get(dataType);
        if (type != null) {
            return type.getName();
        }

        return String.class.getName();
    }

add.html.vm

#if ($column.isBoolean())
							<form:select path="${column.FieldName}" class="${column.ValidationFormClass}" placeholder="$temp">
								<form:option value="true">${msg['globals.table.column.true']}</form:option>
								<form:option value="false">${msg['globals.table.column.false']}</form:option>
							</form:select>
#elseif ($column.JavaType=="DATE")
                            <div class="input-group date form_date"  data-date="1979-09" data-date-format="MM yyyy" data-link-field="${column.FieldName}">
                                <input type="text" size="16" readonly class="form-control" value=" " data-date-format=" MM yyyy" data-parsley-required="true">
                                <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                                <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                            </div>
                            <input type="hidden" id="${column.FieldName}" name="${column.FieldName}" value="${@date.getDate()}" />

#elseif ($column.JavaType=="VARCHAR(200)")
                            <select class="form-control" name="${column.FieldName}" id="${column.FieldName}">
                                <option value=""></option>
                                <% for(o in @dict.getSubListByCode('${column.Comment}')){
                                %>
                                <option value="${o.code}">${o.name}</option>
                                <%
                                } %>
                            </select>
#else

                            <input type="text" id="${column.FieldName}" class="form-control" name="${column.FieldName}" data-parsley-required="true" placeholder="$temp">
#end

EntityDescLoader.java
修改

                    if (annotation instanceof ColDefine) {
                        ColType colType = ((ColDefine) annotation).type();
                       // ColType colTypess = ((ColDefine) annotation).customType();
                        column.setColumnType(colType.name());
                        column.dataType = colType.name();
                        column.cuntomType =((ColDefine) annotation).customType();
                    }
添加回复
请先登陆
回到顶部