Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Two Action questions" Watch "Two Action questions" New topic

Two Action questions

Peter Kananen

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 ( must give a "success" before the view page can be displayed - do I need an action that goes after the form is submitted??

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:

-/a<br />certified slacker...yes, my last name is 'do' - <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Two Action questions
It's not a secret anymore!