• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

adding hidden values that is a list

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whats the syntax for declaring a hidden field thats a list? And adding to it etc? I want to be able to store some rows when a user saves.

I currently have a screen with a spreadsheet where the user can collapse and expand rows via a plus/minus button. I want the screen to remember after the save which rows where collapsed or expanded and refresh accordingly.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All form elements with the same name will participate in the same request parameter of that name. The array of values can be retrieved from the request within the servlet via request.getParameterValues().
 
steve kelly
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do I implement it...like below?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

steve kelly wrote:how do I implement it...like below?



Does that seem like valid HTML to you? Remember, everything you do at the browser is just HTML. Any JSP-isms are just to iniitally generated the HTML page to send the browser.

As I said, all form elements with the same name become the array of values. So to create an array of "rowID" values:


 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

As for the original question, if you want to have a dropdown list that's hidden, then in your drop down element use
if that's what you want. Otherwise if you want an array follow Bear's post
 
steve kelly
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK I this is what I am doing...

I have this declaring my hidden field on jsp page


When user saves I have this code that iterates through the plus/minus rows and determines if they needed to ba added to a variable "rowID"



later when I want to access this variable the alert below is always undefined. I want to access whats been stored. How do I do this?

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your row variable is declared deep within a function. It will only be available within that function. Declare it at a higher scope.

Though I'm still not exactly sure what you are trying to accomplish. What are you actually trying to collect?
 
steve kelly
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically the rows are collapsing plus/minus nested rows in a spreadsheet form. So I want the ability for user to click save and the screen to remember which lines they had previously expanded or collapsed after the save/submit.

Right now after saving I re-expand all lines and its very inconvient if you have lots of lines. Maybe I am just going about this totoally wrong?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And each row has a unique id, and you want to just send this list of ids to the server? (So that you can use the list to determine which rows are "open" next time the page is viewed?)
 
steve kelly
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:And each row has a unique id, and you want to just send this list of ids to the server? (So that you can use the list to determine which rows are "open" next time the page is viewed?)


what you said in the bold. yes
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you doing this at submit time? If so, how can it be determined if a row is opened or closed?

In any case, to send the info back to the server you can:
  • Create multiple hidden inputs as I detailed in a previous reply. If they all have the same name, the values can be retrieved as an array.
  • "Cheat" and create a single hidden input that contains the list as a comma-separated string that you can parse at the server.

  • The latter involves less logic on the page, and more on the server. The former, just the opposite.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic