tags:

views:

63

answers:

1

Hi,

I have an Action for CRUD operations and 3 custom validators.

Two of the validators work correctly, but the other one does not. It handles correctly the validation, and returns the appropriate errors, but if there are no errors, the workflow does not complete, it never reaches the Action. It is as if it is stuck in the validator. There are no errors in the log file. If I remove the validator, the Action is reached.

I am not sure what I am doing wrong, and I would appreciate any help.

A: 

package com.timesheet.validator;

import java.util.Map;

import com.timesheet.action.TimeSheetAction;

import com.timesheet.util.TimeSheetClient;

import com.timesheet.util.TimeSheetHolder; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.validator.ValidationException; import com.opensymphony.xwork2.validator.validators.ValidatorSupport;

public class TimeSheetSubmission extends ValidatorSupport{

@Override public void validate(Object arg0) throws ValidationException { // TODO Auto-generated method stub

Map session = ActionContext.getContext().getSession(); TimeSheetAction act = (TimeSheetAction)ActionContext.getContext().getActionInvocation().getAction(); TimeSheetClient client = act.getClient();

if(session.get("holder") != null){ TimeSheetHolder holder = (TimeSheetHolder)session.get("holder");

   if(!(excessTime(holder) && lessTime(holder))){

    client.cleanUp();
 addActionError(arg0);
 return;
}else{

 client.cleanUp();
 return;
}

} } public boolean lessTime(TimeSheetHolder holder){ boolean done = true; TimeSheetHolder.Day day = holder.dailyHours(); switch(day){

case Mon: setMessageKey("timeSheet.mon.less.hours"); done = false;
break; case Tue: done = false;
setMessageKey("timeSheet.tue.less.hours"); break; case Wed: done = false;
setMessageKey("timeSheet.wed.less.hours"); break; case Thu: done = false;
setMessageKey("timeSheet.thu.less.hours"); break; case Fri: done = false;
setMessageKey("timeSheet.fri.less.hours"); break; default: break; } return done; } public boolean excessTime(TimeSheetHolder holder){ boolean done = true; TimeSheetHolder.Day day = holder.moreTime(); switch(day){

case Mon: setMessageKey("timeSheet.mon.excess.hours"); done = false;
break; case Tue: done = false;
setMessageKey("timeSheet.tue.excess.hours"); break; case Wed: done = false;
setMessageKey("timeSheet.wed.excess.hours"); break; case Thu: done = false;
setMessageKey("timeSheet.thu.excess.hours"); break; case Fri: done = false;
setMessageKey("timeSheet.fri.excess.hours"); break; default: break; } return done; }

}

John
Even when I removed all the code from the validate method it didn't reach the Action.
John