• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Two Action questions

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic