替代的ListView表格單元格我有一個具有它只需要在某些情況下可編輯單個列列表視圖。如果用戶需要更改列,我希望他們單擊該行的編輯按鈕,然後用textField替換單元格中的標籤。當我調用替換時,我可以看到TextField現在已經在標籤的位置,儘管它永遠不會呈現。我有一個AjaxLink來處理事件。我正在使用容器重新繪製listView。這裏是我的列表視圖:動態框文本檢票
parent = new WebMarkupContainer("emp-table-parent");
parent.add(new AjaxLink<Object>(FIRST_NAME_HEADER_LINK) {
/**
*
*/
private static final long serialVersionUID = -1937727929649333407L;
@Override
public void onClick(AjaxRequestTarget target) {
changeGlyphUpdateList(target, parent.get(FIRST_NAME_HEADER_LINK).get(FIRST_NAME_HEADER_ICON),
parent.get(LAST_NAME_HEADER_LINK).get(LAST_NAME_HEADER_ICON),
parent.get(EMAIL_HEADER_LINK).get(EMAIL_HEADER_ICON), parent.get(ELIGIBILITY_CLASS_HEADER_LINK).get(ELIGIBILITY_CLASS_HEADER_ICON),
parent.get(EMPLOYER_HEADER_LINK).get(EMPLOYER_HEADER_ICON));
}
}.add(new Label("first-name-header-label", Model.of("First Name")), new WebComponent(FIRST_NAME_HEADER_ICON)),
new AjaxLink<Object>(LAST_NAME_HEADER_LINK) {
/**
*
*/
private static final long serialVersionUID = -3438649095509412910L;
@Override
public void onClick(AjaxRequestTarget target) {
changeGlyphUpdateList(target, parent.get(LAST_NAME_HEADER_LINK).get(LAST_NAME_HEADER_ICON),
parent.get(FIRST_NAME_HEADER_LINK).get(FIRST_NAME_HEADER_ICON),
parent.get(EMAIL_HEADER_LINK).get(EMAIL_HEADER_ICON),
parent.get(ELIGIBILITY_CLASS_HEADER_LINK).get(ELIGIBILITY_CLASS_HEADER_ICON),
parent.get(EMPLOYER_HEADER_LINK).get(EMPLOYER_HEADER_ICON));
}
}.add(new Label("last-name-header-label", Model.of("Last Name")), new WebComponent(LAST_NAME_HEADER_ICON)),
new AjaxLink<Object>(EMAIL_HEADER_LINK) {
/**
*
*/
private static final long serialVersionUID = 2890934302751793454L;
@Override
public void onClick(AjaxRequestTarget target) {
changeGlyphUpdateList(target, parent.get(EMAIL_HEADER_LINK).get(EMAIL_HEADER_ICON),
parent.get(LAST_NAME_HEADER_LINK).get(LAST_NAME_HEADER_ICON),
parent.get(FIRST_NAME_HEADER_LINK).get(FIRST_NAME_HEADER_ICON),
parent.get(ELIGIBILITY_CLASS_HEADER_LINK).get(ELIGIBILITY_CLASS_HEADER_ICON),
parent.get(EMPLOYER_HEADER_LINK).get(EMPLOYER_HEADER_ICON));
}
}.add(new Label("email-header-label", Model.of("Email")), new WebComponent(EMAIL_HEADER_ICON)),
new AjaxLink<Object>(ELIGIBILITY_CLASS_HEADER_LINK) {
/**
*
*/
private static final long serialVersionUID = -4022209586109961448L;
@Override
public void onClick(AjaxRequestTarget target) {
changeGlyphUpdateList(target, parent.get(ELIGIBILITY_CLASS_HEADER_LINK).get(ELIGIBILITY_CLASS_HEADER_ICON),
parent.get(EMAIL_HEADER_LINK).get(EMAIL_HEADER_ICON),
parent.get(LAST_NAME_HEADER_LINK).get(LAST_NAME_HEADER_ICON),
parent.get(FIRST_NAME_HEADER_LINK).get(FIRST_NAME_HEADER_ICON),
parent.get(EMPLOYER_HEADER_LINK).get(EMPLOYER_HEADER_ICON));
}
}.add(new Label("eligibility-class-header-label", Model.of("Elig. Class")), new WebComponent(ELIGIBILITY_CLASS_HEADER_ICON)),
new AjaxLink<Object>(EMPLOYER_HEADER_LINK) {
/**
*
*/
private static final long serialVersionUID = -738777257301408437L;
@Override
public void onClick(AjaxRequestTarget target) {
changeGlyphUpdateList(target, parent.get(EMPLOYER_HEADER_LINK).get(EMPLOYER_HEADER_ICON),
parent.get(ELIGIBILITY_CLASS_HEADER_LINK).get(ELIGIBILITY_CLASS_HEADER_ICON),
parent.get(EMAIL_HEADER_LINK).get(EMAIL_HEADER_ICON),
parent.get(LAST_NAME_HEADER_LINK).get(LAST_NAME_HEADER_ICON),
parent.get(FIRST_NAME_HEADER_LINK).get(FIRST_NAME_HEADER_ICON));
}
}.add(new Label("employer-header-label", Model.of("Employer")), new WebComponent(EMPLOYER_HEADER_ICON)),
new PageableListView<EmployeeSummaryPkt>("data", employeeSummaryModel.getObject(), 25) {
/**
*
*/
private static final long serialVersionUID = -1697070076764699904L;
@Override
protected void populateItem(final ListItem<EmployeeSummaryPkt> item) {
item.setDefaultModel(new CompoundPropertyModel<EmployeeSummaryPkt>(item.getModelObject()));
item.add(new Label("firstName"),
new Label("lastName"),
new Label("employeeEmail"),
new Link<Object>("eligibility-class-data-link") {
/**
*
*/
private static final long serialVersionUID = -3842291392813313171L;
@Override
public void onClick() {
//LINK TO ELIGIBILITY CLASS OR MAYBE THE SECTION WITHIN THE EMP?
}
}.add(new Label("employeeEligibilityClassSummaryPkt.name")),
new Link<Object>("employer-data-link") {
/**
*
*/
private static final long serialVersionUID = 6809571267919974106L;
@Override
public void onClick() {
getIndex().getHomePanel().setNewContent(new EmployerDetailPanel("panel-content", item.getModelObject().getEmployerSummaryPkt().getId()));
}
}.add(new Label("employerSummaryPkt.name")),
new Label("employeeDateOfBirth"),
new Label("employee-code", Model.of(item.getModelObject().getEmployeeName())).setOutputMarkupId(true),
new AjaxLink<Object>("edit-employee-link") {
/**
*
*/
private static final long serialVersionUID = 6061544430700059358L;
@Override
public void onClick(AjaxRequestTarget target) {
logr.log(Level.FINER, "onClick for edit employee");
logr.log(Level.FINER, "employee code pre: " + item.get("employee-code").getClass().getSimpleName());
item.get("employee-code").replaceWith(new TextField<String>("employee-code", new Model<String>(item.getModelObject().getEmployeeName())).setOutputMarkupId(true));
logr.log(Level.FINER, "employee code post: " + item.get("employee-code").getClass().getSimpleName());
target.addChildren(parent, TextField.class);
target.add(parent);
}
});
}
正如你可以看到,id爲「員工代碼」的標籤是我想要替換的標籤。在AjaxLink onClick中,您可以看到我獲取標籤的位置並將其替換。沒有什麼改變。任何方向或幫助非常感謝。
的聲明'parent'似乎並沒有在代碼片段你貼? – WiseTree
對不起。我編輯上面添加父代的片段。 – SteveManC