CMS 3D CMS Logo

Public Member Functions | Private Attributes

Select Class Reference

#include <Select.h>

Inheritance diagram for Select:
WebElement

List of all members.

Public Member Functions

void printHTML (xgi::Output *out)
 Select (std::string the_url, std::string top, std::string left, std::string the_requestID, std::string the_name)
void setOptionsVector (std::vector< std::string > the_options_v)
 ~Select ()

Private Attributes

std::string name
std::vector< std::string > options_v
std::string requestID

Detailed Description

This is the class that should be instantiated in case the user wants to have a select menu, the elements of which, submit a request when clicked on.

Definition at line 14 of file Select.h.


Constructor & Destructor Documentation

Select::Select ( std::string  the_url,
std::string  top,
std::string  left,
std::string  the_requestID,
std::string  the_name 
) [inline]

Definition at line 25 of file Select.h.

References name, and requestID.

    : WebElement(the_url, top, left)
    {
      name = the_name;
      requestID = the_requestID;
    }
Select::~Select ( ) [inline]

Definition at line 33 of file Select.h.

    {
    }

Member Function Documentation

void Select::printHTML ( xgi::Output *  out) [virtual]

Implements WebElement.

Definition at line 4 of file Select.cc.

References WebElement::get_pix_left(), WebElement::get_pix_top(), WebElement::get_url(), name, options_v, position, requestID, benchmark_cfg::select, and asciidump::table.

{
  std::string position = "position:absolute; left:" + get_pix_left() + "; top:" + get_pix_top();

  // the javascript function makeSelectRequest expects the url of the request and the id of the widget
  // Example: makeSelectRequest('https://[ApplicationURL]/Request?RequestID=MyCustomRequest', 'select menu 1');
  std::string applicationURL = get_url();
  std::string requestName    = "RequestID=" + requestID;
  std::string js_command = "makeSelectRequest('" + applicationURL + "/Request?" + requestName + "'" + 
    ", '" + name + "')";

  *out << cgicc::div().set("style", position.c_str()) << std::endl;

  // The id of the form is the name of the select menu + " Form".
  *out << cgicc::form().set("name", name + " Form").set("id", name + " Form") << std::endl;

  *out << cgicc::table() << std::endl;
  *out << cgicc::tr() << std::endl
       << cgicc::td() << std::endl
       << name << ":" << std::endl
       << cgicc::td() << std::endl;


  *out << cgicc::td() << std::endl;
  *out << cgicc::select().set("name", name).set("id", name).set("onchange", js_command) << std::endl; 
  *out << cgicc::option().set("value", "").set("selected") << cgicc::option() << std::endl;
  for (std::vector<std::string>::iterator it = options_v.begin(); it != options_v.end(); it++)
    {
      *out <<  cgicc::option().set("value", *it) << *it << cgicc::option() << std::endl;
    }
  *out << cgicc::select() << std::endl;
  *out << cgicc::td() << std::endl;

  *out << cgicc::tr() << std::endl;

  *out << cgicc::table() << std::endl;

  *out << cgicc::form() << std::endl;
  *out << cgicc::div() << std::endl;
}
void Select::setOptionsVector ( std::vector< std::string >  the_options_v) [inline]

Definition at line 37 of file Select.h.

References options_v.

    {
      options_v = the_options_v;
    }

Member Data Documentation

std::string Select::name [private]

Definition at line 18 of file Select.h.

Referenced by printHTML(), and Select().

std::vector<std::string> Select::options_v [private]

Definition at line 21 of file Select.h.

Referenced by printHTML(), and setOptionsVector().

std::string Select::requestID [private]

Definition at line 19 of file Select.h.

Referenced by printHTML(), and Select().