Adding @RequiredStringValidator causing result not to be found

107 views Asked by At

I have an Apache Struts web application. All of my actions are defined in my struts.xml file. I am trying to add support to my action classes to have validation annotations added to my project.

To try and get this working I added the struts2-convention-plugin.jar and also commons-lang.jar.

I then added an annotation on top of my action method.

jsp

<s:form id="tradingOutageFrm" action="addTradingOutageDo.action" 
  validate="true" theme="simple">

struts.xml

<action name="addTradingOutageDo" class="com.myproject.action.TradingOutageAction" 
      method="addDo">
    <result name="success" type="tiles">page.tradingOutageAdd</result>
</action>   

My action class

public class TradingOutageAction extends ActionSupport {

    @RequiredStringValidator(type = ValidatorType.SIMPLE, 
                        fieldName = "storeNo", 
                          message = "Please enter a store.")
    public String addDo() throws Exception {                    
        try{
            Map<String, Object> session = ActionContext.getContext().getSession();      
            String userId = session.get("userid").toString();       

            tradingOutage.setStoreNo(storeNo);
            tradingOutage.setStoreServer(storeServer);

            tradingOutageDAO.insertOutage(userId, startDate, startTime, 
                                          endDate, endTime, tradingOutage); 
            addActionMessage(MessageConstants.RECORD_INSERTED);         
        }catch(Exception e){
            addActionError(MessageConstants.UPDATE_FAILED + " " + e.getMessage());
        }
        return SUCCESS;
    }

Without the annotation everything works fine but with the annotation I get a

No result defined for action com.myproject.action.TradingOutageAction and result input.

Can anyone help me with what might be wrong here.

0

There are 0 answers