appfuse中需要注意

去掉appfuse的test

在使用appfuse1.9的时候,ant refresh会编译test里边的类,我基本不怎么使用test,所以准备去掉,通过对biuld.xml的分析,只要把这段注释掉就可以了
<!–javac srcdir=”test/@{module}” debug=”true”
destdir=”${test.dir}/@{module}/classes”>
<classpath>
<path refid=”@{module}.test.classpath”/>
<path location=”${build.dir}/@{module}/classes”/>
</classpath>
<options/>
</javac–>

关于appfuse的权限管理

appfuse 的权限管理在security.xml文件中进行定义的,但是在修改关于user操作的权限的时候就要注意了,他不单单是通过url进行控制了,还使用 aop分别在security.xml文件和applicationContext-service.xml文件中进行了限制。
sercurity.xml文件中
<aop:config>
<aop:advisor id=”managerSecurity” advice-ref=”methodSecurityInterceptor” pointcut=”execution(* net.huangxl.neumail.service.UserManager.*(..))”/>
</aop:config>
<bean id=”methodSecurityInterceptor” class=”org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor”>
<property name=”authenticationManager” ref=”authenticationManager”/>
<property name=”accessDecisionManager” ref=”accessDecisionManager”/>
<property name=”objectDefinitionSource”>
<value>
net.huangxl.neumail.service.UserManager.getUsers=admin
net.huangxl.neumail.service.UserManager.removeUser=admin             </value>
</property>
</bean>
段对方法进行了保护,只有admin的用户可以访问。
除了这个以外,还有一个类,在service包中,叫做UserSecurityAdvice.java的类,也是对UserService访问进行控制的。
<aop:config>
<aop:advisor id=”userManagerTx” advice-ref=”userManagerTxAdvice” pointcut=”execution(* *..service.UserManager.*(..))” order=”0″/>
<aop:advisor id=”userManagerSecurity” advice-ref=”userSecurityAdvice” pointcut=”execution(* *..service.UserManager.saveUser(..))” order=”1″/>
<aop:advisor id=”managerTx” advice-ref=”txAdvice” pointcut=”execution(* *..service.*Manager.*(..))” order=”2″/>
</aop:config>

在appfuse上实现autocomplete

