user1006080
user1006080

Reputation: 75

struts2 validation framework requires result input

In my project with struts2, I don't use validation framework, and no action methods return "input" in my Action class. Here is my configuration snippet,

    <action name="searchTracker" class="searchAction" method="searchTracker">
        <result name="success">/jsp/searchTracker.jsp</result>
        <result name="error">/jsp/searchTracker.jsp</result>
        <result name="input">/jsp/searchTracker.jsp</result>
    </action>

Here is the action class

 public String searchTracker(){

    this.clearErrorsAndMessages();

    List<File> files = fileManager.retrieveFiles(patchNumBySearch);
    if(files == null){
        this.setTrackers(null);
        addActionError("This patch number doesn't exist. Please choose another one !");
        return ERROR;
    } else {
        if (files.size() == 0) {
            addActionError("This patch doesn't include any tracker. Please create tracker or choose another patch");
            return ERROR;
            }
        else {
            List<Tracker> trackers = commonUtils.convertToTrackers(files);
            this.setTrackers(trackers);
        }
    }
        return SUCCESS;
}

If I remove input result, it will throw exception, like this

     "No result defined for action SearchTrackerAction and result input"

and if i check back end log, it shows "2011-11-07 00:09:13,841 DEBUG

com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.debug:68 - Errors on action com.harris.northstar.dbadesk.action.SearchTrackerAction@1d07b41, returning result name 'input'"

Why it invokes DefaultWorkflowInterceptor and return result name input?

If I put back input result in configuration, the exception is gone. But If Action goes to error firstly, it won't go to sucess again even I set break point, it won't go into that method searchTracker() after that.

Upvotes: 2

Views: 2245

Answers (1)

Dave Newton
Dave Newton

Reputation: 160181

This can also be caused by a type conversion error; without knowing more about what you're sending in, it's difficult to help beyond that.

If you remove the "workflow" interceptor, S2 will stop checking for errors on the action. You may also need to remove the type conversion interceptor, but workflow should be enough. If you're not using any validation, you may as well remove that interceptor as well.

Upvotes: 2

Related Questions