File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts: how to list and update data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts: how to list and update data" Watch "struts: how to list and update data" New topic
Author

struts: how to list and update data

luke zanks
Greenhorn

Joined: Aug 23, 2011
Posts: 2
Hey guys.

I begun to work debugging java web applications with struts. Normally bugs are not difficult to correct, but for me is difficult when they are into struts xml config files.
So, below is the problem that now broke my head (this is a bug occurred in an existing java application that I have to correct):

I have a first page that lists data and permits to modify it (we'll call it list.do, invoking listAction.java that reads and prepares data, and a list.jsp page to display it).
Submitting a form, we have to go to another page, that updates data and immediatly returns to previous page without pressing keys (we'll call it modify.do, invoking modifyAction.java and using modify.jsp, if it's needed, that returns to previous page on onload event, for example).

What is the correct method to configure it, using struts 1 (without falling in stack overflow or other errors) ?

(In php or in perl it's possible to do it with almost 50 lines)

Other questions, that aren't clear (for me) in tutorial: how is exactly specified the jsp pages associated to an action? And how the "forward" attributes work?

I now that there are trivial questions, but I worked some days without succeding to resolve them

Thanks in advance!!!

zanks

zanks432@yahoo.com

P.S.: excuse my ignorance of struts and my bad English
Rajagopal Mani
Ranch Hand

Joined: Mar 24, 2011
Posts: 84

Welcome to JavaRanch.
I have a first page that lists data and permits to modify it (we'll call it list.do, invoking listAction.java that reads and prepares data, and a list.jsp page to display it).
Submitting a form, we have to go to another page, that updates data and immediatly returns to previous page without pressing keys (we'll call it modify.do, invoking modifyAction.java and using modify.jsp, if it's needed, that returns to previous page on onload event, for example).


The above scenario is not clear. Find my understanding below.

[1] Initial loading ListAction.java is executed & List.jsp is rendered as first page.
[2] First page has Modify/Edit button to perform modify operation
[3] On click of Modify/Edit button in first page ModifyAction.java is executed & Modify.jsp is displayed
[4] On submitting Modify.jsp form, the first page needs to be displayed with updated data.

Please confirm whether above understanding correct. If not, please elaborate further.
luke zanks
Greenhorn

Joined: Aug 23, 2011
Posts: 2
>[1] Initial loading ListAction.java is executed & List.jsp is rendered as first page.
>[2] First page has Modify/Edit button to perform modify operation
>[3] On click of Modify/Edit button in first page ModifyAction.java is executed & Modify.jsp is displayed
>[4] On submitting Modify.jsp form, the first page needs to be displayed with updated data.

>Please confirm whether above understanding correct. If not, please elaborate further.

Yes. List.jsp must have a textfield that reads the value in the database and permits to modify
it by a submit button, like:

Value: _____________
<Save>


Modify.jsp only must display a messahe like:

The value was updated. Click <Here> to return to previous page


I know it's possible to do it with only a jsp form and only one action (what I did yesterday, after
a lot of times that I received stack overflow on second form or the second action wasn't executed).

I wish to know how is possible correctly implement those 2 forms with struts 1, and how must be used
forward attributes in struts-config.xml file (I searched for samples, but I only found complex samples
difficult to undestand for me)

Thanks in advance


zanks

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts: how to list and update data