# $Id: s.HtmlPlace.xotcl 1.9 01/03/23 21:55:31+01:00 neumann@somewhere.wu-wien.ac.at $
package provide xotcl::awo::htmlPlace 0.8

package require xotcl::trace
package require xotcl::awo::webAgent
package require xotcl::mos::httpPlace
package require xotcl::store::persistence
package require xotcl::mos::agent

Class HtmlPlace -superclass Place -parameter {allowExit}

HtmlPlace instproc init args {
  next
  #
  # just define a minimal object that can react 
  # with HTML decoration, if the called object
  # doesn't exist
  WebFacadeHtml create [self]::start.html

  [self] startingObj [self]::start.html
  if {[[self] exists allowExit]} {
    set exitObj [WebObject create [self]::[[self] set allowExit]]
    [Place getInstance] exportObjs $exitObj
    $exitObj proc default {} {after 1000 ::exit; return "Server terminates"}
  }
}
HtmlPlace instproc default {} {
  set place [string trimleft [self] :]
  set msg "<HTML><TITLE>Place $place</TITLE>
	<BODY><H2>Place $place</H2> Try one of the following links:<UL>"
  foreach o [[self] exportedObjs] {
    set o [string trimleft $o :]
    append msg "<LI><A HREF='[url encodeItem $o]'>$o</A></LI>"
  }
  append msg "</UL></BODY>\n"
}
