Results 1 to 10 of 10
  1. #1
    a.premkumar is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Please help me to solve the problem with returning list to .vm page

    Hi, Im new to Apache velocity. Im trying to display a two lists in a .vm file. is that possible?
    (Both lists are returned from the Controller class at different time of execution). Please help me to solve this issue.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Please help me to solve the problem with returning list to .vm page

    Not too sure what you're meaning.
    Any example?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    a.premkumar is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Here is the example

    I cant post the actual code but i have given you a similar code for example here.



    form.vm

    <form>
    <table>
    #foreach($care in $carelist)
    <tr>
    <td>$care.firstname</td><td>$care.lastname</td>
    </tr>
    <tr>
    <td><input type="button" value="Add"/></td><td><input type="button" value="Edit"/></td>
    </tr>
    #end
    </table>
    </form>

    ##this part is not working

    <form>
    <table>
    #foreach($c in $clist)
    <tr>
    <td><input type="text" value=$c.firstname /></td>
    </tr>
    <tr>
    <td><input type="text" value=$c.lastname/></td>
    </tr>
    #end
    </table>
    </form>

    Actually this page has to be returned twice by the controller. At first, the upper part of the velocity tags works fine. The lower form has to be loaded in a modal separately when the 'Edit' button is clicked. There begins the problem. The values from the controller returned list is not assigned to the text boxes.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Please help me to solve the problem with returning list to .vm page

    Presumably those Edit buttons are associated with the row they're in on the table, so why does the second template have the entire table again, rather than the specific row?

    How is the first form replaced by the second in your code?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    a.premkumar is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re:

    Quote Originally Posted by Tolls View Post
    Presumably those Edit buttons are associated with the row they're in on the table, so why does the second template have the entire table again, rather than the specific row?

    How is the first form replaced by the second in your code?
    Actually the first code is displayed normally, but the second form is displayed in a modal box.

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Please help me to solve the problem with returning list to .vm page

    But the second one is only used when the user clicks on an Edit button?

    What do you want returned by each pass through the controller?
    Presumably the first pass supplies the initial table, and the second pass (on Edit?) will return the second?
    If so then that implies two templates.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  7. #7
    a.premkumar is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re:

    Quote Originally Posted by Tolls View Post
    But the second one is only used when the user clicks on an Edit button?

    What do you want returned by each pass through the controller?
    Presumably the first pass supplies the initial table, and the second pass (on Edit?) will return the second?
    If so then that implies two templates.
    First table is to display the list and second is to edit these details.. The second form displays in modal. Yeah it implies two template but if i make it as two different file, will it work?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Please help me to solve the problem with returning list to .vm page

    You'll at least narrow down where it's failing.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    a.premkumar is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re: Please help me to solve the problem with returning list to .vm page

    Quote Originally Posted by Tolls View Post
    You'll at least narrow down where it's failing.
    '#foreach($c in $clist)'
    this is the line that fails to execute the way it should be.

  10. #10
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default Re: Please help me to solve the problem with returning list to .vm page

    What are you passing into velocity for the clist?
    What does "fail" mean as well?
    Errors?
    Incorrect output?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Display data from list on same jsp page
    By reubenmk in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-13-2012, 11:12 AM
  2. cant solve my problem .needs some help(C++):(y):
    By seongchog in forum New To Java
    Replies: 2
    Last Post: 12-03-2011, 08:49 PM
  3. populating a list box based on another without refreshing the page
    By zahir in forum JavaServer Pages (JSP) and JSTL
    Replies: 8
    Last Post: 07-25-2011, 01:09 PM
  4. Recursive File List - Help me problem solve please
    By caps_lock in forum New To Java
    Replies: 17
    Last Post: 01-14-2009, 06:44 PM
  5. Why is my list returning nothing?
    By xcallmejudasx in forum New To Java
    Replies: 2
    Last Post: 11-05-2008, 03:51 PM

Tags for this Thread

Posting Permissions

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