Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two Action questions

 
Peter Kananen
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic