今天在做页面与action的datatree绑定时,碰到一个莫名奇妙的问题:
页面如下:
<layout:panel region="center" animFloat="false" autoHide="false" border="false"
fit="true" title="查询结果">
<w:dataGrid id="grid" showRowNumber="false" paged="true" rows="10" loadMask="true"
forceFit="true" toolBarPosition="both" border="false" rowInitHeight="22" trackMouseOver="true"
stripeRows="true" jsvar="gridJs">
<w:toolBar styleClass="headerToolBar">
<w:button οnclick="deleteNode();" image="#{hdf:reqContextPath()}/images/icons/delete.png" jsvar="deleteNodeJsvar" label="告警关闭" disabled="true"/>
<w:separator />
</w:toolBar>
<w:outputColumn id="eventName" header="事件名称" sortable="true" ></w:outputColumn>
<w:outputColumn id="soureType" header="资源类型" sortable="true"></w:outputColumn>
<w:outputColumn id="emgcLevel" header="告警等级" sortable="true"></w:outputColumn>
<w:outputColumn id="emgcType" header="告警类型" sortable="true"></w:outputColumn>
<w:outputColumn id="emgcContent" header="告警内容" sortable="true"></w:outputColumn>
<w:outputColumn id="emgcCount" header="次数" sortable="true"></w:outputColumn>
<w:outputColumn id="nodeid" header="选择" clientFormatter="showRadio" width="24" align="center" />
<w:outputColumn id="eventName" header="事件名称" sortable="true" clientFormatter="titleFormat"/>
<w:outputColumn id="resourceType" header="资源类型" sortable="true"/>
<w:outputColumn id="resourceName" header="资源名称"></w:outputColumn>
<w:outputColumn id="clctName" header="采集器名称"></w:outputColumn>
<w:outputColumn id="eventLevel" header="告警等级" sortable="true"></w:outputColumn>
<w:outputColumn id="emgcTitle" header="告警标题" sortable="true"></w:outputColumn>
<w:outputColumn id="emgcContext" header="告警内容" sortable="true"></w:outputColumn>
<w:outputColumn id="notify" header="通知人" sortable="true" clientFormatter="nodehostFormat"></w:outputColumn>
<w:outputColumn id="firstTime" header="第一次告警时间" sortable="true"></w:outputColumn>
<w:outputColumn id="lastTime" header="最后一次告警时间" sortable="true"></w:outputColumn>
<w:outputColumn id="count" header="次数" sortable="true"></w:outputColumn>
<w:outputColumn id="history" header="告警明细" sortable="true"></w:outputColumn>
<w:outputColumn id="state" header="状态" sortable="true"></w:outputColumn>
<w:pagingToolbar displayInfo="true" displayMsg="显示 {0} - {1},共 {2} 条" />
</w:dataGrid>
</layout:panel>
托管Bean获取数据方法如下:
@Bind
private UIDataGrid grid;
@DataModel(id = "grid")
public List<EmgcCommonBean> getPresentEmgc() throws Exception{
Map<String, Object> param = new HashMap<String, Object>();
if(null != this.emgcType && !"".equals(this.emgcType)){
param.put("emgcType", emgcType);
}
List<EmgcCommonBean> list = EmgcApprove.getInstance().queryPersentEmgc(param);
System.out.println(list.get(0).getEventName().toString);
return list;
}
后台获取数据正常,System能打印了,但前端却怎么都不显示。
经过仔细一番调试,发现后台的字段与页面字段不一致导致。(我为了好调试,后台只先读取了几个字段,而页面显示的是所有字段),我把页面多余的字段都去掉,保持与后台读出的字段一致,嘿,正常了。
我们用的框架是金蝶的OperaMasks,看来对datatree的封装还有bug啊!(或者说还不太好用!)