Appfuse 2 FAQ

 
 
AppFuse 命名规范:
com.company.app.model -> Entities
com.company.app.dao -> Dao Interfaces
com.company.app.dao.hibernate -> Hibernate Implementations
com.company.app.service -> Service Interfaces
com.company.app.service.impl -> Service implementation
com.company.app.webapp.action -> Struts Actions (this really depends on the framework you're using)
 
 
基于 appfuse 生成的 project 会有引用 Appfuse core entity class 和一些 module ,如果我希望直接把这些东东作为我的 project source ,而不是引用它,该怎么办 ?
如果你的project希望不依赖 AppFuse dependencies ,而是把 AppFuse source code 加入到你的 project 的话run mvn appfuse:full-source. 该命令将会把 Appfuse source code 添加到你的 project 里,这样你就再也不需要 AppFuse dependencies 了,因为 project 已经包含了它。
 
注意: mvn appfuse:full-source 仅适用于 basic archetypes.
 
 
How do I customize the header and footer messages in 2.x?
缺省的 header message 为:
AppFuse
Providing integration and style to open source Java
 
如果你想改变它,只需要修改 src/main/resources/ApplicationResources.properties 文件里的 webapp.name and webapp.tagline keys.
 
如果要修改 footer "Your Company Here" text and its URL ,则是修改 company.name and company.url 属性
 
 
How do I customize Login and Error Pages in 2.x
If you would like change the any of the pages that appear in the root directory of your application, for example:
login.jsp , error.jsp, 404.jsp, logout.jsp
Put copies of your modified jsp files into src/main/webapp .
If you want to copy existing versions of these files and modify them, look for them in your target/YOUR_APP_NAME/ directory.
 
 
Why don't I have to install Tomcat with 2.x?
如果你执行命令
       mvn integration-test
Maven Cargo plugin就会自动帮你下载安装tomcat 5.5.x (or later),而且对你的project进行integration test( 集成测试)。
 
如果你想把project在web server上运行,有3种方案:
1. Run mvn jetty:run-war 启动 an Jetty instance and deploy your app. It will be available at
 
2. Run mvn cargo:start -Dcargo.wait=true and your application will be deployed to Tomcat and
available at http://localhost:8081/war_file_name .
 
3. 在你的 pom.xml 添加 Maven 2 Tomcat Plugin 配置 ( 见下面代码 ) ,然后 run mvn tomcat:run and mvn tomcat:run-war .
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>tomcat-maven-plugin</artifactId>
    <configuration>
       <path>/</path>
    </configuration>
</plugin>
 
 
怎样把 project 运行在我以前就安装好的 tomcat 里?
If you want to change Cargoto point to an existing instance of Tomcat, you should be able to change the bottom of pom.xml from:
<container>
    <containerId>${cargo.container}</containerId>
    <!--home>${cargo.container.home}</home-->
    <zipUrlInstaller>
        <url>${cargo.container.url}</url>
        <installDir>${installDir}</installDir>
    </zipUrlInstaller>
</container>
To:
<container>
    <containerId>${cargo.container}</containerId>
    <home>${cargo.container.home}</home>
</container>
 
 
AppFuse 2.x archetypes 2 类:一类是 "basic" ,另一类是 "modular" ,两者有什么区别?
Basic archetypes:本人粗浅的理解为“生成的project会把所有的source都打包进war” ,不会有“由于可重用的考虑,分成几个模块,每个模块先打包(如安全模块打包成security.jar),然后再打包成WAR”。 appfuse 推荐这种形式】
 
Modular archetypes:出于可重用的考虑,对模块先打包(如打包成jar),然后再打包进WAR。Maven requires you to have a different "module" for each artifact you want to produce (i.e. JAR or WAR).
 
 
How do I tell IDEA to ignore deployment descriptors when compiling?
Right-click on the file in the messages window and choose "Exclude From Compile".
How can I export my database using DbUnit?
Running mvn dbunit:export will export your database to target/dbunit/export.xml. You can override the destination location by passing in a -Ddest parameter:
mvn dbunit:export -Ddest=sample-data.xml
 
How can I change my AppFuse-generated project to use iBATIS or JPA?
As of AppFuse 2.0 M5+, it's as easy as changing your changing the <dao.framework> property in your root pom.xml to ibatis or jpa (jpa-hibernate in 2.0 M5). For further instructions, please see the JPA and iBATIS tutorials.
Is there any documentation that describes what all the filters do in web.xml?
See the Web Filters Reference Guide for a list of what each filter in web.xml is used for.
How do I configure LDAP Authentication?
See the LDAP Authentication page for a sample configuration.
How do I debug my application when it's running in Jetty?
Dan Allen has a nice writeup of how to do remoting debugging with Jetty.
How do I make Jetty start on a specific port?
There are two easy methods depending on whether you want the change to be permanent (i.e. each time you run 'mvn jetty:run-war' or a manual port change.
Permanent: In your project pom.xml look for the plugin with the artifactid 'maven-jetty-plugin' and add the <connectors> elements to it:
<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <version>6.1.5</version>
    <configuration>
        ...
        <connectors>
            <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
               <port>8081</port>
            </connector>
        </connectors>
    </configuration>
</plugin>
Manual: run 'mvn jetty:run-war -Djetty.port=8081'
When saving Chinese or Japanese characters in a form, I'm getting java.sql.SQLException: Incorrect string value. How do I solve this?
To solve this problem, you'll need to drop and recreate your database with UTF-8 enabled. The following example shows how to do this with a database named myproject:
mysqladmin -u root -p drop myproject
mysqladmin -u root -p create myproject
mysql -u root -p
<enter password>
mysql> ALTER DATABASE myproject CHARACTER SET utf8 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT COLLATE utf8_general_ci;
mysql> exit
You can also configure MySQL to use UTF-8 by default by adding the following to your c:/Windows/my.ini or /etc/my.cnf (on Unix) file:
[mysqld]
default-character-set=utf8
When using jetty:run, CSS and JavaScript files are locked - how can I fix this?
Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. This means that effectively you have to stop Jetty in order to update a file.
The problem is explained more in Jetty's documentation. To fix this, add a line with <webDefaultXml> to your maven-jetty-plugin configuration:
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.5</version>
<configuration>
    ...
    <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
</configuration>
The default webdefault.xml file is found in the lib/jetty.jar at org/mortbay/jetty/webapp/webdefault.xml . Extract it to a convenient disk location and edit it to change useFileMappedBuffer to false:
<init-param>
    <param-name>useFileMappedBuffer</param-name>
    <param-value>false</param-value>
</init-param>
 
 

Using Struts, how can I dynamically add columns to a Table using a list of beans nested in my table row data?

This is the scenario. You are presenting a list of your data on a standard mymodelList.jsp form, using the Display tag library. Your data bean has an attribute that is a list of related data beans. In this scenario, you wish to display that related data in extra columns in your table. Here is one way to achieve this.

The following code example assumes that your Action class has generated a list of parentBean objects and exposes that with a getParentBeans() method that returns a List<ParentBean>. The ParentBean object includes an attribute that is a list of ChildBean objects.
Our simple beans have the following structure:

ParentBean
  • String: id
  • String: title
  • List<ChildBean> childBeans
ChildBean
  • String: id
  • String: name
  • Date: lastUpdated

... and the markup goes something like this...

parentBeanList.jsp
<%-- Normal page header and footer stuff excluded for brevity --%>
<display:table name="parentBeans" class="table" requestURI="" id="parentBeans" export="true" pagesize="25">
    <%-- this is a normal column displaying the "ParentBean.title" attribute --%>
    <display:column property="title" sortable="true" href="editParentBean.html"
        media="html" paramId="id" paramProperty="id" titleKey="parentBean.title"/>
    <display:column property="title" media="csv excel xml pdf" titleKey="parentBean.title"/>

    <%-- Iterate through the childBeans list if present and display a name and lastUpdated column for each --%>
    <%-- We gain access to our parentBean's childBeans list using the #attr.parentBeans.childBeans reference --%>
    <s:if test="#attr.parentBeans.childBeans != null && #attr.parentBeans.childBeans.size() > 0">
        <%-- IMPORTANT NOTE - in this example, the List is actually implemented by a TreeMap (to facilitate sorting) so the
          reference is to the list's "values()" method, otherwise the iterator will return a Map object (containing
          a key and your bean) rather than just the bean.  If your childBeans list is a normal List (eg ArrayList)
          you'd simply put 'value="#attr.parentBeans.childBeans"' in the next line --%>
        <s:iterator id="childBean" value="#attr.parentBeans.childBeans.values()" status="col">
            <%-- Now, complete the display:column object. --%>
            <display:column sortable="false" titleKey="childbean.name">
                <%-- Note, the refeence to $/{id/| in the next row is obtained by using the id attribute value from
                     the <display:table tag (see above).  In this example, we edit a childBean by going to the
                     editor for its ParentBean --%>
                <a href="editParentBean.html?id=$/{parentBeans.id/|">
                    $/{childBean.name/|
                </a>
            </display:column>
            <display:column sortable="false" titleKey="childbean.lastUpdated">
                <fmt:formatDate value="$/{lastUpdated/|" pattern="$/{timePattern/|"/>
            </display:column>
        </s:iterator>
    </s:if>

    <%-- Paging and export properties excluded for brevity --%>
</display:table>
 
 
 
 
 
 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值