package com.nexirius.jnex.example.command;
import com.nexirius.framework.htmlview.HTMLCommand;
import com.nexirius.framework.htmlview.HTMLSessionVariable;
import com.nexirius.framework.htmlview.DefaultHTMLCommand;
import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.framework.datamodel.ModelFlag;
import com.nexirius.framework.FWLog;
import com.nexirius.jnex.example.datamodel.MainModel;
import com.nexirius.jnex.example.datamodel.PersonModel;
public class NewPersonCommand extends DefaultHTMLCommand {
//Method to define weither this HTMLCommand needs to be mapped in a HTMLTransition
//context to be executed.
public boolean requiresMapping() {
return true;
}
//Method that defines that actual command and should return true if the transition
//it could be mapped into should take place.
public boolean execute(HTMLSessionVariable sessionVariable) throws Exception {
PersonModel actualPerson = (PersonModel) sessionVariable.getActModel();
if (actualPerson.isValid()) {
DataModel item = actualPerson.duplicate(null, null);
((MainModel) sessionVariable.getApplicationModel()) .getPersonArray().sortInsert(item);
actualPerson.clear();
return true;
}
boolean flag = actualPerson.getFlag(ModelFlag.MANDATORY);
System.out.println("flag = " + flag);
return false;
}
}