모달 자바 스크립트 확인 상자가 있습니다. 버튼 클릭, 즉 취소 버튼 또는 확인 버튼에 따라 상위 페이지의 일부 구성 요소를 새로 고침하고 싶습니다. 그러나 불행히도 그것은 작동하지 않습니다. 코드에서 볼 수 있듯이 두 개의 텍스트 필드에 값을 ""설정하고 패널을 숨기고 드롭 다운의 선택된 옵션을 0으로 설정하려고합니다. 이것은 일어나지 않고 있으며, 구성 요소는 해제되지 않은 상태로 남아 있습니다.모달 창에서 상위 페이지의 구성 요소 새로 고침
public class ModalConfirmWindow extends WebPage {
private ModalWindow modalConfirmWindow;
private UserAssignmentInfoPanel userAssignmentInfoPanel;
private DropDownChoice choice;
private TextField scheduledTimeField;
private DateTextField deadLineField;
private int numberOfConflictingDays;
public ModalConfirmWindow(ModalWindow modalConfirmWindow, UserAssignmentInfoPanel userAssignmentInfoPanel, DropDownChoice choice, TextField scheduledTimeField, DateTextField deadLineField, int numberOfConflictingDays) {
this.modalConfirmWindow = modalConfirmWindow;
this.userAssignmentInfoPanel = userAssignmentInfoPanel;
this.choice = choice;
this.scheduledTimeField = scheduledTimeField;
this.deadLineField = deadLineField;
this.numberOfConflictingDays = numberOfConflictingDays;
add(new ModalConfirmWindowForm("form"));
}
private class ModalConfirmWindowForm extends Form {
private static final long serialVersionUID = 10090L;
public ModalConfirmWindowForm(String id) {
super(id);
add(new Label("value", " " + numberOfConflictingDays +" ").add(new SimpleAttributeModifier("style", "color: red")));
add(new AjaxButton("cancelButton", this) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
// I am trying to refresh the component here
String javaScript = "document.getElementById('"+ userAssignmentInfoPanel.getMarkupId() +"').display = 'none';" +
"document.getElementById('"+ choice.getMarkupId() +"').options[0].selected = 'selected';" +
"document.getElementById('"+ scheduledTimeField.getMarkupId() +"').value = \"\";" +
"document.getElementById('"+ deadLineField.getMarkupId() +"').value = \"\";";
//target.appendJavascript(javaScript);
//scheduledTimeField.add(new SimpleAttributeModifier("value", ""));
//target.addComponent(scheduledTimeField);
//modalConfirmWindow.close(target);
modalConfirmWindow.close(target);
target.appendJavascript(javaScript);
}
});
add(new AjaxButton("okButton", this) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
modalConfirmWindow.close(target);
}
});
}
}
}
어떻게하면됩니까?
"작동하지 않음"으로 확장 할 수 있습니까? – jzd
@jzd 자세한 내용은 해당 게시물을 편집했습니다. 덕분에 –