// Generated by the WOLips Templateengine Plug-in at Apr 10, 2009 5:30:01 PM
package mildo.wiwo;

import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WORequest;
import com.webobjects.appserver.WODirectAction;

import mildo.wiwo.components.CssComp;
import mildo.wiwo.components.JavaScriptComp;
import mildo.wiwo.components.Main;
import mildo.wiwo.components.ShowWiwoPageComp;
import mildo.wiwo.components.WiwoPageComp;
import mildo.wiwo.data.WiwoPage;

public class DirectAction extends WODirectAction {
	public DirectAction(WORequest request) {
		super(request);
	}

	public WOActionResults defaultAction() {
		return pageWithName(Main.class.getName());
	}
	
	public WOActionResults cssAction() {
		return pageWithName(CssComp.class.getName());
	}
	
	public WOActionResults jsAction() {
		return pageWithName(JavaScriptComp.class.getName());
	}
	
	/**
	 * Shows newest version WiwoPage with given name
	 * @param aPageName
	 * @return
	 */
	public WOActionResults showWiwoPageAction() {
		String thePageName = (String) this.request().formValueForKey("pageName");
		WiwoPage thePage = WiwoPage.fetchPageWithName(session().defaultEditingContext(), thePageName);
		if (thePage != null) {
			WiwoPageComp theWiwoPageComp = (WiwoPageComp) pageWithName(WiwoPageComp.class.getName());
			theWiwoPageComp.setWiwoPage(thePage);
			theWiwoPageComp.showWiwoPage();
			return theWiwoPageComp;
		}
		return null;
	}
	
}
