Tabulação horizontal e vertical
25/11/2009 00:00
Bom dia
Necessito criar uma pagina onde mostro os dados de uma tabela começando da esquerda para direita e de cima para baixo, na verdade já tenho essa pagina funcionando em struts 1.x, o problema é que no struts uso for e consigo navegar na lista trazida do banco com res_cadmesa++ mas com a tag each eu não consigo ir para o próximo registo, como fazer isso ? Segue abaixo o código do domain, controller e view:
domain:
/**
* The Cadmesa entity.
*
* @author Mariolando A. Santos Infocast Sistemas
*
*
*/
class Cadmesa {
static mapping = {
table 'cadmesa'
// version is set to false, because this isn't available by default for legacy databases
version false
id generator:'identity', column:'MESA_ID'
}
Integer mesaId
Integer mesaNum
String mesaOpen
// Relation
Integer mesaLoja
static constraints = {
mesaId(max: 2147483647)
mesaNum(nullable: true, max: 2147483647)
mesaOpen(size: 0..2)
mesaLoja()
}
String toString() {
return "${mesaId}"
}
}
controller:
class MesasController {
def index = { redirect(action:list,params:params) }
// the delete, save and update actions only accept POST requests
//static allowedMethods = [delete:'POST', save:'POST', update:'POST']
def list = {
[ cadmesaInstanceList: Cadmesa.findAll("from Cadmesa as c where c.mesaLoja=? order by c.mesaNum",[2]) ]
}
}
view:
<html>
<head>
<title>Welcome to Grails</title>
<link href="/webtouch/css/style_salao.css" rel="stylesheet" type="text/css"/>
<bean:message key="page.script"/>
<script type="text/javascript">
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
alert("Permiss�o negada.");
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
</script>
</head>
<body>
<table align="CENTER" class="mainTable" style='width:780px;'>
<tr class="mainTr">
<td class="mainTd">
<table class="headerTable" style="width:780px" >
<tr>
<td class="td10">
<%
session.setAttribute("mesa_open","");
session.setAttribute("comanda","");
session.setAttribute("garcom","");
session.setAttribute("mesa_id","");
session.setAttribute("cadven_id",null);
session.setAttribute("res_Cadven",null);
session.setAttribute("res_Cadmov",null);
session.setAttribute("res_Cadmov1",null);
session.setAttribute("res_Cadbai",null);
session.setAttribute("res_Cadlog",null);
session.setAttribute("res_Cadcli",null);
session.setAttribute("res_Cadtel",null);
session.setAttribute("res_Cadconf",null);
session.setAttribute("exception",null);
%>
<bean:message key="page.title"/>
</td>
<td>
<div class='div10'>
<jsp:useBean id="now" class="java.util.Date" />
<fmt:formatDate pattern="dd/MM/yyyy hh:mm:ss" value="${now}" />
</div>
</td>
</tr>
</table>
<jsp:forward page="/system/ErrorPage.jsp"/>
<form name="bl_report_Cadmesa" id="bl_report_Cadmesa" class="baseForm" method="post" >
<table class="bannerTable" style="width:640;">
<tr class="bannerTr">
<td class="bannerTd">
Venda em Loja
</td>
</tr>
</table>
<table id="TRbl_report_Cadmesa" style="width:100%;height:500" border="1" align="center" cellpadding="1" cellspacing="0">
<g:each in="${cadmesaInstanceList}" status="i" var="cadmesaInstance">
<tr class='<%= style_bl_report_Cadmesa %>' id="TRbl_report_Cadmesa<%=i_bl_report_Cadmesa%>" >
<g:each var="g" in="${ (0..<10) }">
<td align="center" valign="middle" bgcolor=<% if(mesa_open.equals("1"))out.print("#FF0000");else if(mesa_open.equals("2"))out.print("#FFFF00");else out.print("#00FF00");%> style="font-size: large">
<a href="http://localhost:8080/webtouch/mesas/mesa?mesa_fone=${fieldValue(bean:cadmesaInstance, field:'mesaNum')}&mesa_id=${fieldValue(bean:cadmesaInstance, field:'mesaId')}&mesa_open=${fieldValue(bean:cadmesaInstance, field:'mesaOpen')}&loja=${fieldValue(bean:cadmesaInstance, field:'mesaLoja')}">
<strong>
${fieldValue(bean:cadmesaInstance, field:'mesaNum')}
</strong>
</a>
</td>
</g:each>
</tr>
</g:each>
</table>
<table class="footerTable">
<tr class="footerTr">
<td class="footerTd">
<bean:message key="div.print"/>
</td>
</tr>
</table>
</table>
</body>
</center>
</html>
Tags:
Grails