Skip to main content

Maplet Framework

No replies
bozorgvar
Offline
Joined: 2010-07-25

this code looks more MVC.
check it
1 - changing .property files to .java files is amazing
2 - maplet:DataTable code is very clear and useful
3 - even it is possible to jump between more maplets and axecute exactly pageName method only.

dont forget to add shine enterprise java pattern libraries .

fileName : maplet.tld
=====================
<?xml version="1.0" encoding="UTF-8"?>

1.0
1.1
maplet

Service
org.j2os.shine.maplet.tag.Service
JSP

name

SecureService
org.j2os.shine.maplet.tag.SecureService
JSP

name

ErrorService
org.j2os.shine.maplet.tag.ErrorService
JSP

Resource
org.j2os.shine.maplet.tag.Resource
JSP

show

from

DataTable
org.j2os.shine.maplet.tag.DataTable
JSP

DataRow
org.j2os.shine.maplet.tag.DataRow
JSP

=====================

fileName : Resuest.jsp
=====================
<%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>

=====================

fileName : Response.jsp
=====================
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ taglib uri="/WEB-INF/maplet.tld" prefix="maplet"%>

oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@javaserver:1521:xe
iranair
iran123
select * from users
style="background-color: red; border: 1px solid"
style="background-color: green; border: 5px solid"
style="background-color: pink"
style="background-color: gray"

=====================

fileName : Core.java
=====================
package controller;

import model.database.dao.T1DAO;

import org.j2os.shine.maplet.Maplet;

public class Core extends Maplet {
private T1DAO t1;
public String name;

public void startup() throws Exception {
try {
t1 = new T1DAO("model/database/setting/Connection.xml");
System.out.println("DataBaseLogin");
} catch (Exception e) {
out.print(e);
}
}

public void request() throws Exception {
t1.insert(0, name, "none");
secureForward("Response.jsp", "insert");
}
}
=====================

fileName : T1DAO.java
=====================
package model.database.dao;

import model.database.dto.*;

import org.j2os.shine.jconnection.*;

import java.util.*;

public class T1DAO extends Hibernate {
public T1DAO(String address) throws Exception {
login(address);
}

public void insert(long id, String name, String famil)
throws Exception {
// if id!=0 => update
begin();

T1 object = new T1();
object.setId(id);
object.setName(name);
object.setFamil(famil);
saveOrUpdate(object);
commit();
}

public void delete() throws Exception {
begin();

Iterator i = getSQLQueryContent("select * from t1",
"model.database.dto.T1");

while (i.hasNext()) {
T1 object = (T1) i.next();
delete(object);
}

commit();
}

public void update() throws Exception {
begin();

Iterator i = getSQLQueryContent("select * from t1",
"model.database.dto.T1");

while (i.hasNext()) {
T1 object = (T1) i.next();
object.setFamil("bahador");
saveOrUpdate(object);
}

commit();
}

public void select() throws Exception {
begin();

Iterator i = getSQLQueryContent("select * from t1",
"model.database.dto.T1");

while (i.hasNext()) {
T1 object = (T1) i.next();
System.out.println(object.getName());
}

commit();
}
}
=====================

fileName : T1.java
=====================
package model.database.dto;
import org.j2os.shine.maplet.tag.DataTable;
public class T1 {
private long id;
private String name;
private String famil;

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setFamil(String famil) {
this.famil = famil;
}

public String getFamil() {
return famil;
}

public void setId(long id) {
this.id = id;
}

public long getId() {
return id;
}
}
=====================

fileName : T1.xml
=====================
<?xml version="1.0" encoding="utf-8" ?>

=====================

fileName : Connection.xml
=====================
<?xml version="1.0" encoding="utf-8"?>

oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@javaserver:1521:xe
root
root
10
true
org.hibernate.dialect.GenericDialect

=====================

fileName : EN.java
=====================
package resource;

public class EN {
public String msg1 = "insert your name";
public String msg2 = "finish";
}
=====================

fileName : FA.java
=====================
package resource;

public class FA {
public String msg1 = "نام را وارد کنید";
public String msg2 = "اتمام";
}
=====================