Package org.springframework.samples.petclinic

Examples of org.springframework.samples.petclinic.Pet


    setSessionForm(true);
  }

  /** Method creates a new <code>Visit</code> with the correct <code>Pet</code> info */
  protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    Pet pet = getClinic().loadPet(ServletRequestUtils.getRequiredIntParameter(request, "petId"));
    Visit visit = new Visit();
    pet.addVisit(visit);
    return visit;
  }
View Full Code Here


    // get the Pet referred to by id in the request
    return getClinic().loadPet(ServletRequestUtils.getRequiredIntParameter(request, "petId"));
  }

  protected void onBind(HttpServletRequest request, Object command) throws ServletException {
    Pet pet = (Pet) command;
    int typeId = ServletRequestUtils.getRequiredIntParameter(request, "typeId");
    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }
View Full Code Here

    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }

  /** Method updates an existing Pet */
  protected ModelAndView onSubmit(Object command) throws ServletException {
    Pet pet = (Pet) command;
    // delegate the update to the business layer
    getClinic().storePet(pet);
    return new ModelAndView(getSuccessView(), "ownerId", pet.getOwner().getId());
  }
View Full Code Here

    return refData;
  }

  protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    Owner owner = getClinic().loadOwner(ServletRequestUtils.getRequiredIntParameter(request, "ownerId"));
    Pet pet = new Pet();
    owner.addPet(pet);
    return pet;
  }
View Full Code Here

    owner.addPet(pet);
    return pet;
  }

  protected void onBind(HttpServletRequest request, Object command) {
    Pet pet = (Pet) command;
    int typeId = Integer.parseInt(request.getParameter("typeId"));
    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }
View Full Code Here

    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }

  /** Method inserts a new Pet */
  protected ModelAndView onSubmit(Object command) throws ServletException {
    Pet pet = (Pet) command;
    // delegate the insert to the Business layer
    getClinic().storePet(pet);
    return new ModelAndView(getSuccessView(), "ownerId", pet.getOwner().getId());
  }
View Full Code Here

        }
    }

    private class RenamePetExecutor extends AbstractActionCommandExecutor {
        public void execute() {
            final Pet pet = getSelectedPet();
            InputApplicationDialog renameDialog = new InputApplicationDialog(pet, "name");
            renameDialog.setTitle(getMessage("renamePetDialog.title"));
            renameDialog.setInputLabelMessage("renamePetDialog.label");
            renameDialog.setParentComponent(getWindowControl());
            renameDialog.setFinishAction(new Block() {
View Full Code Here

     * @see CloseAction
     */
    private class PetPropertiesExecutor extends AbstractActionCommandExecutor {

        public void execute() {
            final Pet pet = getSelectedPet();
            final PetForm petForm = new PetForm(FormModelHelper.createFormModel(pet), false);
            final FormBackedDialogPage dialogPage = new FormBackedDialogPage(petForm);

            TitledPageApplicationDialog dialog = new TitledPageApplicationDialog(dialogPage, getWindowControl(), CloseAction.DISPOSE) {
                protected void onAboutToShow() {
View Full Code Here

        /**
         * Create the dialog with {@link CloseAction#HIDE}. This will keep the dialog hidden in order
         * to reuse the component. This avoids the time-consuming building of the dialog gui each time.
         */
        private void createDialog() {
            petForm = new PetForm(FormModelHelper.createFormModel(new Pet()), true);
            dialogPage = new FormBackedDialogPage(petForm);

            dialog = new TitledPageApplicationDialog(dialogPage, getWindowControl(), CloseAction.HIDE) {
                protected void onAboutToShow() {
                    petForm.requestFocusInWindow();
                    setEnabled(dialogPage.isPageComplete());
                }

                protected boolean onFinish() {
                    petForm.commit();
                    Pet newPet = (Pet)petForm.getFormObject();
                    getSelectedOwner().addPet(newPet);
                    clinic.storePet(newPet);
                    DefaultMutableTreeNode ownerNode = getSelectedOwnerNode();
                    ownerNode.add(new DefaultMutableTreeNode(newPet));
                    ownersTreeModel.nodeStructureChanged(ownerNode);
View Full Code Here

         */
        protected void doExecuteCommand() {
            if (dialog == null)
                createDialog();

            petForm.setFormObject(new Pet());
            dialog.showDialog();
        }
View Full Code Here

TOP

Related Classes of org.springframework.samples.petclinic.Pet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.