ServiceException

From JRapid

Jump to: navigation, search

ServiceException is a runtime exception offered in the com.jrapid.exception package used to stop a method execution showing a message to the user.

Example

For a Company entity, you could overwrite the store() method in the Services class to avoid phone numbers that start with "000" from being saved.

import com.jrapid.exception.ServiceException;

public class CompanyServices extends CompanyServicesAbstract {

	@Override
	public Object store(String id, Company voobj) {	
		if(voobj.getPhone().startsWith("000")) {
			throw new ServiceException("Phone numbers cannot start with '000'");
		}
		return super.store(id, voobj);
	}
}

If the phone property value starts with "000" the execution is stopped and the string message passed as a parameter to the ServiceException is shown to the user in the front end by using a browser alert.

See also

Personal tools