wood burning stoves*
The moose likes Struts and the fly likes Two Action questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Two Action questions" Watch "Two Action questions" New topic
Author

Two Action questions

Peter Kananen
Greenhorn

Joined: Apr 24, 2005
Posts: 4
1. I have an action that returns everything in a db table, and then I want to create html tables that display all of the (variable amount) data. How do I create this dynamic html? Scriptlets? With the struts mantra seperating business logic from presentation, this seems hard.

2. I assumed there was a one to one ratio between a view and an Action. I have a jsp page with 3 simple fields (html text fields), which are then added to a db upon submission. But, the action (AddRecordAction.java) must give a "success" before the view page can be displayed - do I need an action that goes after the form is submitted??

Thanks!
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
1. it's not hard, you need to try harder. it's actually very simple VC in the whole MVC thing. separation of biz logic and presentation is not a mantra of struts, it's a matra of good application design practice in EVERY framework. struts makes it much easier with the provided tag libraries for your view layer. if you don't like them, use JSTL (i highly recommend this), avoid scriptlets as much as possible. i suggest searching for some samples online.

2. it's not 1-to-1, you can have your entire app full of actions forward to 1 jsp, but that would be a little confusing to the user. if you want to forward the update to the same page, use struts ActionMessage to display some 'success' message to the user on that same page. the set up of this depends on your understanding of how your Action class finds the defined forwards.

these are 2 very basic struts concepts. before delving into doing serious apps and go down the wrong paths, pick up a book or go through some tutorials, here's a good one: http://www.reumann.net/struts/main.do.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
 
jQuery in Action, 2nd edition
 
subject: Two Action questions
 
Similar Threads
Listener Class and Regular Java
Ajax - Struts - JSP
struts Action for asynchronous HTTP processing
Store jsp content in database
Prepopulating a DynaActionForm