Package com.nexirius.jnex.example.command

Source Code of com.nexirius.jnex.example.command.DeletePersonCommand

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.DataModelVector;
import com.nexirius.framework.datamodel.DataModelEnumeration;
import com.nexirius.framework.datamodel.DataModel;
import com.nexirius.jnex.example.datamodel.MainModel;
import com.nexirius.jnex.example.datamodel.PersonModel;

public class DeletePersonCommand 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 {
        DataModelVector selectedChildren = sessionVariable.getSelectedChildren();
        DataModelEnumeration en = selectedChildren.getEnumeration();

        while (en.hasMore()) {
            MainModel mainModel = ((MainModel) sessionVariable.getApplicationModel());

            DataModel model = en.next();
            mainModel.getPersonArray().removeItem(model);
        }

        return true;
    }
}
TOP

Related Classes of com.nexirius.jnex.example.command.DeletePersonCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.