indexing description: "An application servlet that may generate a response to the user" author: "Neal L Lester " date: "$Date$" revision: "$Revision$" copyright: "(c) Neal L Lester" deferred class GOA_DISPLAYABLE_SERVLET inherit GOA_APPLICATION_SERVLET redefine log_request_content end KL_SHARED_FILE_SYSTEM feature -- Attributes ok_to_display (processing_result: REQUEST_PROCESSING_RESULT): BOOLEAN is -- Is it OK to display this servlet to the user? -- No if user lacks permission or system state doesn't permit display of this page? require valid_processing_result: processing_result /= Void ok_to_read_data: ok_to_read_data (processing_result) deferred ensure ok_to_read_data: ok_to_read_data (processing_result) end send_secure: BOOLEAN -- Sent pages generated by this servlet only via an SSL connection log_request_content: BOOLEAN is do Result := Precursor and not send_secure end standard_submit_label (processing_result: REQUEST_PROCESSING_RESULT): STRING is -- Label to display on the "Standard" submit button for this page require valid_processing_result: processing_result /= Void ok_to_read_data: ok_to_read_data (processing_result) do Result := processing_result.message_catalog.submit_label end feature -- Page Building new_xml_document (processing_result: REQUEST_PROCESSING_RESULT): GOA_XML_DOCUMENT is -- Create a new XML document and open the documents root element require valid_processing_result: processing_result /= Void processing_result_was_processed: processing_result.was_processed not_ok_to_read_write_data: implements_transaction_and_version_access implies not (ok_to_read_data (processing_result) or ok_to_write_data (processing_result)) generating_servlet_updated: processing_result.generating_servlet = Current deferred ensure valid_result: Result /= Void root_element_added: Result.root_element_added not_ok_to_read_write_data: implements_transaction_and_version_access implies not (ok_to_read_data (processing_result) or ok_to_write_data (processing_result)) end add_body (processing_result: REQUEST_PROCESSING_RESULT; xml: GOA_XML_DOCUMENT) is -- Add the body to xml require not_ok_to_read_write_data: implements_transaction_and_version_access implies not (ok_to_read_data (processing_result) or ok_to_write_data (processing_result)) valid_processing_result: processing_result /= Void processing_result_was_processed: processing_result.was_processed valid_xml: xml /= Void -- xml is in a state where it is OK to add content deferred ensure not_ok_to_read_write_data: implements_transaction_and_version_access implies not (ok_to_read_data (processing_result) or ok_to_write_data (processing_result)) end add_footer (processing_result: REQUEST_PROCESSING_RESULT; xml: GOA_XML_DOCUMENT) is -- Add the footer to xml require valid_processing_result: processing_result /= Void processing_result_was_processed: processing_result.was_processed valid_xml: xml /= Void not_ok_to_read_write_data: implements_transaction_and_version_access implies not (ok_to_read_data (processing_result) or ok_to_write_data (processing_result)) -- xml is in a state where it is OK to add content deferred ensure not_ok_to_read_write_data: implements_transaction_and_version_access implies not (ok_to_read_data (processing_result) or ok_to_write_data (processing_result)) end feature send_response (processing_result: REQUEST_PROCESSING_RESULT) is -- Send a response to the user require valid_processing_result: processing_result /= Void processing_result_was_processed: processing_result.was_processed local response: GOA_HTTP_SERVLET_RESPONSE do response := processing_result.response processing_result.set_generating_servlet (Current) log_hierarchy.logger (configuration.application_log_category).info ("Generating servlet: " + name) response.send (new_page (processing_result).as_html) end new_page (processing_result: REQUEST_PROCESSING_RESULT): GOA_XML_DOCUMENT is -- XML version of page to send to user require valid_processing_result: processing_result /= Void processing_result_was_processed: processing_result.was_processed do Result := new_xml_document (processing_result) add_body (processing_result, Result) add_footer (processing_result, Result) -- Close up any elements from until Result.is_complete loop debug ("goa_xml_document") io.put_string ("Dangling Element: " + Result.element_tag_for_code (Result.current_element_code) + "%N") end Result.end_current_element end debug ("goa_xml_document") Result.put_html_to_file ("output.htm") end end end -- class GOA_DISPLAYABLE_SERVLET