All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mentawai.coc.OldAutoViewConsequenceProvider Maven / Gradle / Ivy

Go to download

A Java full-stack web framework with programmatic configuration instead of XML and Annotations.

There is a newer version: 2.5.6
Show newest version
package org.mentawai.coc;

import org.mentawai.core.Action;
import org.mentawai.core.Consequence;
import org.mentawai.core.Forward;

/**
 * This consequence provider was build for backward compatibility with the old
 * auto view schema, in other words, if you were using the old auto view schema
 * you can use the consequence provider to simulate the same behaviour when 
 * choosing your consequences.
 * 
 * @author Sergio Oliveira Jr.
 */
public class OldAutoViewConsequenceProvider implements ConsequenceProvider {
   
   public Consequence getConsequence(String action, Class actionClass, String result, String innerAction) {
	   
	   if (result == null) return null;
    
	   StringBuilder sb = new StringBuilder(128);
		
	   sb.append("/").append(action).append("/");
		
		if (innerAction != null) {
		    
		    sb.append(innerAction).append(".");
		}
		
		if (result.equals(Action.SUCCESS)) {
		    
		    sb.append("ok.jsp");
		    
		} else {
		    
		    sb.append(result).append(".jsp");
		}
		
		Consequence c = new Forward(sb.toString());
		
		return c;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy