package flexa.ff;
import flexa.fb.*;
import java.util.Map;
import java.util.HashMap;
import javax.script.*;
public class card extends FComponent {
    //
    // CONSTRUCTOR
    //
    public card() {
        super("ff.card");
    }
    
    // 
    // Methods
    //
    
    
    public void updateFromRequest(HashMap<String, Object> aParameters)  { 
    		if( aParameters.containsKey(this.getValue("name")) )
		        this.setValue("value", aParameters.get(this.getValue("name")).toString());

    }
    


    // 
    // Events
    //
	public void event(String aAction, FContext aContext) throws Exception {
        
    
        // refresh EVENT
        if( LibText.stringToArray("" + this.name + ".select," + this.name + ".refresh,onopen,start").contains(aAction) ) {
        			if( this.status == 0  && hasValue("datasource") && ((String)getValue("datasource")).toLowerCase().startsWith("select") ) {
			    //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);
	}
	
	
	
	
}