区域更新错误内的 Tapestry 网格
Tapestry Grid inside Zone update error
我正在尝试完成一个简单的任务:从数据库中删除一条记录,更新网格,其中源属性指向用户列表,从数据库下载。我在 tml 中有一个 Grid 组件:
<div t:type="zone" t:id="deleteZone" id="deleteZone">
<table t:type="grid" source="allAdmins" row="currAdmin" empty="blabla" model="adminTableModel"
add="delete,lock">
<p:deleteCell>
<t:actionlink t:id="delete" context="${currAdmin.}" zone="deleteZone">
Delete admin
</t:actionlink> <!--context=""-->
</p:deleteCell>
</table>
</div>
在页面 class 内,我有:
public List<AUser> getAllAdmins() {
return webHelpService.getAllUsers(true);
}
@InjectComponent
private Zone deleteZone;
Object onActionFromDelete(int code) {
Admins adminToChange = dao.getAdmin(code);
if(code!=0) {
dao.deleteAdmin(adminToChange);
}
return deleteZone.getBody();
}
但是当我按下删除按钮时,出现以下 Tapestry 错误:
org.apache.tapestry5.runtime.ComponentEventException: Render queue error in SetupRender.
location: points to line <t:actionlink t:id="delete" context="${currAdmin.code}" zone="deleteZone">
org.apache.tapestry5.ioc.internal.OperationException
location: point to Grid.tml line <thead t:id="columns"/>
java.lang.NullPointerException
org.apache.tapestry5.internal.beaneditor.BeanModelUtils.add(BeanModelUtils.java:74)
org.apache.tapestry5.internal.beaneditor.BeanModelUtils.modify(BeanModelUtils.java:42)
org.apache.tapestry5.corelib.components.Grid.getDataModel(Grid.java:523)
org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java:112)
org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:181)
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
org.apache.tapestry5.internal.services.PageRenderQueueImpl.renderMarkup(PageRenderQueueImpl.java:142)
org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.renderMarkup(RenderCommandComponentEventResultProcessor.java:78)
org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
org.apache.tapestry5.internal.services.PageRenderQueueImpl.renderPartial(PageRenderQueueImpl.java:159)
org.apache.tapestry5.internal.services.PartialMarkupRendererTerminator.renderMarkup(PartialMarkupRendererTerminator.java:45)
org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:2141)
虽然部分更改网格行效果很好(未包含该代码),但我无法使用网格组件重新加载整个区域。
谁能给我指明方向,完成用户的动态删除操作?
任何帮助将不胜感激!
我发现该代码有几个问题:
网格的add
:
"... is only used when a default model is created automatically."
https://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/Grid.html
但同时您通过 model="adminTableModel"
.
为网格提供自定义模型
ActionLink
上下文中的语法错误:context="${currAdmin.}"
。最后多了一个点(.
)
修复模型初始化问题后,我得到了以下工作代码:
<t:zone t:id="deleteZone" id="deleteZone">
<table t:type="grid" source="adminsSource" rowsPerPage="5" row="currAdmin" inPlace="true" model="adminTableModel" empty="Admins not found" class="t-data-grid table table-bordered">
...
<p:deleteCell>
<t:actionlink t:id="delete" context="currAdmin.code" zone="deleteZone"
${message:delete}
</t:actionlink>
</p:deleteCell>
获取模型:
public BeanModel getAdminTableModel() {
BeanModel<Admin> model;
model = beanModelSource.createDisplayModel(Admin.class, messages);
...
return model;
}
获取来源:
public GridDataSource getAdminsSource() {
return new HibernateGridDataSource(session, Admin.class);
}
因此,按删除键,我得到了网格数据源当前显示页面的更新。希望这会对某人有所帮助)
我正在尝试完成一个简单的任务:从数据库中删除一条记录,更新网格,其中源属性指向用户列表,从数据库下载。我在 tml 中有一个 Grid 组件:
<div t:type="zone" t:id="deleteZone" id="deleteZone">
<table t:type="grid" source="allAdmins" row="currAdmin" empty="blabla" model="adminTableModel"
add="delete,lock">
<p:deleteCell>
<t:actionlink t:id="delete" context="${currAdmin.}" zone="deleteZone">
Delete admin
</t:actionlink> <!--context=""-->
</p:deleteCell>
</table>
</div>
在页面 class 内,我有:
public List<AUser> getAllAdmins() {
return webHelpService.getAllUsers(true);
}
@InjectComponent
private Zone deleteZone;
Object onActionFromDelete(int code) {
Admins adminToChange = dao.getAdmin(code);
if(code!=0) {
dao.deleteAdmin(adminToChange);
}
return deleteZone.getBody();
}
但是当我按下删除按钮时,出现以下 Tapestry 错误:
org.apache.tapestry5.runtime.ComponentEventException: Render queue error in SetupRender.
location: points to line <t:actionlink t:id="delete" context="${currAdmin.code}" zone="deleteZone">
org.apache.tapestry5.ioc.internal.OperationException
location: point to Grid.tml line <thead t:id="columns"/>
java.lang.NullPointerException
org.apache.tapestry5.internal.beaneditor.BeanModelUtils.add(BeanModelUtils.java:74)
org.apache.tapestry5.internal.beaneditor.BeanModelUtils.modify(BeanModelUtils.java:42)
org.apache.tapestry5.corelib.components.Grid.getDataModel(Grid.java:523)
org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java:112)
org.apache.tapestry5.corelib.components.GridColumns.setupRender(GridColumns.java)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.invokeComponent(ComponentPageElementImpl.java:174)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$AbstractPhase.invoke(ComponentPageElementImpl.java:133)
org.apache.tapestry5.internal.structure.ComponentPageElementImpl$SetupRenderPhase.render(ComponentPageElementImpl.java:181)
org.apache.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
org.apache.tapestry5.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:124)
org.apache.tapestry5.internal.services.PageRenderQueueImpl.renderMarkup(PageRenderQueueImpl.java:142)
org.apache.tapestry5.internal.services.RenderCommandComponentEventResultProcessor.renderMarkup(RenderCommandComponentEventResultProcessor.java:78)
org.apache.tapestry5.internal.services.PageRenderQueueImpl$Bridge.renderMarkup(PageRenderQueueImpl.java:62)
org.apache.tapestry5.internal.services.PageRenderQueueImpl.renderPartial(PageRenderQueueImpl.java:159)
org.apache.tapestry5.internal.services.PartialMarkupRendererTerminator.renderMarkup(PartialMarkupRendererTerminator.java:45)
org.apache.tapestry5.services.TapestryModule.renderMarkup(TapestryModule.java:2141)
虽然部分更改网格行效果很好(未包含该代码),但我无法使用网格组件重新加载整个区域。 谁能给我指明方向,完成用户的动态删除操作? 任何帮助将不胜感激!
我发现该代码有几个问题:
网格的
add
:"... is only used when a default model is created automatically." https://tapestry.apache.org/5.4/apidocs/org/apache/tapestry5/corelib/components/Grid.html
但同时您通过
model="adminTableModel"
. 为网格提供自定义模型
ActionLink
上下文中的语法错误:context="${currAdmin.}"
。最后多了一个点(.
)
修复模型初始化问题后,我得到了以下工作代码:
<t:zone t:id="deleteZone" id="deleteZone">
<table t:type="grid" source="adminsSource" rowsPerPage="5" row="currAdmin" inPlace="true" model="adminTableModel" empty="Admins not found" class="t-data-grid table table-bordered">
...
<p:deleteCell>
<t:actionlink t:id="delete" context="currAdmin.code" zone="deleteZone"
${message:delete}
</t:actionlink>
</p:deleteCell>
获取模型:
public BeanModel getAdminTableModel() {
BeanModel<Admin> model;
model = beanModelSource.createDisplayModel(Admin.class, messages);
...
return model;
}
获取来源:
public GridDataSource getAdminsSource() {
return new HibernateGridDataSource(session, Admin.class);
}
因此,按删除键,我得到了网格数据源当前显示页面的更新。希望这会对某人有所帮助)