[英]Is there a method of BreadCrumbBar I can overload to add an extra Component to be refreshed?
I have a wicket page with a data panel that makes use of the BreadCrumbBar
(org.apache.wicket.extensions.breadcrumb). 我有一个带有数据面板的检票口页面,该页面使用了
BreadCrumbBar
(org.apache.wicket.extensions.breadcrumb)。 If I go down a level a new breadcrumb is automatically added and the data panel is refreshed. 如果我降低级别,则会自动添加新的面包屑,并刷新数据面板。 If I click on one of the previous breadcrumbs my data panel gets updated correctly.
如果单击以前的面包屑之一,则数据面板会正确更新。 Now I want to make sure some extra Component on the page (the title) also gets updated.
现在,我要确保页面上的一些额外组件(标题)也得到更新。 This works fine when I control the link myself, but for the breadcrumb links I don't have full control.
当我自己控制链接时,此方法效果很好,但是对于面包屑链接,我没有完全控制权。
Is there a method of BreadCrumbBar
I can overload to add the extra Component to be refreshed? 有没有我可以重载添加要刷新的额外Component的
BreadCrumbBar
的方法? I assume the links in the BreadCrumbBar
are ajax links, but I cannot find an ajax target in the BreadCrumbBar
(or any of the child components). 我假设
BreadCrumbBar
中的链接是ajax链接,但是我在BreadCrumbBar
(或任何子组件)中找不到ajax目标。
By default, BreadCrumbBar
uses BreadCrumbLink
s to render its links, which are usual Link
s (and not AjaxLink
s). 默认情况下,
BreadCrumbBar
使用BreadCrumbLink
呈现其链接,这些链接是通常的Link
(而不是AjaxLink
)。
To get an ajax behavior, you could try to create your own link ( BreadCrumbAjaxLink
) implementation using AjaxLink
as a base and implement in onClick(AjaxRequestTarget)
the same logic that exists in BreadCrumbLink
's onClick()
. 为了获得ajax行为,您可以尝试使用
AjaxLink
作为基础来创建自己的链接( BreadCrumbAjaxLink
)实现,并在onClick(AjaxRequestTarget)
实现与BreadCrumbLink
的onClick()
相同的逻辑。
Then create an analogue of BreadCrumbComponent
(let's call it AjaxBreadCrumbComponent
) using your BreadCrumbAjaxLink
instead of BreadCrumbLink
. 然后使用您的
BreadCrumbAjaxLink
而不是BreadCrumbLink
创建一个BreadCrumbComponent
的类似物(我们称它为AjaxBreadCrumbComponent
)。
And then override BreadCrumbBar
's newBreadCrumbComponent()
method: 然后重写
BreadCrumbBar
的newBreadCrumbComponent()
方法:
protected Component newBreadCrumbComponent(final String id, final long index, final int total,
final IBreadCrumbParticipant breadCrumbParticipant)
{
boolean enableLink = getEnableLinkToCurrent() || (index < (total - 1));
return new AjaxBreadCrumbComponent(id, getSeparatorMarkup(), index, this,
breadCrumbParticipant, enableLink);
}
In BreadCrumbAjaxLink
, you could update whatever additional component you want. 在
BreadCrumbAjaxLink
,您可以更新所需的任何其他组件。 (You would probably need to update the bar itself too). (您可能也需要更新栏本身)。
Since extending several classes seemed a bit overkill for my use case, I tried something different that eventually worked. 由于扩展多个类对于我的用例来说似乎有些过大,所以我尝试了一些最终可行的方法。
By overloading the setActive
method of the BreadCrumbBar
I could set some text to the page title model. 通过重载
BreadCrumbBar
的setActive
方法,我可以为页面标题模型设置一些文本。 That text was then shown on the page. 该文本随后显示在页面上。
I am still not sure how the BreadCrumbBar
handles this. 我仍然不确定
BreadCrumbBar
如何处理此问题。 I think the entire page is refreshed and no ajax call is done. 我认为整个页面都已刷新,并且没有ajax调用完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.