Announcement Announcement Module
Collapse
No announcement yet.
command.new in petForm.jsp and visitForm.jsp in PetClinic Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


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

      Comment


      • #4
        Yes

        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]

        Comment

        Working...
        X