package flexa.ff;

import flexa.fb.*;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;


public class card extends FComponent {
    
    public card() {
        super("ff.card");
    }

	public void updateFromRequest(HashMap<String, Object> aParameters) {
	    if( aParameters.containsKey(this.getValue("name")) )
            this.setValue("value", aParameters.get(this.getValue("name")).toString());
	}  
	
	public void event(String aAction, FContext aContext) throws Exception {
	    Log.getInstance().info("card " + this.name + " event " + aAction);
	    if( this.status == 0 
	        && hasValue("datasource")
	        && ((String)getValue("datasource")).toLowerCase().startsWith("select") 
	        && (aAction.equals(this.name + ".select") || aAction.equals(this.name + ".refresh") || aAction.equals("onopen") || aAction.equals("start"))
	       ) {
	        //Log.getInstance().info("card event " + aAction + " datasource : " + (String)getValue("datasource") );
            // Execute ds
            FResult result = Util.sqltoarrayddtotal(aContext, (String)getValue("datasource"));
            // Clone me
            this.clonefromresult(result, aContext);
	    }
	    super.event(aAction, aContext);
	}
	

}