package org.opengroupware.jope.appserver.elements;

import java.util.Map;

import org.opengroupware.jope.appserver.WOAssociation;
import org.opengroupware.jope.appserver.WOContext;
import org.opengroupware.jope.appserver.WOElement;
import org.opengroupware.jope.appserver.WOResponse;

public class WOResetButton extends WOInput {

  public WOResetButton(String _name, Map<String, WOAssociation> _assocs,
                       WOElement _template)
  {
    super(_name, _assocs, _template);
  }

  public void appendToResponse(WOResponse _r, WOContext _ctx) {
    // TODO: warn if 'name' and 'disabled' are set?
    
    _r.appendBeginTag("input");
    _r.appendAttribute("type",  "reset");
    _r.appendAttribute("name",  this.elementNameInContext(_ctx));
    _r.appendAttribute("value", this.value.stringValueInComponent(_ctx));
    
    if (this.disabled != null) {
      if (this.disabled.booleanValueInComponent(_ctx.cursor()))
        _r.appendAttribute("disabled", "disabled");
    }
    
    this.appendExtraAttributesToResponse(_r, _ctx);
    // TODO: otherTagString
    
    _r.appendBeginTagClose();
  }
}
