• 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

ActionForms............

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a struts newbie, so be patient!
1. I have a jsp screen with display items only, is the correct way to accomplish this to use a standard action form, but just load it manually and stuff it in the session, using standard tags to extract the data?
2. I can't figure out how to access a form field withnin a jsp for use in a scriptlet. I have a field in the form I want to test, and the only way I can think of doing this is using standard java code in a scriplet to get the bean, and then do what I want.
Thanks in advance.
Dave Hewitson.
 
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Not sure to really understand the question but let's try an answer.
Due to reflection, the fields of your form are available in the associated ActionForm class.
So in a validate method, you can get their values and do the job needed.
hth
[ April 25, 2002: Message edited by: Bill Bailey ]
 
Dave Hewitson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bill - thanks for your reply.
I want to access the data in the form from the jsp (eg via a scriptlet) but the only way I can think of doing this is by getting the form bean directly from the session - I have a concern that this isn't very "strutty", but can't find another way to do it.
It's simple when you just want to display the data cause you can just use the std <bean:message key="xxxxxx"/> tag, but I want to get this value within a scriptlet to do something with it.
Hope this clarifies a bit
Dave
 
Saloon Keeper
Posts: 27764
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. You COULD build a bean and use the useBean tag, but there's a reason why it works better when you use the Struts <bean:write> tag. I just wish I could remember what is is . You might want to check out my article on getting started with Struts. at http://www.devx.com/premier/mgznarch/javapro/2002/04apr02/th0402/th0402-1.asp
Sample code for what you're interested in is attached to the demo at
http://localhost/strutsdemo/showCategories.do
The sample is working with a Collection of beans - if you just want a single bean, of course, you don't need the iterator parts.
2. Scriptlets run BEFORE the page is sent to the client, so the form data is whatever you loaded in. If you're using a FormBean, just reference its get() method for the desired field. The Struts tag equivalent is bean:write.
 
Alas, poor Yorick, he knew this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic