Created
May 14, 2015 07:20
-
-
Save TheB1ackSheep/2d0544d1724cd9c5cd85 to your computer and use it in GitHub Desktop.
JSP Tag File with Dynamic 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
<%@tag pageEncoding="UTF-8" dynamic-attributes="attr" %> | |
<jsp:useBean id="bank" class="model.Bank"/> | |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> | |
<h1>${attr.header}</h1> | |
<div class="flex"> | |
<c:forEach var="b" items="${bank.findAll()}"> | |
<div class="bank"> | |
<div class="bank-img"><img src="images/${b.slug}.png"/></div> | |
<div class="bank-name">${b.name}</div> | |
</div> | |
</c:forEach> | |
</div> |
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: 00:50 | |
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>Our Banks</title> | |
<style> | |
.flex{ | |
display: flex; | |
display: flex; | |
flex-wrap: wrap; | |
justify-content: center; | |
width: 440px; | |
margin: 0 auto; | |
} | |
.bank { | |
text-align: center; | |
margin: 10px; | |
} | |
.bank-img { | |
width: 200px; | |
} | |
img{ | |
width: 100%; | |
} | |
</style> | |
</head> | |
<body> | |
<m:bankTable header="ธนาคาร"/> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment