Created
May 14, 2015 06:45
-
-
Save TheB1ackSheep/77a2d9224d43a51b2d26 to your computer and use it in GitHub Desktop.
JSP Tag File with Attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package model; | |
import database.Column; | |
import database.ORM; | |
import database.SQL; | |
import java.sql.ResultSet; | |
import java.util.List; | |
/** | |
* Created by Falook Glico on 5/14/2015. | |
*/ | |
public class Bank implements ORM { | |
private int id; | |
private String name; | |
private String slug; | |
public static final String TABLE_NAME = "BANKS"; | |
public static final Column COLUMN_ID = ORM.column(TABLE_NAME,"BANK_ID"); | |
public static final Column COLUMN_NAME = ORM.column(TABLE_NAME,"NAME_TH"); | |
public static final Column COLUMN_SLUG = ORM.column(TABLE_NAME,"SLUG"); | |
public static final List<Column> PRIMARY_KEY = ORM.columns(COLUMN_ID); | |
public int getId() { | |
return id; | |
} | |
public void setId(int id) { | |
this.id = id; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public String getSlug() { | |
return slug; | |
} | |
public void setSlug(String slug) { | |
this.slug = slug; | |
} | |
@Override | |
public void orm(ResultSet rs) throws Exception { | |
this.id = rs.getInt(COLUMN_ID.getColumnName()); | |
this.name = rs.getString(COLUMN_NAME.getColumnName()); | |
this.slug = rs.getString(COLUMN_SLUG.getColumnName()); | |
} | |
public List<Bank> findAll() throws Exception { | |
return (List<Bank>)SQL.findAll(Bank.class); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%-- | |
Created by IntelliJ IDEA. | |
User: Falook Glico | |
Date: 5/14/2015 | |
Time: 13:41 | |
To change this template use File | Settings | File Templates. | |
--%> | |
<%@ page contentType="text/html;charset=UTF-8" language="java" %> | |
<%@ taglib tagdir="/WEB-INF/tags" prefix="m"%> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<div class="flex"> | |
<m:bankBox id="${param.id}"/> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ tag import="database.SQL" %> | |
<%@ tag import="model.Bank" %> | |
<%@ tag pageEncoding="UTF-8"%> | |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | |
<%@ attribute name="id" required="true" rtexprvalue="true" %> | |
<c:set var="bank" value="<%=SQL.findById(Bank.class,id)%>"/> | |
<div class="bank"> | |
<div class="bank-img"><img src="images/${bank.slug}.png"/></div> | |
<div class="bank-name">${bank.name}</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment