• 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 1 form

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

I'll try to explain my issue.

I have a link in my application like this: <a href="editaPaciente.do?paciente.id=${itemAtual.id}"> .

When the users clicks this link, my editaPacienteAction does a search on my database, and sets the Paciente that it finds on the form, by using this code:

Then my ActionForm sets the fields from the page that comes next with the values of the paciente that was found in the action.

So, once the fields are populated, I want to be able to edit them, put new values and then redirect this form to yet another Action which will update the database by using
the new values on the form.

However, my actionForm only fills the html form fields if I make it like this: <html:form action="/editaPaciente">

I wanted to be able to put something like this: <html:form action="/efetuaEdicaoPaciente">

So when the user first clicks the <a href="editaPaciente.do?paciente.id=${itemAtual.id}"> link, he gets a page that is filled with the old values from the database, but when he clicks submit, the efetuaEdicaoPacienteAction updates the database with the new values.

Any suggestions, please?
 
Rodrigo Bossini
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe I was not clear enough..
I have a page with a list of clients, and below each client there's a link to a updateClient action.

Once clicked, this link invokes the updateClientAction, which has an ActionForm associated to it, which populates the form fields for me.
Once in this page, I want to be able to edit some (or maybe all of them) of the fields, and click a submit button, which should invoke yet another
action, which should access the database and update the client according to the changes on the form..
However, in this page, I MUST set the action form as the previus action (not the one that will access the DB), otherwise the fields will not come populated with the bean values...If it's not clear enough, please let me know.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the action mapping for path "/efetuaEdicaoPaciente", please post that from struts-config xml and make sure that both action has same form name .
 
Rodrigo Bossini
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:What is the action mapping for path "/efetuaEdicaoPaciente", please post that from struts-config xml and make sure that both action has same form name .



Thank you.

I read somewhere that for some reason it would be advisable to NOT have the same form for two different actions. However, now I see that this depends on what you are doing, and that the solution for my issue is indeed using the same form for the 2 actions. Thanks again.

 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rodrigo Bossini wrote:

Sagar Rohankar wrote:What is the action mapping for path "/efetuaEdicaoPaciente", please post that from struts-config xml and make sure that both action has same form name .


I read somewhere that for some reason it would be advisable to NOT have the same form for two different actions.


Depends upon the scope you're declaring your FROM, in session scope it may leads to some problems if the same form is used by another Action.
 
Rodrigo Bossini
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sagar Rohankar wrote:

Rodrigo Bossini wrote:

Sagar Rohankar wrote:What is the action mapping for path "/efetuaEdicaoPaciente", please post that from struts-config xml and make sure that both action has same form name .


I read somewhere that for some reason it would be advisable to NOT have the same form for two different actions.


Depends upon the scope you're declaring your FROM, in session scope it may leads to some problems if the same form is used by another Action.



What kind of problem could possibly arise?
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most convincing problem will be, you may end up using stale data or old data or 'others' data, for example if you declared the form in session scope and initialize it with some data, and if within the session expire time out, some other action access the same form, the action gets the same old data as that got initialized by first Action..

Struts don't instantiated the new Form, if that form object is already present in session.

And other problem, like memory consumption.

HTH
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic