Currently, I have a Stripes form with a submit button that’s binded to the “search” method of the following ActionBean:
public class SearchRepairActionBean extends BaseActionBean {
private String searchType;
private String searchValue;
@DefaultHandler
public Resolution defaultHandler(){
return null;
}
@HandlesEvent("search")
public Resolution search(){
return new ForwardResolution("SearchRepairResult.action").addParameter("searchType", searchType).addParameter("searchValue", searchValue);;
}
public String getSearchType() {
return searchType;
}
public void setSearchType(String searchType) {
this.searchType = searchType;
}
public String getSearchValue() {
return searchValue;
}
public void setSearchValue(String searchValue) {
this.searchValue = searchValue;
}
}
And SearchRepairResultActionBean attempts to resolve it thus:
public class SearchRepairResultActionBean extends BaseActionBean {
private String searchType;
private String searchValue;
@DefaultHandler
public Resolution defaultHandler(){
return new ForwardResolution("/jsp/searchRepairResult.jsp");
}
@HandlesEvent("SearchRepairResult")
public Resolution SearchRepairResult(){
System.out.println(searchType);
System.out.println(searchValue);
}
public String getSearchType() {
return searchType;
}
public void setSearchType(String searchType) {
this.searchType = searchType;
}
public String getSearchValue() {
return searchValue;
}
public void setSearchValue(String searchValue) {
this.searchValue = searchValue;
}
}
The problem is when I try to print “searchType” and “searchValue” – they return null. Am I passing parameters incorrectly? What would be the best way of doing this?
Why are you getting the
typeandvalueby callinggetContext().getRequest().getParameter()? You should be able to just have methods on yourSearchRepairResultActionBeanlike so:And then Stripes will inject the necessary values in (as part of
LifecycleStage.BindingAndValidation) before calling your event method.Actually, for that matter, why are you separating
SearchRepairActionBeanfromSearchRepairResultActionBean? If the “result” page needs to view the data that came from the form that was submitted to thesearchevent, then why not just perform the action in thesearch()method onSearchRepairActionBean, and then do aForwardResolutionon to your view? Is there a particular reason for using two ActionBeans here?