top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Getting lists back from struts

0 votes
31 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 Google+ Share Button LinkedIn Share Button Multiple Social 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 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.

+1 vote

Facing some issue, while we use wildfly-deploy maven plugin to deploy strut2 application to wildfly aka jboss 7, struts2 is unable to read package.properties file packaged inside .war. If i deploy from an IDE or manually then there is no issue.

The only difference is wildfly-deploy plugin is deploying application war inside {WILDFLY_HOME}/standalone/data/ folder where as manual or IDE will deploy it under {WILDFLY_HOME}/standalone/deployments/ folder.

In essence struts2 unable to read package.properties file if deployed under certain location.

Any thoughts, application is working perfectly except label's are not coming only label key is coming in screens.


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...