Announcement Announcement Module
No announcement yet.
add more parameters into a form page Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • add more parameters into a form page


    In the jsp page that display list of books, I have:

    <form action="<c:url value="book.html"/>">
    <input type="hidden" name="id" value="<c:out value="${book.bookId}"/>" /><input type="submit" name="edit" value="Edit" /></form>

    When I click edit button for a book (with Id =1), I have this in URL:


    This page will show the details of the book. As the book may have one or more comments and I need to update, delete any of these comments. To edit a comment with Id =2, I need to have one more parameter for it, example it is commentId = 2.

    I tried:

    <c:url var="editComment" value="book.html"> <!-- I need to display the edit comment in the same book detail page -->
    <caram name="commentId" value="2"/>
    <a href="<c:out value="${editComment}"/>">edit Comment</a>

    My URL now is http://localhost:8080/book/book.html?commentId=2

    But I NEED to have this in URL:


    Could you please tell me how to do this. I use a simpleFormController as all of actions happend on only one form.

    Many thanks

  • #2
    Why not use a form with hidden fields? There is no reason the form cannot use a get instead of a post (action="get").

    If you want to use c:url you can still do:
      <c:url var="editComment" value="book.html?commentId=2"/>
    I think, although I don't use c:url very much.


    • #3
      -If you want to use c:url you can still do:

      -<c:url var="editComment" value="book.html?commentId=2"/>

      I cannot use this as I will lost the book Id and edit parameter in (http://localhost:8080/book/book.html?id=1&edit=Edit)

      In the jsp page, I have book details and some comments in a table( with people names and their comments). I need to update book details and update, add comments. So I cannot use forms for comments as I cannot use forms (for update or add more comments) inside a form (for update book details).

      There is any better way to do this.
      Thank you


      • #4
        I see.

        Is there any reason you cannot have each section it's own form and submit to different controllers which all have the same successView?

        i.e. Image a page which looks like:

            |   Book name: Expert Spring MVC         |
            |                    and Web Flow               |
            |                                                      |
            |            Delete  Edit Add Comment       |
            |                                                      |
            |                                                      |
            |   Comment 1: this is a really good book |
            |                               Delete  Edit       |
            |                                                      |
            |   Comment 2: it really is!                    |
            |                               Delete  Edit       |
        (excuse the formatting horror )

        you could have a form wrapping the book section, and then a form wrapping each comment section. The book form might submit to /books/edit.htm or /books/delete.htm etc.

        Would that work for you?


        • #5

          Thanks Yatesco

          At the moment I use ONLY one FormSimpleController for the edit book page. I use functions isFormChangeRequest and onFormChange to update comments. That is why I want to use <a href tag for update/add Comments AND I use "onSubmit" for update Book details (after update/add comment, user then update whole book.)
          Do you have any idea about this. I will try your solution.
          Last edited by shoa; May 2nd, 2006, 05:07 AM.


          • #6
            Well, I would question the benefit of that over the benefit of having seperate controllers.... whenever I see a class with "if this then" in lots of methods it seems to smell of one class coping with two instances; which is exactly what (I think) your single formController is doing


            • #7
              You are right, I have many if-then. it is not good

              >you could have a form wrapping the book section, and then a form wrapping each comment section

              However, using your method, I really donot know how many controllers (or what kind of controller) I should use as one book may have many comments


              • #8
                I would have one controller for managing the book and one controller for managing the certainly don't want one controller per comment if that is what you were implying


                • #9
                  Lets close this one and continue in