Exemplo n.º 1
0
  public AdminPatientPage(PageParameters parameters) {
    super();

    final Patient patient;
    final PatientUser patientUser;

    StringValue idValue = parameters.get(PARAM_ID);
    patientUser = userManager.getPatientUser(idValue.toLong());
    patient = patientManager.getPatientByRadarNumber(patientUser.getRadarNumber());

    CompoundPropertyModel<PatientUser> patientUserModel =
        new CompoundPropertyModel<PatientUser>(patientUser);

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    feedback.setOutputMarkupPlaceholderTag(true);
    add(feedback);

    final Form<PatientUser> userForm =
        new Form<PatientUser>("patientForm", patientUserModel) {
          protected void onSubmit() {
            try {
              userManager.savePatientUser(getModelObject());
            } catch (Exception e) {
              error("Could not save patient: " + e.toString());
            }
          }
        };
    add(userForm);

    userForm.add(new Label("radarNo", patientUser.getRadarNumber().toString()));
    userForm.add(new Label("forename", patient.getForename()));
    userForm.add(new Label("surname", patient.getSurname()));
    userForm.add(new RequiredTextField("username"));
    userForm.add(new Label("dob", patientUser.getDateOfBirth().toString()));
    userForm.add(new Label("dateRegistered", patientUser.getDateRegistered().toString()));

    userForm.add(
        new AjaxSubmitLink("updateTop") {
          protected void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            setResponsePage(AdminPatientsPage.class);
          }

          protected void onError(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            ajaxRequestTarget.add(feedback);
          }
        });

    userForm.add(
        new AjaxLink("cancelTop") {
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            setResponsePage(AdminPatientsPage.class);
          }
        });

    userForm.add(
        new AjaxSubmitLink("updateBottom") {
          protected void onSubmit(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            setResponsePage(AdminPatientsPage.class);
          }

          protected void onError(AjaxRequestTarget ajaxRequestTarget, Form<?> form) {
            ajaxRequestTarget.add(feedback);
          }
        });

    userForm.add(
        new AjaxLink("cancelBottom") {
          public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            setResponsePage(AdminPatientsPage.class);
          }
        });
  }
Exemplo n.º 2
0
 public static PageParameters getPageParameters(PatientUser patientUser) {
   return new PageParameters().set(PARAM_ID, patientUser.getId());
 }