package flexa.ff;

import flexa.fb.*;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;


public class div extends FComponent {
    
    public div() {
        super("ff.div");
    }

	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("DIV " + 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("DIV event " + aAction + " datasource : " + (String)getValue("datasource") );
            FResult result = Util.sqltoarrayddtotal(aContext, (String)getValue("datasource"));  // Execute ds
            this.clonefromresult(result, aContext); // Clone me

	    }
	    super.event(aAction, aContext);
	}
	

}