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

  • add more parameters into a form page

    Hello

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

    <td>
    <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>
    </td>

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

    http://localhost:8080/book/book.html?id=1&edit=Edit

    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:

    <td>
    <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"/>
    </c:url>
    <a href="<c:out value="${editComment}"/>">edit Comment</a>
    </td>

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

    But I NEED to have this in URL:

    http://localhost:8080/book/book.html...it&commentId=2

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

    Many thanks
    shoa

  • #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:
    Code:
      <c:url var="editComment" value="book.html?commentId=2"/>
    I think, although I don't use c:url very much.

    Comment


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

      -<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
      sho

      Comment


      • #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:

        Code:
             ---------------------------------------
            |   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?

        Comment


        • #5
          Thanks

          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.
          Regards
          Last edited by shoa; May 2nd, 2006, 05:07 AM.

          Comment


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

            Comment


            • #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
              Thanks

              Comment


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

                Comment


                • #9
                  Lets close this one and continue in http://forum.springframework.org/showthread.php?t=24506

                  Comment

                  Working...
                  X