package flexa.ff;

import flexa.fb.*;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;


public class li extends FComponent {
    
    public li() {
        super("ff.li");
    }

	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("LI " + this.id + " event " + aAction + " status " + this.status);
	    if( this.status == 0 
	            && hasValue("datasource")
	            && ((String)getValue("datasource")).toLowerCase().startsWith("select") 
	            && (aAction.equals(this.id + ".select") || aAction.equals(this.id + ".refresh") || aAction.equals("onopen") || aAction.equals("start")) 
	        ) {
	        Log.getInstance().info("LI 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);
	}
	

}