Announcement Announcement Module
Collapse
No announcement yet.
add/edit/delete obj in the same JSP page. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • add/edit/delete obj in the same JSP page.

    Hi all,

    I would like to implement a page in JSP where I have a list of objects that would allow me to add/delete/edit. I managed already to deal with edit & delete. The thing that is still blurry is how to deal with obj creation.

    In the jsp page, I use the form: tag with the path of the obj that I am currently working with. If the object is new, then I would not have that path available [i.e. when the page is rendered there is no specific HTML to deal with it and I guess that the HTML fields should be added at 'runtime' by JS]

    How would be possible to implement the ADD obj in the same JSP page? It would be really handy for user usability to have all function [add/delete/edit] in one place. I am thinking to use also DWR when adding one objet but that would be quite tricky as well. Would it then be picked out on POSTing the page in the controller ?

    I believe that there should be a simpler solution. Anyone ever face something similar ?

  • #2
    Originally posted by dawez View Post
    Hi all,

    I would like to implement a page in JSP where I have a list of objects that would allow me to add/delete/edit. I managed already to deal with edit & delete. The thing that is still blurry is how to deal with obj creation.

    In the jsp page, I use the form: tag with the path of the obj that I am currently working with. If the object is new, then I would not have that path available [i.e. when the page is rendered there is no specific HTML to deal with it and I guess that the HTML fields should be added at 'runtime' by JS]

    How would be possible to implement the ADD obj in the same JSP page? It would be really handy for user usability to have all function [add/delete/edit] in one place. I am thinking to use also DWR when adding one objet but that would be quite tricky as well. Would it then be picked out on POSTing the page in the controller ?

    I believe that there should be a simpler solution. Anyone ever face something similar ?
    did you have to create multiple entries, or just one at a time with one click?

    Comment


    • #3
      Hey traceon,

      The plan is to add more entries at once.

      Comment


      • #4
        i had a smiliar problem and solved it like this (pls don't blame me for the not 100% perfect code. i just typed it freestyle

        My View
        Code:
          ...
        <form:form action="create.htm" commandName="createForm">
        
           <form:input path="forenames"/>
           <form:input path="surnames"/>
        
        ..
        My Form
        Code:
        public class MyForm (){
           public List<String> forenames;
           public List<String> surnames;
        
           //Getter, setter
           ....
           //Retrieve person from input field
           public List<Person> getPersons(){
              List<Person> persons = new ArrayList<Person>();
            
              //I expect that the size of forenames && surenames is always equal. this might not be the best solution.
              for(int i = 0; i < forenames.size; i++){
                     Person person = new Person();
                     person.setForename(getFornames().get(i));         
                     person.setSurename(getSurenames().get(i));        
                     persons.add(person);
                }
        
               return person;        
           }      
          
        }
        My Controller
        Code:
        @Controller
        public class MyController(){
        
          @RequestMapping(value = "/create.htm")
          public ModelAndView create(MForm myForm){
                List<Person> person = myForm.getPersons();
                 
                //Persist...          
          }
        
        }

        Comment

        Working...
        X