package mildo.wiwo.components;

import mildo.wiwo.Session;
import mildo.wiwo.data.WiwoPage;

import com.webobjects.appserver.*;

// Generated by the WOLips Templateengine Plug-in at Apr 18, 2009 3:02:05 PM
public class EditWiwoPageComp 
	extends mildo.wiwo.components.BaseComp 
{
	
	public EditWiwoPageComp(WOContext context) {
        super(context);
    }
	
	private WiwoPage page4Editing;
	
	public void setPage4Editing(WiwoPage aValue) {
		page4Editing = aValue;
		if (page4Editing != null) {
			if (wikiMarkup == null) {
				wikiMarkup = page4Editing.wikiMarkup();
			}	
			pageName = page4Editing.name();
		}	
	}
	
	public WiwoPage getPage4Editing() {
		return page4Editing;
	}
	
	private String pageName;
	
	public void setPageName(String aValue) {
		pageName = aValue;
	}
	
	public String getPageName() {
		return pageName;
	}
	
	private String wikiMarkup;
	
	public void setWikiMarkup(String aValue) {
		wikiMarkup = aValue;
	}
	
	public String getWikiMarkup() {
		return wikiMarkup;
	}
	
	public WOComponent saveChangesAction() {
		if (wikiMarkup != null && page4Editing != null && page4Editing.wikiMarkup() != null && !wikiMarkup.equals(page4Editing.wikiMarkup())) {
			setPage4Editing(WiwoPage.createPage(session().defaultEditingContext(), ((Session)session()).getActualSessionUser(), page4Editing.name(), wikiMarkup, page4Editing));
			session().defaultEditingContext().saveChanges();
		}
		return null;
	}
	
}