Skip to content

digitalspider/jcframe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

167 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaCloud Framework

The JavaCloud Framework (jcframe) makes building Java web CRUD applications really simple.

This project contains 2 artefacts:

  • A jcframe java library for building CRUD applications
  • A demo website, which is a sample war file using the jcframe code.

The development process is:

  • Create a new database table schema, or get the connection properties to existing database
  • Create a new database configuration file
  • src/main/resources/db.properties
  • Note: Different databases can be accessed through the annotation @TableName("myschema:Table")
# MySQL
myschema.driver=com.mysql.jdbc.Driver
myschema.url=jdbc:mysql://localhost:3306/TestDB
myschema.username=test
myschema.password=test

# SQLite
default.driver=org.sqlite.JDBC
default.url=jdbc:sqlite:${REALPATH}database.db
default.username=test
default.password=test
  • Create a javacloud configuration file
  • src/main/resources/jc.properties
# JavaCloud configuration file

package.name=com.mysite

#serviceloader.class=au.com.jcloud.jcframe.service.ServiceLoaderImpl
#auth.class=au.com.jcloud.jcframe.auth.BaseAuthServiceImpl
#daolookup.class=au.com.jcloud.jcframe.service.DAOLookupImpl
#viewgen.class=au.com.jcloud.jcframe.view.ViewGeneratorImpl
#ds.class=au.com.jcloud.jcframe.dao.BaseDataSource
#ds.config.file=db.properties
  • Use a tool to generate a series of beans against the database schema
  • A bean is an object representing a table in the database, extends BaseBean
  • e.g. oracle jpa page or eclipse jpa page
  • Import this JCFrame jar file into your maven
  • Download the source code using git clone https://github.com/digitalspider/jcsite.git
  • Run mvn clean install
  • Create a new WebApplication project and include the maven depenedency in pom.xml
    <!-- JavaCloud Framework -->
    <dependency>
      <groupId>au.com.jcloud</groupId>
      <artifactId>jcframe</artifactId>
      <version>1.0-SNAPSHOT</version>
    </dependency>
  • DAO and Controllers are automatically created for each bean, however you can create custom ones like this:
  • For more details see jcframe
  • For complete override of all Controllers set @BeanClass(BaseBean.class)
import java.security.Principal;
import au.com.jcloud.annotation.BeanClass;
import au.com.jcloud.model.MyData;

@BeanClass(MyData.class)
public class MyDataController extends BaseControllerImpl<MyData,Principal> {
    @Override
    public void doAction(ServletAction action, PathParts pathParts, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        super.doAction(action, pathParts, request, response);
    }
}
  • Generate some jsp pages for the bean "MyData" by running "site/generate.sh mydata"
  • src/main/webapp/jsp/mydata/list.jsp
  • src/main/webapp/jsp/mydata/show.jsp
  • src/main/webapp/jsp/mydata/edit.jsp
  • src/main/webapp/jsp/mydata/index.jsp (optional, based on @IndexPage)
  • Note: Create your own custom templates in:
  • src/main/webapp/jsp/jctemplate/<list/index/edit/show>.jsp (for page templates)
  • src/main/webapp/jsp/jctemplate//<list/index/edit/show>.jsp (for field templates)
  • These pages use the variables ${bean} or ${beans}
  • e.g. content for list.jsp
<c:forEach items="${beans}" var="bean">
    <tr>
        <td><a href="${beanUrl}/show/<c:out value='${bean.id}'/>"><c:out value="${bean.id}" /></a></td>
        <td><c:out value="${bean.title}"/></td>
        <td><c:out value="${bean.description}" escapeXml="false"/></td>
        <td><a href="${beanUrl}/edit/<c:out value='${bean.id}'/>">Update</a></td>
        <td><a href="${beanUrl}/delete/<c:out value='${bean.id}'/>">Delete</a></td>
    </tr>
</c:forEach>
<a href="${beanUrl}/insertStmt">Add MyData</a>
  • Build your application
  • mvn package
  • Deploy your application
  • Place the war file into a tomcat "webapps" directory

TODO

  • Implement AttachmentService = File Upload / display
  • Implement bean generator from DB metadata
  • Implement AJAX mechanism
  • Move DBDateFormat to new DataSourceWrapper
  • Implement custom @DBColumnName attribute
  • Implement default templates in jcframe.jar
  • Add Tests for ViewGeneratorImpl
  • Add Tests for BaseControllerImpl
  • Add Tests for BaseDAOImpl
  • Add Tests for FrontControllerServlet
  • Add ITTests for Database Testing
  • Implement custom ID types = ✅ 06/07/2016
  • Implement M2MService = Many-to-Many i.e. List ✅ 04/07/2016
  • Implement ServiceLoaderService = abstract away some of statics ✅ 27/06/2016
  • Implement namespaces in db.properties files, and in @TableName("schema:Table") ✅ 27/06/2016
  • Refactor ReflectUtil to create a centralised FieldMetaData with setMethod, getMethod, Field, ClassType ✅ 26/06/2016

About

Java web CRUD application framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages