• 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

Struts variables from JSP

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am most likely being a total knob but I have searched high and low and I can't find what I'm doing wrong.

simple form - load values from Action. Edit and Submit values back to update action.
i have a simple Array List menuItems ...
i'm displaying results in table - with edit /delete

what i'm trying to figure out is how to pass the edited value back to the editMenu action -- all i'm getting right now is the original value.
The menuId (which is not editable) - returns correctly.

I'm sorry to any purists out there, i've tried so many different things I've found on google, the code snippet below might be really really bad



tx

Clarissah.
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the JavaRanch

what i'm trying to figure out is how to pass the edited value back to the editMenu action



The usual strategy is to have the menu stored in some sort of persistent storage, like a database, flat file, serialized object, etc. The editMenu (this is actually a display/list items/configure, not an edit, right?) action would read this storage every time it is executed and display it. When you perform an edit, the edit action would read the detailed information from the storage. When one commits any updates, the action called would update the storage and forward to the editMenu action, which would read the storage and display the updated version.
 
Clarissah Logan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:Welcome to the JavaRanch

what i'm trying to figure out is how to pass the edited value back to the editMenu action



The usual strategy is to have the menu stored in some sort of persistent storage, like a database, flat file, serialized object, etc. The editMenu (this is actually a display/list items/configure, not an edit, right?) action would read this storage every time it is executed and display it. When you perform an edit, the edit action would read the detailed information from the storage. When one commits any updates, the action called would update the storage and forward to the editMenu action, which would read the storage and display the updated version.



Thanks Joe. Yeah it is a Crud.
I have the read and add parts working. But In logic terms - not code (trying to understand my error)
1. Have an array list with bean containing ID and name.
2. In jsp - iterate and display.
3. Create edit/delete functions per item. Allow user to change menu name.
4. Submit action. The value of menuName returned to action is pre- changed value.


I'm using 1 action to create list.another action to do edits.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Clarissah Logan wrote:1. Have an array list with bean containing ID and name.



If you have the add part working, you must be updating this array list somehow. What is the difference between the add and the edit?
 
Clarissah Logan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joe Ess wrote:

If you have the add part working, you must be updating this array list somehow. What is the difference between the add and the edit?



the add has it's own jsp and a form with action



while my edit is doing it from a iterated list like this


if the value pass to display in the form initially is from another action class that returns an arraylist of my menuItemBeans ... and i edit a value - do I need to do anything explicitly to have that value updated before it get sent back to the action to save the changes?


 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Clarissah Logan wrote: do I need to do anything explicitly to have that value updated before it get sent back to the action to save the changes?



I would assume so. Otherwise how would the editMenu action know about the change? It really depends on how your code is written and you haven't shared nearly enough information with us.
 
Clarissah Logan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey sorry for not following up. For now we've used a work around which I KNOW is the wrong way of doing things, we have set two variables, one storing the old value and one the changed value.

I'm gonna spend some time hitting the books, true someone pointed out I'm trying to learn from bits and pieces on the web. I need to follow a succinct linear learning module in order to understand what I'm doing rather than just rote coding.
Tx.
 
I'm still in control here. LOOK at this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic