Results 1 to 5 of 5
  1. #1
    Emertana is offline Member
    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0

    Default how to send value of a list to a hidden tag?

    I have the following code in my jsp:

    Java Code:
    <c:forEach var="value" items="${MyList}" varStatus="loop">
    
             <tr><td><div id="Name1">Here:${value.name}</div></td></tr>
             <s:hidden id="Name" name="Name" value="%{value.name}"/>
    the html source is as following:

    Java Code:
       <tr><td><div id="Name1">Here:My name is X</div></td></tr>
             <input type="hidden" name="Name" value="" id="Name"/>
    As demonstrated the div tag is showing the value.name correctly but the value attribute of hidden tag is empty. I could not find any solution because most of the solutions were not related to list.
    I changed it to ${value.name} but ran into this error: "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default Re: how to send value of a list to a hidden tag?

    You're mixing the jsp tags with struts tags.
    Struts has its own iterator tag, so I would suggest using that.
    That's the first thing.

    Second, the name part of your hidden field has to map to something in the action, otherwise struts does not know where to pull the value from.
    You don't generally set the value field (unless you need a default).
    So your name would be "MyList[%{#loop.index}]", or something along those lines.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Emertana is offline Member
    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0

    Default Re: how to send value of a list to a hidden tag?

    I do not get you, what do you mean by "MyList[%{#loop.index}]", or something along those lines. would you give me a sample code?

  4. #4
    Emertana is offline Member
    Join Date
    Oct 2012
    Posts
    6
    Rep Power
    0

    Default Re: how to send value of a list to a hidden tag?

    Quote Originally Posted by Tolls View Post
    You're mixing the jsp tags with struts tags.
    Struts has its own iterator tag, so I would suggest using that.
    That's the first thing.

    Second, the name part of your hidden field has to map to something in the action, otherwise struts does not know where to pull the value from.
    You don't generally set the value field (unless you need a default).
    So your name would be "MyList[%{#loop.index}]", or something along those lines.
    I do not get you, what do you mean by "MyList[%{#loop.index}]", or something along those lines. would you give me a sample code?

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default Re: how to send value of a list to a hidden tag?

    In other words, use Struts the way it was intended.
    The whole point behind struts is that the name field of the various input tags references an actual attribute on the action invoked.
    So your hidden field names need to reference something, which I presumed was MyList[<index>].
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Passwords not hidden
    By kkid in forum Suggestions & Feedback
    Replies: 6
    Last Post: 11-13-2012, 02:21 PM
  2. Hidden JText Field
    By jo15765 in forum New To Java
    Replies: 5
    Last Post: 05-29-2012, 04:18 AM
  3. How to send a list as a input for a oracle procedure
    By anilkumar_vist in forum Advanced Java
    Replies: 4
    Last Post: 11-24-2010, 08:51 AM
  4. Replies: 10
    Last Post: 06-06-2010, 06:49 PM
  5. Hidden Button after paint()
    By MuslimCoder in forum New To Java
    Replies: 5
    Last Post: 09-14-2009, 05:52 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
  •