######################################################################
##
## Copyright (c) LIFL 1999
## The GOODE team of the LIFL
## University of Lille, France
## All rights reserved
##
## The CorbaWeb script associated to the OMG IDL GridService::GridFactory
## interface.
##
######################################################################

# Each action must have two arguments: the first one refers to the
# current CORBA object and the second one refers to a CorbaWeb
# ActionContext instance.

######################################################################
## This action generates forms to execute GridService::GridFactory
## operations.
######################################################################

proc view(factory, ac)
{
  # generates <h1>...</h1>
  ac.h1("Basic Actions on this GridFactory")

  # generates a HTML form referring the do_create_grid action.
  ac.action_form(factory,"do_create_grid")
    # generates the submit button.
    ac.submit_button("Create a new grid")
    # generates the text field input for the variables "a_h" and "a_w".
    ac.text_input("a_h", 3)
    ac.text_input("a_w", 3)
  ac.end_form()
}

######################################################################
## This action executes the create_grid operation on a GridService::
## GridFactory.
######################################################################

proc do_create_grid(factory, ac)
{
  # gets the form variables "a_h" and "a_w".
  a_h = ac.getLong("a_h")
  a_w = ac.getLong("a_w")

  # executes the remote create_grid operation.
  grid = factory.create_grid(a_h,a_w)

  # display the result.
  ac.anchorToObject(grid,"Go to the created grid")

  # generates the form.
  view(factory, ac)
}

######################################################################
## Declaration of these actions into the CorbaWeb ActionRepository.
######################################################################

declareAction("view", view, "Views the GridService::GridFactory")
declareAction("do_create_grid", do_create_grid,
              "Creates a GridService::grid")

######################################################################
# end of file 'CorbaWeb/actions/GridService_GridFactory'
######################################################################
