there is also a textfield, and a submit button, where i would like to add new words to this vector, and reload the page.
My action class looks like this:
public class EmployeeCreateBuzzwordAction extends ActionSupport implements SessionAware, ValidationAware
// braucht es bei jeder action zur identifikation
private static final long serialVersionUID = 1L;
private Map session;
private Exception ex = null;
There's absolutely no reason to tie yourself to the servlet specification to accomplish this. Even if you wanted to bypass the normal Struts 2 mechanisms and use the request map you could implement RequestAware and access the request parameter map directly and have an easier-to-test class.
That aside, do you have a buzzwordVector getter and setter in your action class?
Joined: Dec 29, 2008
yes i have the getter and setter in my class. And in the other classes it works perfect.. but here it doesnt... any idea?
Maybe it is a problem, that i have the pageLoad() Method and the addBuzzword() Method in the same action?
I don't think there's any reason buzzwordVector would get set with this code, although without the action configuration it's hard to say. If the form submits to the addBuzzword method you'll get a vector of one buzzword--actions are instantiated for each request.
One way to do this might be to just have a List<String> buzzwords, include hidden form fields using array notation, and the action method would just append the new buzzword to the end of the buzzword list. Less code, and uses the framework's type conversion to good advantage.
subject: struts 2: how can i pass a Vector as a parameter?