wood burning stoves 2.0*
The moose likes Struts and the fly likes struts 1 form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 1 form" Watch "struts 1 form" New topic
Author

struts 1 form

Rodrigo Bossini
Ranch Hand

Joined: Jul 03, 2009
Posts: 108
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?

I see wind mills
Rodrigo Bossini
Ranch Hand

Joined: Jul 03, 2009
Posts: 108
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.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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 .


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Rodrigo Bossini
Ranch Hand

Joined: Jul 03, 2009
Posts: 108
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Jul 03, 2009
Posts: 108
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 1 form
 
Similar Threads
Open new window from struts with session access
html:link problem
problem in forms..
Actionform not populating JSP
actionForm mechanism