Results 1 to 4 of 4

Thread: command.new in petForm.jsp and visitForm.jsp in PetClinic

  1. #1
    Join Date
    May 2005
    Posts
    11

    Default command.new in petForm.jsp and visitForm.jsp in PetClinic

    are the command.newS bound to Pet#isNew() and Visit#isNew() in AddPetForm.java and AddVisitForm.java controller with formBackingObject?

    Code:
    	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    		Pet pet = getClinic().loadPet(RequestUtils.getRequiredIntParameter(request, "petId"));
    		Visit visit = new Visit();
    		pet.addVisit(visit);
    		return visit;
    	}
    and

    Code:
    	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    		Owner owner = getClinic().loadOwner(RequestUtils.getRequiredIntParameter(request, "ownerId"));
    		Pet pet = new Pet();
    		owner.addPet(pet);
    		return pet;
    	}
    usually command.new should be resolved into to Command#getNew, how is it resolved to Command#isNew and from which version JSTL or is it done through Spring?

    thanks.

  2. #2
    Join Date
    Sep 2004
    Location
    Tokyo, Japan
    Posts
    22

    Default

    are the command.newS bound to Pet#isNew() and Visit#isNew() in AddPetForm.java and AddVisitForm.java controller with formBackingObject?
    The answar is no. Pet and Visit Objects are extended from Entity and in Entity you will find isNew() method.

  3. #3
    Join Date
    May 2005
    Posts
    11

    Default

    thanks. but are the command objects created with formBackingObject in both AddPetForm.java and AddVisitForm.java?

  4. #4

    Default Yes

    Quote Originally Posted by philip
    thanks. but are the command objects created with formBackingObject in both AddPetForm.java and AddVisitForm.java?
    Yes there are created within the formBackingObject() but in the EditPetForm.java there are retrieved from the DB because they should already exist(since u r editing).

    I think the main reason isNew() is used is so that a single jsp page can be used for both adding a new entity and editing an existing entity. I think if you decided to use a different page each for adding and editing then there would be no need for defining the isNew() method in your entities/domain objects.

    HTH.[/b]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •