嗨,我有一个 gsp,它将具有 jq 网格和一些最初将加载的模板。如果控制器有问题,它会抛出 flash.warning 之类的
def err = resp?.status?.message?:resp?.status?.message?:message(code:'common.unknown.error')
flash.warning = message(code:'common.error.default', args:[err])
在普惠制中,我会抓住它
<div id="errorPanel">
<g:if test="${flash.warning}">
<g:message code = "reporting.label" />
<div class="message">${flash.warning}</div>
</g:if>
</div>
如果控制器发出警告,则一切都很好,它仅在页面刷新后才显示。请帮帮我
我的gsp是
<%@ page language="java" import="com.cisco.rms.constants.TicketType" %>
<html>
<head>
<meta name="layout" content="main" />
<g:set var="entityName" value="${message(code: 'incident.label', default: '<incident.label>')}" />
<title><g:message code = "incident.list" /></title>
</head>
<body>
<div id="errorPanel">
<g:if test="${flash.warning}">
<g:message code = "reporting.label" />
<div class="message">${flash.warning}</div>
</g:if>
</div>
<div class="ros-pageContainer">
<div id="incidentListContainer" class="rosPanel">
<div id="incidentListHeaderContainer">
<div class="ui-widget-header">
<span class="ros-title"> <g:message code="incident.label.plural" /> </span>
<g:include controller="ticket" action="searchTicketsInclude"/>
<!--
<span class="header-quick-action">
<select name="quickactions">
<option selected> <g:message code="common.quickActions.header" /> </option>
<option value="download"><g:message code="common.quickActions.download" /> </option>
<option value="list and details"><g:message code="common.quickActions.listAndDetails" /> </option>
<option value="list only"><g:message code="common.quickActions.listOnly" /> </option>
<option value="list all"><g:message code="common.quickActions.listAll" /> </option>
<option value="print list"><g:message code="common.quickActions.printList" /> </option>
<option value="columns"><g:message code="common.quickActions.columns" /> </option>
</select>
</span> -->
</div>
</div>
<jqgrid:wrapper id="incident" />
</div>
<g:render template="details"/>
<br/>
<g:render template="/site/sitesAffected"/>
<br/>
<g:render template="/device/listForIncident"/>
<br/>
<g:render template="/workLog/list"/>
<br/>
<g:render template="/alarm/listForIncident"/>
</div>
<g:render template="/layouts/gridTemplate" />
<script type="text/javascript">
function searchByTicketId()
{
var ticketId = $('#ticketId').val();
var id_type = $("input[@name=id_type]:checked").val();;
var ext = false;
if(id_type == 'external')
ext = true;
search(ticketId, ext);
}
function search(ticketId, ext)
{
var grid = $('#incidentGrid');
grid.jqGrid("clearGridData", true);
grid.jqGrid('setGridParam',{postData:{ticketId:ticketId, extTicketId:ext}});
grid.trigger( 'reloadGrid' );
// alert('ticketId: ' + ticketId + ' type: ' + id_type + ' external: ' + ext);
}
function resetSearch()
{
$('#ticketId').val('');
var grid = $('#incidentGrid');
grid.jqGrid("clearGridData", true)
grid.jqGrid('setGridParam',{postData:{ticketId:null}});
grid.trigger( 'reloadGrid' );
}
function onIncidentGridComplete() {
var devCount = $('#incidentGrid').getGridParam("reccount");
if (devCount == 1) {
var rowId = $('#incidentGrid').getDataIDs()[0];
$('#incidentGrid').setSelection(rowId, true);
}
$(window).trigger('resize');
}
var ticketId;
var ticketType = '${com.cisco.rms.constants.TicketType.INCIDENT}';
function quickActions(actionsList)
{
var sel = actionsList.selectedIndex
if(sel == 1)
{
window.open('../workLog/addWorkLog?ticketId=' + ticketId + '&ticketType=' + ticketType, 'Add Worklog', 'width=600,height=600', false)
}
}
function resizeGrid(){
//$('#incidentGrid').jqGrid('setGridHeight',$(window).outerHeight() - 255 - 25 - $("#incidentDetailsContainer").outerHeight());
}
function clearDetails() {
clearIncDetails();
}
function onSelectRow(rowId) {
clearDetails();
$('#quickActions').show();
ticketId = $('#incidentGrid').getCell(rowId, 'id');
populateDetails(rowId);
var rowMinus1 = parseInt(rowId) - 1;
$("#incidentGrid tr").removeClass("ui-state-highlight-1");
$("#incidentGrid tr:eq(" + rowMinus1 + ")").addClass("ui-state-highlight-1");
resizeGrid();
reloadDeviceGrid(ticketId);
reloadWorklogs (ticketId, ticketType);
reloadSitesAffectedGrid(ticketId, ticketType);
reloadAlarms(ticketId);
}
function populateDetails(rowId) {
var grid = $('#incidentGrid');
var id = grid.getCell(rowId, 'id');
var submitDate = grid.getCell(rowId, 'submitDate');
var summary = grid.getCell(rowId, 'summary');
var status = grid.getCell(rowId, 'status');
var type = grid.getCell(rowId, 'type');
var data = {id:id, submitDate:submitDate, summary:summary, status:status, type:type};
populateIncDetails(data);
}
$(document).ready(function() {
<jqgrid:grid
id="incident"
url="'${createLink(action: 'listByCompanyJSON', params: [ticketId: params.ticketId])}'"
colNames="
'${g.message( code:'common.priority' )}',
'${g.message( code:'common.id' )}',
'${g.message( code:'user.details.site' )}',
'${g.message( code:'common.impact' )}',
'${g.message( code:'incident.opened' )}',
'${g.message( code:'common.parameters.duration' )}',
'${g.message( code:'common.status' )}',
'${g.message( code:'common.description' )}',
'${g.message( code:'common.type' )}'
"
colModel="
{name:'priority', editable: false, fixed: true, width:'55px'},
{name:'id', editable: false, fixed: true, width:'100px'},
{name:'siteName', editable: false, fixed: true, classes:'ellipsis', width: '200px'},
{name:'impact', editable: false, fixed: true, width:'125px'},
{name:'submitDate', editable: false, fixed:true, width:'125px'},
{name:'duration', editable: false, fixed:true, width:'95px'},
{name:'status', editable: false, fixed: true, width:'65px'},
{name:'summary', editable: false, classes:'ellipsis' },
{name:'type', editable: false, hidden: true}
"
gridComplete="onIncidentGridComplete"
onSelectRow="onSelectRow"
resizable="true"
sortname="'id'"
sortorder="'desc'"
height="265"
autowidth="true"
shrinkToFit="true"
scrollOffset="16"
viewrecords="true"
showPager="true"
rowNum="12"
datatype="'json'">
<jqgrid:navigation id="incident" refresh="true" />
<jqgrid:resize id="incident" resizeOffset="0" />
</jqgrid:grid>
//Strips garbage from grid
$("#incidentListContainer").find("#incidentWrapper").first().removeClass("ui-widget-header");
//Wires window resize so grid will fit properly at all sizes
$(window).resize(resizeGrid);
$(window).trigger('resize');
}
);
</script>
</body>
</html>