场景:我正在使用带有列的数据表 其中一列是链接。 在运行时我计算创建的链接 问题从以下时间开始: 1. opennig表页面P1 2.我在新标签中点击了链接打开 2.使用此URL创建新标签
mit:8080/backoffice/?4-1.ILinkListener-MainPanelComponentWrapper-MainPanelComponent-table-gridForm-grid-body-rows-3-cells-2-cell-link
是P1上的一个组件,此选项卡生成P2。
我需要创建一个新页面链接到的重定向链接。 我怎么能得到它?
public class LinkPropertyColumn<T extends IEntity> extends BOPropertyColumn<T, String> implements IBOExportableColumn<T, String, Object> {
private static final long serialVersionUID = 1L;
private String headerTilte;
private GridViewType navigateTo;
private String routingByProperty;
private String entityId;
private String navigateToDynamicFunction;
private Map<String, String> filterByMap;
protected BOLinkPanel<T> linkPanel ;
public LinkPropertyColumn(String displayModel, String propertyToSortBy, String propertyExpression, String entityId,
String routingByProperty, String headerTilte, String navigateToDynamic) {
super(Model.of(displayModel), propertyToSortBy, propertyExpression);
this.headerTilte = headerTilte;
this.entityId = entityId;
this.navigateToDynamicFunction = navigateToDynamic;
this.routingByProperty = routingByProperty;
}
@Override
public Component getHeader(String componentId) {
return new Label(componentId, headerTilte);
}
@Override
public void populateItem(Item<ICellPopulator<T>> item, String componentId, final IModel<T> rowModel) {
linkPanel = new BOLinkPanel<T>(componentId, rowModel, getPropertyExpression()) {
private static final long serialVersionUID = 1L;
@Override
void onLinkClicked() {
LinkPropertyColumn.this.onLinkClicked(rowModel);
}
};
item.add(linkPanel);
}
public void onLinkClicked(IModel<T> rowModel) {
doing stuff...
params.add(HomePage.ENTITY_ID, idProperty);
final Object routingProperty = routingByProperty == null ? idProperty : BeanUtils.getProperty(object, routingByProperty);
params.set(HomePage.ROUTING_PROPERTY, routingProperty);
HomePage homePage = new HomePage(params);
final RequestCycle requestCycle = RequestCycle.get();
requestCycle.setResponsePage(homePage);
}
}
}
和:
public abstract class BOLinkPanel<T> extends Panel {
private static final long serialVersionUID = 1L;
/**
* @param id
*/
public BOLinkPanel(String id, IModel<T> model, String propertyExpression) {
super(id);
AbstractLink link = getLink();
link.add(new Label("caption", new PropertyModel<String>(model.getObject(), propertyExpression)));
add(link);
}
protected AbstractLink getLink() {
Link<Void> link = new AjaxFallbackLink<Void>("link") {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
// TODO Auto-generated method stub
BOLinkPanel.this.onLinkClicked();
}
// @Override
// public void onClick() {
// BOLinkPanel.this.onLinkClicked();
//
// }
};
return link;
}
abstract void onLinkClicked();
}
答案 0 :(得分:0)
requestCycle.setResponsePage(HomePage.class, params);