在appfuse集成了dwr,查看web.xml文件中是不是已经把dwr的servlet加里边了,并且检查servletmapping是不已经对应到了/dwr了。
然后修改WEB-INF下的dwr.xml文件,
在allow中添加
<convert match=”net.huangxl.neumail.model.*” converter=”bean”></convert>
先把一些用户传数据的东西转化成能在网络上传输的东西。这里边converter是使用什么来进行转化,我这里边都是些pojo,可以使用bean来进行转化。
然后
<create creator=”spring” javascript=”dwrManager”>
<param name=”beanName” value=”dwrManager”/>
<include method=”getEmails”/>
<include method=”getAlia”/>
<include method=”getUsername”/>
</create>
创建一个类。
其中creator是创建的方法
new是dwr自己创建,spring是使用spring中的bean。
include是那些方法可以让js调用到。
这样以后,就可以访问
/yourapplication/dwr/
来测试工作是不是正常了。
之后就是写页面了
<script src=’<%=request.getContextPath() + “/scripts/prototype.js” %>’ type=”text/javascript”></script>
<script src=’<%=request.getContextPath() +  “/scripts/scriptaculous.js”%>’ type=”text/javascript”></script>
<script type=’text/javascript’ src=’<%=request.getContextPath() + “/dwr/interface/dwrManager.js”%>’></script>
<script type=’text/javascript’ src=’<%=request.getContextPath() + “/dwr/engine.js”%>’></script>
<script type=’text/javascript’ src=’<%=request.getContextPath() + “/dwr/util.js”%>’></script>
<script type=”text/javascript” src=’<%=request.getContextPath() + “/scripts/autocomplete.js”%>’></script>
<script type=”text/javascript”>
function updateList(autocompleter, token) {
dwrManager.getEmails(token, function(data) {
autocompleter.setChoices(data)
});
}
function nameValueSelector(tag){
return tag.email;
}
</script>
<input id=”test” type=”text” />
<div id=”testList” class=”auto_complete”></div>
<script type=”text/javascript”>
new Autocompleter.DWR(’test’, ‘testList’, updateList,{ valueSelector: nameValueSelector, partialChars: [...]

appfuse使用ibatis的时候,生成的sqlmap文件中update的paramMa顺序有问题

生成的sqlMap文件中的updateParam把id放到了第一个,对于update操作,最后一个才是id所以一定要调整一下那个map的顺序

让appfuse使用ibatis

###配置appgen
##cd extras\appgen 现在运行appgen,使用table来生成代码会报错。因为,我们已经删除了hibernate。但appgen会用到middlegen来读取数据库,而middlegen会使用到hibernate.因此需作如下改动
#将appfuse中的hibernate库文件拷贝到middlegen的lib目录下。cp appfuse\lib\hibernate-3.2 当前应用\extras\middlegen\lib\
#修伽middlegen下的build.xml文件,添加如下内容
<property name=”hibernate.dir” location=”./lib/hibernate-3.2″/>
<property name=”hibernate.jar” location=”${hibernate.dir}/hibernate3.jar”/>
<path id=”hibernate.classpath”>
<pathelement location=”${hibernate.jar}”/>
<fileset dir=”${hibernate.dir}/lib” includes=”*.jar”/>
<pathelement location=”${database.jar}”/>
<pathelement location=”${commons-beanutils.jar}”/>
<pathelement location=”${commons-lang.jar}”/>
<path location=”${build.dir}/dao/classes”/>
</path>
#这时使用appgen,使用table来生成代码,会正常运行,在build目录下即可看见生成的代码。但是appgen默认会为hibernate和 ibatis都生成相关代码。我们不想安装相关的hibernate代码,还需对appfuse的build.xml做出修改。
将<target name=”merge-config” depends=”merge-tests,merge-menu,merge-hibernate,merge-ibatis”>这行改为
<target name=”merge-config” depends=”merge-tests,merge-menu,merge-ibatis”>

去掉appfuse显示日期时间的时候的秒后边的

修改service中的DateUtil.java文件getDateTimePattern()函数,就可以是你想要的格式啦^^

解决appfuse的appgen生成新的pojo时候以前的pojo会被重新生成的问题的办法

修改middlegen的build.xml文件
找到
<target name=”all” description=”Build and install everything” depends=”install”/>
在depends上添加clean
<target name=”all” description=”Build and install everything” depends=”clean,install”/>

appfuse生成的dao的list默认不是使用example进行list

appfuse生成的dao的list默认不是使用example进行list,要去掉他的注释,才是使用条件list

appfuse有一个标签是refresh,是执行clean,undeploy,deploy的

所以我前边有一个写给deploy加clean那个就没有必要了

appfuse中没有对displaytag的properties文件进行native2ascii

appfuse的build.xml文件中只对ApplicationResources_*.properties进行了native2ascii,所以displaytag在页面会乱码,所以修改build.xml。
找到<target name=”copy-resources” depends=”prepare”   description=”Copy .properties and .xml files from source directory”>这段,然后在<exclude name=”ApplicationResources_pt*.properties”/>下边添加
<exclude name=”displaytag_zh*.properties”/>
在复制的时候不复制displaytag的properties文件。
在 <native2ascii src=”web/WEB-INF/classes” dest=”${build.dir}/web/classes”        includes=”ApplicationResources_zh*.properties” encoding=”UTF-8″/>下边添加
<native2ascii src=”web/WEB-INF/classes” dest=”${build.dir}/web/classes”
includes=”displaytag_zh*.properties” encoding=”UTF-8″/>
让ant对displaytag的资源文件native2ascii,并且直接放到build目录里边。
然后以后在deploy的时候,这样displaytag就不会出现乱码了。

posted @ 2009-04-22 15:49  QQ天堂  阅读(1466)  评论(0编辑  收藏  举报