Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Struts2 questions

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm just getting started with Struts2 and I have some questions regarding the usage of the framework.
I want to use the s:action tag to populate a select drop-down list but it does not seem to work. I read
the documentation regarding the s:action tag and I cannot find what am I doing wrong. Are there any
examples of s:action usage to point me to (apart from the extremely trivial ones) ?

Also another issue I have is how can I submit a form to the current page the user is. For example I
have a drop-down list from which the user selects the language he wants, and then submits the result.
I want the user after the submission of the form to be redirected to the same page he was. How can I
achieve that using action mapping on the struts.xml ?

Thanks in advance
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re question 1: without knowing what you're doing, it's impossible to say what you're doing wrong.

Re question 2: a form tag with no action/etc. will do a postback, although that isn't necessarily what you really want--it depends on your application.
 
Yiorgos Panayiotakis
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok you are probably right maybe I have to elaborate a bit to give you a better understanding of what I'm
asking.

In question 1 what I want is to use the s:action tag to provide me with the data to populate a drop-down
list. To be more specific I want to populate a drop-down list with a number of Countries. For this purpose
I created an action (populateCountryList) that its sole purpose is to supply me with the List of Countries
(see code snippet below).


Now in the header of each of my pages I have the code



which fails to populate the drop-down list. Correct me if I am wrong but shouldn't the Countries property be
available on the ValueStack after I used the s:action tag ?

For the second question imagine that while the user changes the Language I want some code to be executed
(so I have to provide some action to the form) and then return to the current page that initiated the submission
of the form . Because this form is in the header page (which is included in several pages) I want to know if
there is a way to tell struts (through struts.xml) to execute an action and then return back to the same page
that initiate the request.

Thanks
 
Yiorgos Panayiotakis
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually I found the problem related with question 1. I had to add an id attribute to s:action tag, which I
then used to access my property. Hence the new (corrected) code (just in case anybody stumbles to the
same problem) is :
 
Something must be done about this. Let's start by reading this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!