top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Getting lists back from struts

0 votes
533 views

I have encountered this issue a couple of times, always found a way to code around but now I really need to ask:

Can struts create lists/arrays (or whatever collection) when e.g. using

public class MyAction extends ActionSupport {
 public List getChoices() {
 ....
 }
 ....
 public List getPreSelectedChoices() {
 // returns a list of Choice.getKey(), which is a String
 ....
 }
 }

 public class Choice {
 public String getKey() { ...}
 public String getDisplayName() { ... }
 ....
 }

The selected values are sent to

public void setMyChoice(String myChoice){
 ...
}

correct? There is no way something like

public void setMyChoice(String[] myChoice){
 ...
}

works in struts?

If not, whats the common way to get the values back from the String myChoice? Use Split on it?

posted Aug 7, 2013 by Jagan Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
answer Aug 7, 2013 by Abhay Kulkarni
Similar Questions
+1 vote

I am using the token session interceptor for a form and I have this situation:
1) I am in the form page;
2) I leave the form page;
3) Go back to the form page by the "back" button;
4) Submit the form;

And of course the form is not submitted and the token returns "invalid.token" but do not adds no actionError. It will not be interesting to add an action error?

Ok, I can resend to a page with a message but I already have a error page that presents the action errors when necessary.

0 votes

In the context of an tag, for instance for a login action, we previously always coded forms as :

 ....

And in the struts.xml we have been using :

content.login
 content.menu
 summary_input
 welcome

This has worked in the past and allowed us to not only use the action="login" to target the execute method of the action, but also to build links to, for instance, login_checkStatus.action to target other, specific methods within the action. I am not sure this Is a common/best practice, I had no prior struts2 experience before joining this company and this is how a lot of the existing functionality is coded. (If this is wrong/there is a better way, please let me know)

Now randomly, this fails to generate the proper action url in the html (it is missing the '.action', which results in a 404 once you post the form)

The only workaround we have found so far is to add the '.action' suffix to the
s:form's action attribute. Before it was always added for us by struts.

So now we are having success with

 ...

I can only assume that this has been affected by the changes related to S2-015 and the wildcard action matching.

0 votes

I have been tasked with upgrading Apache Struts, running on CentOS 7, to the latest version. I have no idea where to begin. I am not a web developer, I am only a system administrator, so I have no idea where I should even look to figure out how to upgrade this thing. Any and all help will be greatly appreciated!

0 votes

I have a very minimal struts app I wrote some years ago. I want to upgrade it from 2.3 to 2.5. I'm wondering what requirements would allow the use of the essential dependencies jar. I am using only jstl tags, no struts tags. And my app is pretty simple.

...