######################################################################
##
## 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 Hello 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 Hello operations.
######################################################################

proc view(hello, ac)
{
  # generates <h1>...</h1>
  ac.h1("Basic Actions on this Hello service")

  # generates a HTML form referring the do_hello_world action.
  ac.action_form(hello,"do_hello_world")
    # generates the submit button.
    ac.submit_button("Hello World!")
  ac.end_form()

  # generates a HTML form referring the do_display action.
  ac.action_form(hello,"do_display")
    # generates the submit button.
    ac.submit_button("Display")
    ac.println(" the following message ")
    # generates the text field input for the variable "a_message".
    ac.text_input("a_message", 40)
  ac.end_form()
}

######################################################################
## This action executes the hello_world operation on a Hello.
######################################################################

proc do_hello_world(hello, ac)
{
  # executes the remote hello_world operation.
  hello.hello_world()

  # generates the forms.
  view(hello, ac)
}

######################################################################
## This action executes the display operation on a Hello.
######################################################################

proc do_display(hello, ac)
{
  # gets the form variable "a_message".
  a_message = ac.getString("a_message")

  # executes the remote display operation.
  hello.display(a_message)

  # generates the forms.
  view(hello,ac)
}

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

declareAction("view", view, "Views forms to act on the Hello object")
declareAction("do_hello_world", do_hello_world, "Executes the hello_world operation")
declareAction("do_display", do_display, "Executes the display operation")

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