去年毕业,刚参加工作不久,新到的一家公司,被通知项目要用新的框架,Wabacus,后上网下帮助文档,看demo自行学习!发现该框架简单易懂,上手很快。至于Wabacus的意义及用法,大家可以在百度百科上去详细了解,那里说得挺清楚的。接下来我简单介绍一下Wabacus的使用方法。(现在已经更新到4.0,很快4.1也就新鲜出炉啦。)
1、先将框架所需要的包及框架自带的配置文件拷的项目中去,具体可参照demo示例。
2、先来段代码,完整的增删改查功能
<page id="listpage1">
<tabpanel id="tablistpage1" margin="10px" titlestyle="2" titlewidth="120px">
<report id="reportlistpage1" title="员工信息列表" titlealign="center" pagesize="15" interceptor="com.wabacustest.SavePer" parenttitle="普通数据列表报表" type="editablelist2" dataexport="richexcel|word">
<display>
<col column="{sequence:1}" label="序号"/>
<col column="no" label="工号">
<inputbox type="textbox" value="seq_no" source="@{select seq_user.nextval as seq_no from dual}"></inputbox>
</col>
<col column="name" label="姓名"/>
<group label="基本信息">
<col column="sex" label="性别">
<inputbox type="radiobox">
<option value="1" label="男"></option>
<option value="0" label="女"></option>
</inputbox>
</col>
<col column="age" label="年龄"/>
<col column="birthday" label="出生日期" datatype="date{yyyy-MM-dd}">
<inputbox type="datepicker"></inputbox>
</col>
</group>
<col column="deptno" label="工号" displaytype="hidden"/>
<col column="deptname" label="所属部门" updatecol="@{deptno}">
<inputbox type="selectbox">
<option value="deptno" label="deptname" source="@{select deptno,deptname from tbl_department}"></option>
</inputbox>
</col>
</display>
<sql>
<select>
<value>
<![CDATA[
select base.no,name,dept.deptno,sex,age,birthday,deptname from tbl_baseinfo base inner join tbl_department dept on
base.deptno=dept.deptno where {#condition#}
]]>
</value>
<condition name="txtno" label="员工编号:" labelstyle="2">
<value>
<![CDATA[
base.no like '%#data#%'
]]>
</value>
<inputbox type="textbox">
<typeprompt>
<promptcol label="no" title="员工编号" matchmode="anywhere" casesensitive="false"></promptcol>
<datasource>
<option source="@{select no from tbl_baseinfo where no like {#matchcondition#}}"></option>
</datasource>
</typeprompt>
</inputbox>
</condition>
<condition name="txtname" label="员工姓名:" labelstyle="2">
<value>
<![CDATA[name like '%#data#%']]>
</value>
</condition>
<condition name="txtsex" label="性别:" labelstyle="2">
<value>
<![CDATA[sex like '#data#' ]]>
</value>
<inputbox type="selectbox">
<option value="" label="不限"></option>
<option value="1" label="男"></option>
<option value="0" label="女"></option>
</inputbox>
</condition>
</select>
<insert>
<params>
<param name="seq_no" value="sequence{seq_user}"/>
</params>
<value>
insert into tbl_baseinfo(@{no},@{name},@{age},@{sex},@{birthday},@{deptno});
</value>
</insert>
<update>
update tbl_baseinfo(@{name},@{age},@{sex},@{birthday},@{deptno}) where no=@{no};
</update>
<delete>
delete from tbl_baseinfo where no=@{no}
</delete>
</sql>
<format>
<imports>
<import>java.text.*</import>
</imports>
<value>
<![CDATA[
sex=sex==null?"1":sex.trim();
if(sex.equals("1")){
sex="男";
}else{
sex="女";
}
]]>
</value>
</format>
</report>
示例效果如图所示:
report对应有多种报表类型,如:editablelist,editablelist2,crosslist,listform,blocklist,detail等等,不对的报表类型对应不同的报表效果。
这里的增删改查只需要配置相应的标签即可!页面上就会出现相应的按钮!
查询出的SQL语句中的字段,只要在<col>标签的column属性里对应,即可显示在页面上!
对于查询条件,只要配置<condition/>标签即可!
综上所述,还有很多功能,只需简单的配置一下xml配置文件即可实现!Wabacus是完整的javaEE开发框架,可以代替90%左右的ssh功能,但开发效率比后者高很多倍!