webform development guide - 富士通のソフトウェ...

68
B1WD-3119-01ENZ0(00) Interstage XWand V12 WebForm Development Guide Java Interface(XBRL 2.1)

Upload: trinhthuan

Post on 10-Mar-2018

250 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

B1WD-3119-01ENZ0(00)

Interstage XWand V12

WebForm

Development Guide

Java Interface(XBRL 2.1)

Page 2: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

ii

Page 3: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

iii

Page 4: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

iv

Preface

Purpose of this Guide This guide uses the Interstage XWand WebForm ("WebForm") sample program to provide an

overview of the Interstage XWand HTMLForm processor and Interstage XWand

RenderingLink processor, and explains their features and how they are used in WebForm

Intended Readership This guide is intended for application developers using the WebForm library.

It is assumed that readers of this guide are familiar with the XBRL 2.1 and FRIS specifications.

Related Manuals - XBRL Processor XBRL 2.1 Java Interface API Reference (referred to as "XBRL API

Reference")

- Dimension Processor XBRL 2.1 Java Interface API Reference (referred to as "Dimension API

Reference")

- Formula Processor XBRL 2.1 Java Interface API Reference (referred to as "Formula API

Reference")

Export Restrictions This software product is designed primarily for use in the country to which the software is

imported. The software must not be re-exported from the country without authorization from

the appropriate government authorities in accordance with the Foreign Exchange and

Foreign Trade Control Law of the country. In no event will Fujitsu be liable for foreign

government or third-party claims for compensation or damages whatsoever arising from the

use of the software resulting in any violation of the laws and ordinances of the country or

those of the relevant country. Fujitsu assumes no responsibility for any problems or

damages arising from such use of the software outside the country. If Fujitsu suffers any

damages as a result of a user’s violation of the above laws, Fujitsu reserves the right to

claim compensation from the user.

Trademarks - XBRL is a registered trademark of XBRL International, Inc. in the United States and other

countries.

- Microsoft, Windows, Excel, and Word are either trademarks or registered trademarks of

Microsoft Corporation in the United States and/or other countries.

- Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names

may be trademarks of their respective owners.

- Other trademarks and registered trademarks appearing in this manual are trademarks or

Page 5: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

v

registered trademarks of their respective companies.

Cautions - This manual may be modified without notice.

- This manual may not be copied or circulated without permission.

- Fujitsu is not responsible for any infringement of third-party patents or other rights arising

out of use of the data in this manual.

Publication Date First edition, December 2011

Page 6: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

vi

Contents

PUBLICATION DATE.................................................................................................................. V

CONTENTS ................................................................................................................................. VI

CHAPTER 1 OVERVIEW ........................................................................................................... 1

1.1 PURPOSE ........................................................................................................................... 2

1.2 APIS USED, AND FEATURE RANGE ........................................................................................ 3

1.3 EXTERNAL LIBRARY AND RESOURCES ................................................................................... 5

CHAPTER 2 SYSTEM CONSTRUCTION .................................................................................. 6

2.1 PRODUCTION ENVIRONMENT................................................................................................ 7

2.2 DEPLOYMENT ON TOMCAT ................................................................................................... 8

CHAPTER 3 FOLDER CONSTRUCTION ................................................................................ 11

3.1 FOLDER CONSTRUCTION ................................................................................................... 12

CHAPTER 4 SAMPLE PROGRAM VIEWS ............................................................................. 14

4.1 WINDOW CONFIGURATION ................................................................................................. 15

4.2 INDEX VIEW ...................................................................................................................... 16

4.3 DISPLAY VIEW ................................................................................................................... 17

4.4 INPUT / UPDATE VIEW ........................................................................................................ 19

4.5 ERROR DIALOG BOX VIEW .................................................................................................. 21

4.6 XBRL DOCUMENT VIEW .................................................................................................... 23

CHAPTER 5 PROCESSING FLOW OF THE SAMPLE PROGRAM ........................................ 25

5.1 PROCESSING FLOW ........................................................................................................... 26

CHAPTER 6 INSTANCE VIEW ................................................................................................ 27

6.1 OVERVIEW........................................................................................................................ 28

6.2 CREATING THE RENDERING RESULT MODEL ........................................................................ 29

6.3 CREATING HTML DATA TO BE SHOWN ON YOUR BROWSER ................................................. 30

6.4 EXPLANATION OF THE SAMPLE PROGRAM ........................................................................... 33

6.4.1 Creating objects needed to display the view (index.jsp / HTMLFormStartServlet.java)

33

6.4.2 Creating rendering result model (HTMLFormCreateServlet.java) ............................. 34

6.4.3 Creating HTML(HTMLFormCreateServlet.java) ........................................................ 35

6.4.4 Displaying the created HTML(HTMLFormCreateServlet.java) .................................. 36

6.4.5 Displaying error information ....................................................................................... 36

CHAPTER 7 UPDATING INPUT VALUES ............................................................................... 40

7.1 OVERVIEW........................................................................................................................ 41

Page 7: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

vii

7.2 PUTTING INPUT VALUES TO INSTANCE ................................................................................ 42

7.3 EXPLANATION OF THE SAMPLE PROGRAM ........................................................................... 44

7.3.1 Preparation for objects and processors used for updating

(HTMLFormUpdateServlet.java).................................................................................................... 44

7.3.2 Getting input values (parameters) (HTMLFormUpdateServlet.java) ......................... 44

7.3.3 Updating the instance contents using HTMLForm

processor(HTMLFormUpdateServlet.java) .................................................................................... 45

7.3.4 Saving the instance after updating(HTMLFormUpdateServlet.java) ......................... 46

7.3.5 Refreshing the view(HTMLFormUpdateServlet.java) ................................................ 46

CHAPTER 8 VALIDATING INSTANCE ................................................................................... 48

8.1 OVERVIEW........................................................................................................................ 49

8.2 VALIDATING INSTANCE USING FORMULA PROCESSOR .......................................................... 50

8.3 GETTING EVALUATION RESULTS IN THE FORMULA PROCESSOR ............................................ 52

8.4 EXPLANATION OF THE SAMPLE PROGRAM ........................................................................... 53

8.4.1 Preparation for objects and processors used for validation

(HTMLFormUpdateServlet.java# service method) ........................................................................ 53 8.4.2 Implementation of FormulaLinkResultHandler interface

(FormulaLinkResultHandlerImpl.java/FormulaLinkAssertionResultInfo.java) ............................... 53

8.4.3 Execution of the instance evaluation (HTMLFormUpdateServlet.java# validate

method) 56

8.4.4 Displaying the instance evaluation results and evaluation errors ............................. 56

CHAPTER 9 NOTES ................................................................................................................ 59

9.1 A NOTE FOR CREATING XBRL PROCESSOR OBJECT ............................................................ 60

Page 8: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface
Page 9: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 1 Overview

1

Chapter 1 Overview

Page 10: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 1 Overview

2

1.1 Purpose

By using the Interstage XWand HTMLForm processor and the Interstage XWand RenderingLink

processor, you can edit taxonomy / instance information in a way that you can easily understand it

visually. This enables you to develop web applications, where you can view / edit / (formula)

evaluate instances concurrently on the web browsers.

In this document, we introduce the API that enables the capability written above, by walking

through the sample program that performs viewing / editing / (formula) evaluation of XBRL

instances.

Page 11: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 1 Overview

3

1.2 APIs used, and feature range

The sample program is used in the Interstage XWand APIs shown below.

The Interstage XWand HTMLForm processor and Interstage XWand RenderingLink processor

that are used in Interstage XWand WebForm are used together with the Interstage XWand XBRL

processor.

The Interstage XWand Formula processor used for evaluation of the input values is also used in

the sample program. Each processor is related as shown in the figure below.

Table 1.1Explanation of the external libraries

External library Description

Interstage XWand HTMLForm

processor

- Viewing instances / creating and editing HTML data on your web

browser

- Updating instances

Interstage XWand RenderingLink

processor

- Creating rendering result models - with which you can handle

taxonomy information visually

Interstage XWand Formula processor - Instance validation based on Formula definitions

Interstage XWand XBRL processor - Creating instances / validating instances based on XBRL

specifications

- Saving instances

Interstage XWand Formula

processor

Interstage XWand XBRL processor

Interstage XWand HTMLForm

processor

Interstage XWand RenderingLink

processor

Figure 1.1Structure of the API used

Page 12: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 1 Overview

4

Page 13: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 1 Overview

5

1.3 External library and resources

The relation between the external library and resources is as follows:

The terminology used here is as follows:

Table 1.2 Explanation of the terminology used

Terminology Description

Rendering link file Rendering definition information of taxonomy

Rendering result model: the rendering link data model built with the

RenderingLink Library

HTML data HTML document containing the loaded instance and the rendering result

model in the form tag.

Template file Template HTML documents used for input and display views.

input output

Rendering link

file

Template file

Taxonomy file

Template

instance file

Instance

(Rendering result model)

(Instance)

HTML data

Interstage

XWand XBRL

processor

Interstage

XWand Formula

processor

Interstage

XWand

Rendering

processor

Interstage

HTML Form

processor

Figure 1.2 Relation between the external library and resources

Page 14: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 2 System construction

6

Chapter 2 System construction

Page 15: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 2 System construction

7

2.1 Production environment

One of the following software types is required in order to use Interstage XWand WebForm:

・Eclipse 3.6 or later (JDK1.5 or higher)

It has also been confirmed that Interstage XWand WebForm can run on the following application

servers:

・Tomcat 5.5.33

The explanations in this document assume that each application server has already been

installed. Refer to the guide for each product for information on how to install the application

server.

Page 16: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 2 System construction

8

2.2 Deployment on Tomcat

To run this sample program on Tomcat, configure the following settings for Tomcat:

1. Deploy the sample project files to the webapps folder under the Tomcat installation folder

2. Copy the following XBRL2.1 processor Java library from the folder where the Interstage

XWand Application Developer is setup to the WEB-INF¥lib folder.

formulaproc.jar

xbrl-function.jar

xbrldimensions.jar

xmlpath2.jar

xmlpath2fn.jar

xmlpro.jar

xmlschema.jar

xmlschemac.jar

xmltrans.jar

xmltransx.jar

xwand-common.jar

xwand.jar

xwandlink.jar

xwandschema.jar

xwand_xpath2.jar

3. Add the following line to the <Host> tag of conf\server.xml under the Tomcat installation

folder

The tags and attributes that are used are shown below.

Table 2.1 Explanation of the tags and attributes that are added in server.xml

Tag/attribute Description

Context Context setting for Web application unit that runs on Tomcat

path Virtual directory name that is referenced in the browser

reloadable Tomcat restart setting for when the servlet class file has been

updated

true=enabled, no attribute/false=disabled

docBase Name of the folder that the Web application files are deployed to

workDir Name of folder used by Tomcat temporarily

<Context path="/<sample project context name>" reloadable="true" docBase="<Tomcat

installation path>¥webapps¥<sample project folder name>" workDir="<Tomcat installation path>

¥webapps¥<sample project folder name>¥work" />

Page 17: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 2 System construction

9

4. Use the browser to access as follows:

http://localhost:<port number>/<sample project context name that was added in 3>

Page 18: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 2 System construction

10

Page 19: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 3 Folder construction

11

Chapter 3 Folder construction

Page 20: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 3 Folder construction

12

3.1 Folder construction

The folder structure shown below will be required when this sample program is executed. For

deployment of the WAR files on Tomcat and creation of the WAR files, use the folder structure

shown below when creating the WAR files.

* Under the "data" folder, located are files that are used in the sample program. The sp refers to

the files under the "data" folder, and it assumes the folder structure is fixed as such. Therefore

you cannot change the folder names.

* The XBRL2.1 processor library is not in the sample folder. Copy it from the folder where the

Interstage XWand Application Developer is setup.

Figure 3.1 Folder structure

WebForm_Sample

│ index.jsp

├─data

│ ├─data_work …Folder used for work (output) │ ├─formula …Formula validation taxonomy file folder │ │ assertion-formula.xml

│ │ assertion.xsd

│ │ role-validationmessage.xsd

│ ├─ins …Processing target instance file folder │ │ └─Sample

│ │ instance-value.xml

│ │ instance.xml

│ ├─ren …Rendering taxonomy file folder | | rendering-linkbase_fj.xsd

| | rendering-roles_fj.xsd

│ │ Sample_mod-rendering.xml

│ │ Sample_mod-rendering.xsd

│ │ Sample_mod-rendering_view.xml

│ │ Sample_mod-rendering_view.xsd

│ ├─tax …Basic taxonomy file folder │ │ └─Sample

│ │ dimension-sample-definition.xml

│ │ dimension-sample-label.xml

│ │ dimension-sample.xsd

│ └─template_html …Template HTML file folder │ template_html.xml

│ template_html_view.xml

├─WEB-INF

│ web.xml

├─classes

├─lib … Library folder │ rendering-std.jar … Interstage XWand RenderingLink processor │ xwandhtmlform.jar … Interstage XWand HTMLForm processor │ formulaproc.jar … Interstage XWand XBRL 2.1 complete processor set │ xbrl-function.jar

│ xbrldimensions.jar

│ xmlpath2.jar

Page 21: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 3 Folder construction

13

│ xmlpath2fn.jar

│ xmlpro.jar

│ xmlschema.jar

│ xmlschemac.jar

│ xmltrans.jar

│ xmltransx.jar

│ xwand-common.jar

│ xwand.jar

│ xwandlink.jar

│ xwandschema.jar

│ xwand_xpath2.jar

└─src … Program folder └─sampleApp

FormulaLinkAssertionResultInfo.java

FormulaLinkErrorHandlerImpl.java

FormulaLinkResultHandlerImpl.java

HTMLFormCreateServlet.java

HTMLFormStartServlet.java

HTMLFormUpdateServlet.java

SampleFormulaEntityResolver.java

SampleXBRLEntityResolver.java

SampleXBRLErrorHandler.java

Utilities.java

Page 22: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 4 Sample program views

14

Chapter 4 Sample program views

Page 23: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

第 1 部 Chapter 4

15

4.1 Window configuration

The views that this sample program shows are as follows:

Index view

Display view

Input / update view

|-Error dialog box view

XBRL document view

Page 24: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 4 Sample program views

16

4.2 Index view

Figure 4.1 user selects either the input or update view

Table 4.1Explanation of the window items

Number Item Description

1 View Instance link Moving to the display view

2 Edit Instance link Moving to the input / update view

Note: As the XBRL instances for the "View Instance link" and "Edit Instance link" are different, it

is not possible to view the results of the "Edit Instance link" in the "View Instance link".

① ②

Page 25: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

第 1 部 Chapter 4

17

4.3 Display view

Figure 4.2 displaying an instance

Table 4.2Explanation of the window items

Number Item Description

1 Table Displays the loaded instance based on the rendering link result

model definition

Page 26: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 4 Sample program views

18

Page 27: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

第 1 部 Chapter 4

19

4.4 Input / update view

Figure 4.3 lets user edit the instance

Table 4.3Explanation of the window items

Number Item Description

1 "SAVE" button Performs XBRL and Formula validation, updates the instance, and

save the file.

-> If errors are detected in the validation, the view will move to the

error dialog box view.

2 show raw XBRL

Instance link

Moving to the XBRL document view

3 Table Displays the loaded instance based on the rendering link result

model definition

4 Input form Text fields to be filled with instance values

① ②

Page 28: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 4 Sample program views

20

Page 29: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

第 1 部 Chapter 4

21

4.5 Error dialog box view

Figure 4.4 shows information of errors detected in XBRL or Formula validation

(Refer to Chapter 8, "Validating instance" for information on the Formula definition.)

Table 4.4 Explanation of the window items

Number Item Description

1 Error dialog box Shows error information

2 "OK" button Click the "OK" button to close the error dialog box.

3 Input form Paints in pink the background color of the erroneous parts.

Page 30: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 4 Sample program views

22

Page 31: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

第 1 部 Chapter 4

23

4.6 XBRL document view

Figure 4.5 shows the XBRL document in an XML file format

Page 32: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 4 Sample program views

24

Page 33: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 5 Processing flow of the sample program

25

Chapter 5 Processing flow of the sample

program

Page 34: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 5 Processing flow of the sample program

26

5.1 Processing flow

The processing flow of the sample program is as follows:

[Flow for viewing]

(1) The index window (index.jsp) is accessed from the browser.

(2) The content to be displayed in the window (instance/rendering schema/validation

schema/template HTML file) is selected from the index window. (Note)

(3) The instance file to be displayed in the window is loaded, and each processor is created.

(4) Transition to HTMLFormCreateServlet.

(5) The instance content is displayed in the window using the instances that were prepared in (3)

and the various processors.

[Flow for saving]

(1)' When the "save" button is clicked from the browser, transition to HTMLFormUpdateServlet

occurs.

(2)' The instance is updated to the value entered in the browser. At this time, an input check and

a validation check of the input content is performed.

(3)' If no problems are detected in the input check and the validation check of the input content in

(2)', the instance content after the update is saved in the file.

(4)' Transition to HTMLFormCreateServlet.

(5)' The instance content after the update is displayed in the window. If an error occurs in (3)',

the error content is displayed at this time.

Note: Switching the reference window and the input form

This can be realized by preparing the rendering schema file and the template HTML file when

switching the reference window and the input form

Application Server index.jsp (Initial view)

HTMLFormStartServlet.java (Preparation for view)

HTMLFormCreateServlet.java (Shows view)

HTMLFormUpdateServlet.java (Updates / Validation)

Instance

(1)

(2)(3)

(4)(5)

(1)’ (2)’ (3)’

(4)’

browser (Top Page)

browser (Input form)

Flow for viewing

Flow for saving

(5)’

Figure 5.1 Processing flow of the sample program

Page 35: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

27

Chapter 6 Instance view

Page 36: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

28

6.1 Overview

The application creates HTML data using HTMLForm processor, in order to show the instance

content on your browser.

The HTML data to be shown on your browser is made out of the rendering result model (using

XWand Rendering Library) and the template file.

Page 37: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

29

6.2 Creating the rendering result model

The application uses HTMLForm processor to create the rendering result model

(XBRLStaticRenderingModel).

The rendering result model is made out of the taxonomy files (containing the rendering files) and

the instance file.

The created rendering result model will be used for inserting data into the HTML data explained in

the next subsection.

The following is an example of the said processing

// Create the rendering model factory XBRLRenderingModelFactory rmf = new XBRLRenderingModelFactory();

// Create the XBRL processor to enable Rendering Link processing XBRLProcessor xbrlProc = new XBRLProcessor();

xbrlProc.setProperty("http://www.fujitsu.com/xml/xwand/process-generic-linkbase","yes");

// Obtain the taxonomy that contains the rendering link File renderingFile =

new File("/taxonomy/Folder/Path", "rendaringTaxonomyFile.xsd");

TaxonomySet renderingTaxSet =

xbrlProc.loadTaxonomySet(new StreamSource(renderingFile.getAbsolutePath()));

// Obtain the instance that connects to the rendering result model File instanceFile = new File("/instance/Folder/Path", "instanceFile.xml");

Instance ins = xbrlProc.loadInstance(new StreamSource(instanceFile.getAbsolutePath()));

// Create the rendering result model XBRLStaticRenderingModel rm = rmf.createStaticRenderingModel(ins, renderingTaxSet);

Page 38: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

30

6.3 Creating HTML data to be shown on your

browser

HTML data is created using HTMLForm processor.

The application sets to HTMLForm processor the rendering result model (created in the last

subsection) and the HTML template file. The application outputs the HTML data.

The rendering result model content is added to the specified element from the HTML defined in

the template HTML file.

The following is an example of the said processing.

// Generate the HTMLForm processor // The rendering result model (XBRLStaticRenderingModel) that is output to the HTML is set in the argument HTMLFormProcessor formProc = new HTMLFormProcessor(rm);

// Load the template HTML File templateHtmlFile = new File("/template/Folder/Path", "templateHTMLFile.xml");

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

dbf.setNamespaceAware(true);

DocumentBuilder db = dbf.newDocumentBuilder();

Document html = db.parse(templateHtmlFile);

// Obtain the HTMLForm parent HTML element to be added Element parentElem = (Element) html.getElementsByTagName("form").item(0);

// HTML data creation processing (the rendering result model content is added under the form element) // The form data created from the rendering result model is added to the html object

HTMLFormProcessor

XBRLStaticRenderingModel

<HTML>

:

<form>

</form>

:

</HTML> Specify <form> as

the destination.

The HTML data is created

<HTML>

:

<form>

[HTML created out of XBRLStaticRenderingModel]

</form>

:

Figure 6.1 Flow for the creation of HTML data

Page 39: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

31

formProc.createHtmlForm(parentElem);

Page 40: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

32

Page 41: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

33

6.4 Explanation of the sample program

In this subsection, we will explain the flow of creating from an instance file an HTML data to be

shown on your browser.

In the sample program, we will create an HTML data with the following steps:

1. Creating objects needed to display the view

2. Creating rendering result model

3. Creating HTML

4. Displaying the created HTML

5. Displaying error information

6.4.1 Creating objects needed to display the view (index.jsp /

HTMLFormStartServlet.java)

We prepare objects and processors (of the instance etc.) in order to construct the display view.

From index.jsp, we set the instance and taxonomy files etc. to HTMLFormStartServlet and POST

them using the following parameters.

Table 6.1 Explanation of the parameters

Parameter name Description

folderName Name of the folder that is located under "[docBase]/data/ins" folder

and where the instance file is stored.

instanceFile Filename of the instance for viewing that is located under

"[docBase]/data/ins/[folderName]" folder.

renderingTaxFile Name of the taxonomy file for rendering that is located under

"[docBase]/data/tax" folder.

formulaTaxFile Name of the taxonomy file for formula validation that is located

under "[docBase]/data/formula" folder.

templateHTMLFile Name of the template file for outputting HTML that is located under

"[docBase]/data/formula" folder.

<index.jsp>

<a

href="./servlet/start?folderName=Sample&instanceFile=instance-value.xml&renderingTaxFile=Samp

le_mod-rendering.xsd&formulaTaxFile=assertion.xsd&templateHTMLFile=template_html.xml"

target="child">Edit Instance</a><br/>

HTMLFormStartServlet receives parameters written above and creates the following objects and

processors. For the details of creation, refer to HTMLFormStartServlet.java source code.

- Object of the instance that you want to view

- Template file object

Page 42: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

34

- Taxonomy object used for rendering

- XBRL processor

- Formula processor used for validation

The program sets these objects and processors to the session and moves the processing to

HTMLFormCreateServlet.

Attribute names of the objects, processors, and the session are the following:

Table 6.2 Explanation of the sessions

Session content Session attribute name

Instance object __ins

Template file object __template

Taxonomy set object containing rendering link __ren

XBRL processor __xbrlProc

Formula processor __formulaProc

6.4.2 Creating rendering result model

(HTMLFormCreateServlet.java)

We explain here how to create a rendering result model which is used for inserting data to the

HTML you are going to display.

Obtain the following objects required in order to create the rendering result model from the

session:

- Instance object

- Taxonomy set object including rendering link

Use the RenderingLink processor to generate the rendering result model

(XBRLStaticRenderingModel) from the instance object and taxonomy set object that were

obtained above.

// Obtain processing target instance Instance ins = (Instance) request.getSession().getAttribute("__ins");

// Obtain the rendering link TaxonomySet from the session TaxonomySet renderingTaxSet = (TaxonomySet) request.getSession().getAttribute("__ren");

// Generate the rendering link result model XBRLRenderingModelFactory rmf = new XBRLRenderingModelFactory();

XBRLStaticRenderingModel rm = rmf.createStaticRenderingModel(ins, renderingTaxSet);

Page 43: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

35

6.4.3 Creating HTML(HTMLFormCreateServlet.java)

This section explains how to add the rendering result model content that was created in the

previous section to the HTML form tag defined in the template HTML file using the HTMLForm

processor.

With HTMLFormStartServlet, we get the following objects set to the session.

- Template file object

Obtain the add destination form element object of the rendering link result model that was created

in the previous section from the template HTML file object that was obtained above.

// Gets template HTML file

// Gets template HTML file object from the session

File templateHtmlFile = (File) request.getSession().getAttribute("__template");

// Creates Document object of the template HTML file

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

dbf.setNamespaceAware(true);

DocumentBuilder db = dbf.newDocumentBuilder();

Document html = db.parse(templateHtmlFile);

// Gets HTML element that is to be parent of HTMLForm now we are going to add

Element parentElem = (Element) html.getElementsByTagName("form").item(0);

With the rendering result model as the argument, create the HTMLForm processor. Since this will

be used in post-processing (Refer to Section 7.3.1, "Preparation for objects and processors used

for updating" for details), store it in the "__formProc" attribute for the session.

The addition of the rendering result model is performed in the createHtmlForm method of the

HTMLForm processor that was created.

// Creates HTMLForm processor

HTMLFormProcessor formProc = new HTMLFormProcessor(rm);

// Sets HTMLForm processor to the session

request.getSession().setAttribute("__formProc", formProc);

// HTML data creation processing (the rendering result model content is added under the form element) // The form data created from the rendering result model is added to the html object formProc.createHtmlForm(parentElem);

[Information] Extension of input form

You can extend the input forms in your own way like splitting the date input field into three: year / month /

day.

For extending input forms, inherit the class (DefaultHTMLFormCreaterHandler) of HTMLForm processor

Page 44: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

36

and implement it.

public class HTMLFormCreaterHandlerExtends extends DefaultHTMLFormCreaterHandler {

public HTMLFormCreaterHandlerExtends() {

super();

}

public Element processFactField(Element parentHtmlElem,

FactField field,

Map parameters)

throws HTMLFormProcessorException {

}

}

We set the created extension class to HTMLForm processor.

HTMLFormProcessor formProc = new HTMLFormProcessor(model);

formProc.setHTMLFrmreaterHandler(new HTMLFormCreaterHadlerExtends());

6.4.4 Displaying the created

HTML(HTMLFormCreateServlet.java)

We explain here how to show the HTML data created previously on your browser.

The result of HTMLForm processor is set to the Document object created by the template HTML

file object.

We get the HTML for browser view from the Document object.

// Outputs HTML

TransformerFactory tf = TransformerFactory.newInstance();

Transformer t = tf.newTransformer();

// Since the template HTML file is defined using UTF-8, use the same encoding for the output response.setContentType("text/html;charset=UTF-8");

// Display the html that was added using the HTMLForm processor in the window t.transform(new DOMSource(html), new StreamResult(response.getWriter()));

6.4.5 Displaying error information

We explain here how to display error information when errors occur in the update processing.

In this sample program, we pop-up the error information with a dialog box and change the

background color of the corresponding input forms into pink.

Page 45: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

37

If an error has occurred in update processing (HTMLFormUpdateServlet), the list array for the

HTMLFormDataException containing the error information will be stored in the session "__errors"

attribute.

Error notification processing will be performed when a window display error exists in the

"__errors" attribute.

// Gets input exception

HTMLFormDataException[] errors =

(HTMLFormDataException[])request.getAttribute("__errors");

if (errors == null || errors.length == 0) {

// If display is for the first time or there is no input error

// Creates HTMLForm (adds HTMLForm under the element)

formProc.createHtmlForm(parentElem);

} else {

// If there are any input errors

// Gets request parameters

request.setCharacterEncoding("UTF-8");

Map parameters = request.getParameterMap();

// Creates HTMLForm (adds HTMLForm under the element)

// If there is an input error, pass the request parameters through the argument in order to

reproduce the situation of the input error

formProc.createHtmlForm(parentElem, parameters);

// Adds the error information to HTML

addErrorInfo(html, errors);

}

In the addErrorInfo method that adds the error content to the HTML data, the error message and

input field name are obtained from HTMLFormDataException that is stored in the error information.

Additionally, the message display and error item input field background colors have been changed

to pink, and processing that moves the focus has been added.

/**

* Adds instance update error information to HTMLForm

* - Puts red marks to input forms with errors

* - Shows error messages to a dialog box

* @param html HTML DOM object

* @param errors Error information about instance update

*/

void addErrorInfo(Document html, HTMLFormDataException[] errors) {

// Gets body tag

Element bodyElem = (Element)html.getElementsByTagName("body").item(0);

// Gets 'name' attribute value of form tag

Page 46: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

38

String formName =

((Element)html.getElementsByTagName("form").item(0)).getAttribute("name");

// Script of error handling

StringBuffer script = new StringBuffer();

// Moves the focus to the error input field

if (errors.length > 0) {

HTMLFormDataException ex = (HTMLFormDataException)errors[0];

if (ex.getFieldNames().length > 0) {

script.append(formName);

script.append(".");

script.append(ex.getFieldNames()[0]); // Obtain the name of the field in which the input error occurred script.append(".focus();");

}

}

// Paints in pink the error input fields

// Edits error messages

StringBuffer message = new StringBuffer();

for (int i=0; i< errors.length; i++) {

HTMLFormDataException ex = (HTMLFormDataException)errors[i];

for (int j = 0, n = ex.getFieldNames().length; j < n; j++) {

script.append(formName);

script.append(".");

script.append(ex.getFieldNames()[j]); // Obtain the name of the field in which the input error occurred script.append(".style.background='pink';");

}

message.append("*");

message.append(i);

message.append("* : input error{");

message.append(ex.getMessage()); // Obtain the error message message.append("}\\n");

}

// Shows error messages

script.append("alert('");

script.append(jsEscape(message.toString()));

script.append("');");

// Sets the error message to the 'onload' event of the body tag

bodyElem.setAttribute("onload", script.toString());

}

Page 47: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 6 Instance view

39

Page 48: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

40

Chapter 7 Updating input values

Page 49: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

41

7.1 Overview

Use updateHtmlForm() of HTMLForm processor when you want to put the form values to

your instance.

Page 50: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

42

7.2 Putting input values to instance

Using getParameterMap() of HttpServletRequest class, you can get the input field values on the

HTML form created in the previous section.

Using HTMLForm processor created in the previous section, we put input values in the form to the

instance.

To do this, we set the Map object obtained with getParameterMap() to the argument of

updateHtmlForm() of HTMLForm processor.

The updated instance is the one associated with the rendering result model passed as an

argument when creating HTMLForm processor.

If there is an instance update error with updateHtmlForm(), HTMLFormUpdateInstanceException is

thrown.

Input exception information (HTMLFormDataException) is stored in

HTMLFormUpdateInstanceException. You can get the information with getUpdateErrors().

gets input parameter a:test1 -> 1000 a:test2 -> 2000

<XBRL>

:

<a:test1 context=’..’> 100 </a:test1>

<a:test2 context=’..’> 200 </a:test2>

:

</XBRL>

HTMLForm processor

<XBRL>

:

<a:test1 context=’..’> 1000 </a:test1>

<a:test2 context=’..’> 2000 </a:test2>

:

</XBRL>

Test1

b

a 1000

Test2

2000

updateHtmlForm method

Item corresponding to

a:test1 -> changes from

100 to 1000

Item corresponding to

a:test2 -> changes from

200 to 2000

instance

instance

browser

In the sample program, a scale of 0 is set for the rendering link,

therefore the input value is set as it is.

Fig 7.1 Processing flow for instance reflection

Page 51: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

43

In the example shown below, we show how to put input values to the instance.

For the process of up to creating HTML processor, refer to the previous section.

protected void service(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

// Gets taxonomy including rendering link

TaxonomySet renderingTaxSet = xbrlProc.loadTaxonomySet(...);

// Gets instance connecting to rendering result model

Instance ins = xbrlProc.loadInstance(...);

// Creates rendering result model

XBRLStaticRenderingModel rm = rmf.createStaticRenderingModel(ins, renderingTaxSet);

// HTMLForm processorを create

HTMLFormProcessor formProc = this.createXBRLFormProcessor(rm);

// Gets request parameters

request.setCharacterEncoding("UTF-8");

Map parameters = request.getParameterMap();

try {

// Updates instance with the obtained parameter

formProc.updateHtmlForm(parameters);

} catch (HTMLFormUpdateInstanceException updateEx) {

// Gets input exception

HTMLFormDataException[] errors = updateEx.getUpdateErrors();

}

}

Page 52: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

44

7.3 Explanation of the sample program

We explain here, with the sample program, the flow of updating the instance with the input values

and then of saving and showing the instance.

The processing sequence is as follows:

1. Preparation for objects and processors used for updating

2. Getting input values (parameters)

3. Updating the contents using HTMLForm processor

4. Saving the instance after updating

5. Refreshing the view

7.3.1 Preparation for objects and processors used for

updating (HTMLFormUpdateServlet.java)

We prepare objects and processors used for updating the instance.

Obtain the following objects and processors required for update processing from the session:

- Instance object

- XBRL processor

- HTMLForm processor

// Gets instance

Instance ins = (Instance) request.getSession().getAttribute("__ins");

// Gets XBRL processor

XBRLProcessor xbrlProc =

(XBRLProcessor) request.getSession().getAttribute("__xbrlProc");

// Gets HTMLForm processor

HTMLFormProcessor formProc =

(HTMLFormProcessor) request.getSession().getAttribute("__formProc");

7.3.2 Getting input values (parameters)

(HTMLFormUpdateServlet.java)

We explain here how to get input values on the form.

The input value is set as parameter of HttpServletRequest. We get it using getParameterMap().

// Gets request parameters

// Display the UTF-8 encoding code in the browser request.setCharacterEncoding("UTF-8");

Page 53: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

45

Map parameters = request.getParameterMap();

7.3.3 Updating the instance contents using HTMLForm

processor(HTMLFormUpdateServlet.java)

We update the instance connected to the rendering result model obtained in the subsection 1 -

with the parameter Map object obtained in the subsection 2.

We update the instance with updateHtmlForm() of HTMLForm processor.

When there is an instance update error, HTMLFormUpdateInstanceException is thrown.

We get error information (HTMLFormDataException) as a list in the case of

HTMLFormUpdateInstanceException. We set the error information to the session as ”__errors”

parameter attribute value in order to show the error information.

try {

// Updates HTMLForm

// Set the Map object containing the values input from the browser in the argument formProc.updateHtmlForm(parameters);

} catch (HTMLFormUpdateInstanceException updateEx) {

// Gets input error

// Gets input exception

HTMLFormDataException[] errors = updateEx.getUpdateErrors();

// Adds input exception to the request

request.setAttribute("__errors", errors);

}

[Information] Getting input values with an extended form

When you get input values of the form you extended in your own way (in the previous section), inherit

the HTMLForm library class (DefaultHTMLFormCreaterHandler) and implement it

public class HTMLFormUpdaterHandlerExtends extends DefaultHTMLFormUpdaterHandler {

public HTMLFormUpdaterHandlerExtends() {

super();

}

public String getFieldValue(StaticElement elem,

Map parameters,

String name)

throws HTMLFormDataException {

..

return super.getFieldValue(elem, parameters, name);

}

..

}

Set the created extension class when creating HTMLForm processor.

HTMLFormProcessor formProc = new HTMLFormProcessor(model);

formProc.setHTMLFormUpdaterHandler(new HTMLFormUpdaterHandlerExtends());

Page 54: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

46

7.3.4 Saving the instance after

updating(HTMLFormUpdateServlet.java)

We explain here how to save to the file the instance that we updated in the previous subsection.

To do this, use XBRLProcessor like the following.

The destination of the file saving is the instance file used in creating the instance object in the

previous section.

// Saves instance

Transformer trans = (Transformer) xbrlProc.getProperty(XBRLProperties.TRANSFORMER);

trans.setOutputProperty(OutputKeys.INDENT, "yes");

// Using the Instance.getSystemId() method, obtain the full path of the instance file that was // used when the instance object was created xbrlProc.saveInstance(ins, new StreamResult(ins.getSystemId()));

7.3.5 Refreshing the view(HTMLFormUpdateServlet.java)

We explain here how to refresh the view with the updated instance content.

The updated instance (in subsection 3) is always held in the session. So you do not have to keep

newly the updated instance in the session.

The program moves to HTMLFormCreateServlet, where mapping is performed with

/servlet/create to show the updated instance on the view.

// Sends forward again to show the input view

RequestDispatcher rd = this.getServletContext().getRequestDispatcher("/servlet/create");

rd.forward(request, response);

Page 55: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 7 Updating input values

47

Page 56: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

48

Chapter 8 Validating instance

Page 57: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

49

8.1 Overview

We can perform validation of the updated instance using Formula processor.

In the sample program, we do this using ValueAssersion.

Page 58: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

50

8.2 Validating instance using Formula processor

We prepare a Formula file. This is ”assertion-formula.xml” in the sample program.

In the sample program, we create the following formulae using ValueAssersion.

We define a variable for each encircled part and we check the validity with the following

expression:

$totalValue = $hwValue + $swValue + $consultantValue

In the sample program, the initial state is like the view shown above. When you perform a

validation with this status you will have an error:

400($totalValue) = 100 ($hwValue) + 200($swValue) + 300($consultantValue)

the evaluation result is: 400 != 600

After changing input values to the following, they will be verified as OK.

600($totalValue) = 100 ($hwValue) + 200($swValue) + 300($consultantValue)

We create a processor for executing the given formulae.

First, we create an XBRL processor and then add functions needed to perform formula

processing.

To do this, we use setUpXBRLProcessor() of FormulaLinkProcessorFactory class.

// Creates an XBRL processor

XBRLProcessor xbrlProc = new XBRLProcessor();

// Sets to XBRLProcessor the needed functions for formula processing.

FormulaLinkProcessorFactory.setUpXBRLProcessor(xbrlProc);

Next, we create a formula processor.

Getting the taxonomy file referring to the Formula link, we create a formula processor.

In order to get formula evaluation results, we implement the FormulaLinkResultHandler interface

and set it to the said formula processor. The implementation of FormulaLinkResultHandler

interface will be explained in the next subsection.

Using validate() of the formula processor, we evaluate the instance.

$totalValue $hwValue

$swValue

$consultantValue

Page 59: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

51

Shown below is the creation of a formula processor and the validation.

// Creates a factory for formula processor

FormulaLinkProcessorFactory factory = FormulaLinkProcessorFactory.newInstance();

// Gets TaxonomySet containing the formula linkbase

File formulaFile = new File("/formula/folder/path", "formulaTaxFile.xsd");

TaxonomySet formulaTaxSet =

xbrlProc.loadTaxonomySet(new StreamSource(formulaFile.getAbsolutePath()));

// Formula processorの create

FormulaLinkProcessor formulaProc = factory.createFormulaLinkProcessor(formulaTaxSet);

// Class settings receiving validation results

FormulaLinkResultHandlerImpl formulaResultHandler = new FormulaLinkResultHandlerImpl();

formulaProc.setResultHandler(formulaResultHandler);

// Validates instance

formulaProc.validate(instance, null, null);

Page 60: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

52

8.3 Getting evaluation results in the formula

processor

Using FormulaLinkResultHandler interface, you can receive formula processor evaluation results.

You need to implement the following methods in implementing FormulaLinkResultHandler

interface.

- assertionResult(boolean result, AssertionContext assertionContext)

... gets assertion results.

- assertionFinalResult(boolean result)

... gets all the assertion results.

- formulaResult(com.fujitsu.xml.xbrl.xwand.instance.Item fact, FormulaContext formulaContext)

... gets formula evaluation results.

- formulaFinalResult(com.fujitsu.xml.xbrl.xwand.instance.Instance instance)

... gets all the formula evaluation results.

For more details of the implementation, refer to the Formula API reference.

Page 61: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

53

8.4 Explanation of the sample program

We explain here, with the sample program, how to perform validations for the input values in the

updated instance.

To do this, we use validate() of HTMLFormUpdateServlet class.

The processing sequence is as follows:

1. Preparation for objects and processors used for validation

2. Implementation of FormulaLinkResultHandler interface

3. Execution of the instance evaluation

4. Obtaining of the instance evaluation results and evaluation errors

8.4.1 Preparation for objects and processors used for

validation (HTMLFormUpdateServlet.java# service

method)

We prepare objects and processors used for validation.

Obtain the following processors required for instance evaluation from the session:

- Formula processor

// Gets formula processor

FormulaLinkProcessor formulaProc = (FormulaLinkProcessor)

request.getSession().getAttribute("__formulaProc");

We use the updated instance (explained in the previous section) for the validation.

8.4.2 Implementation of FormulaLinkResultHandler interface

(FormulaLinkResultHandlerImpl.java/FormulaLinkAsse

rtionResultInfo.java)

We explain here how to implement FormulaLinkResultHandler interface for receiving evaluation

results in the formula processor.

In order to receive the validation evaluation results using the Formula processor that is required in

step 4. create the class that implements the FormulaLinkResultHandler interface.

Page 62: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

54

In the sample program, we receive ValueAssersion evaluation results in assertionResult() and get

UserElement related with message and assertion in case of errors.

Obtained message and UserElement are stored in FormulaLinkAssertionResultInfo class and

registered in ArrayList.

Using getFaildAssertionContextInfo(), you can get the registered ArrayList.

FormulaLinkAssertionResultInfo.java /**

* The class used for storing formula assertion results

*/

public class FormulaLinkAssertionResultInfo {

private String message;

private ArrayList userElementList = new ArrayList();

/**

* Gets assertion message

* @return assertion message

*/

*/

public String getMessage() {

return message;

}

/**

* Sets assertion message

* @param message assertion message

*/

public void setMessage(String message) {

this.message = message;

}

/**

* Gets a UserElement list related with the assertion.

* @return UserElement list related with the assertion

*/

public ArrayList getUserElementList() {

return userElementList;

}

/**

* Sets a UserElement list related with the assertion.

* @param userElementList UserElement list related with the assertion

*/

public void setUserElementList(ArrayList userElementList) {

this.userElementList.clear();

if (userElementList == null) {

return;

}

for (Iterator iterator = userElementList.iterator(); iterator.hasNext();) {

Object object = (Object) iterator.next();

if (object instanceof UserElement) {

UserElement userElement = (UserElement) object;

this.userElementList.add(userElement);

}

Page 63: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

55

}

}

}

FormulaLinkResultHandlerImpl.java /**

* Implementation of FormulaLinkResultHandler class

* - Outputs to the standard output the evaluation result notified by FormulaLink processor.

* - Stores failed assertion result information.

*/

public class FormulaLinkResultHandlerImpl implements FormulaLinkResultHandler {

// Failed assertion result information

private ArrayList assetionContextInfoList = new ArrayList();

/**

* Gets assertion results. <br/><br/>

*

* Outputs to standard output the assertion result information. <br/>

* Stores failed assertion result information. <br/>

* You can get the stored result information using getFaildAssertionContextInfo().

*

* @param result evaluation result (boolean)

* @param assertionContext assertion result information

*/

public void assertionResult(boolean result, AssertionContext assertionContext) {

if (!result) {

FormulaLinkAssertionResultInfo resultInfo = new FormulaLinkAssertionResultInfo();

// Sets assertion description to the evaluation information

String message =

assertionContext.getResourceInformation().getGenericLabelAsString(null, null, null);

resultInfo.setMessage(message);

// Gets UserElement related with assertion

// ConsistencyAssertion, ExistenceAssertion are not suppored

ArrayList failedUserElementList = resultInfo.getUserElementList();

short assertionType = assertionContext.getAssertionType();

if (assertionType == ResourceInformation.RESOURCE_TYPE_VALUE_ASSERTION) {

BoundVariable[] bvs =

((ValueAssertionContext) assertionContext).getBoundVariables();

for (int j = 0, nn = bvs.length; j < nn; j++) {

BoundVariable bv = bvs[j];

int boundSize = bv.getBoundSize();

for (int k = 0; k < boundSize; k++) {

Object value = bv.getValue(k);

if (value instanceof UserElement) {

failedUserElementList.add(value);

}

}

}

}

assetionContextInfoList.add(resultInfo);

}

}

Page 64: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

56

/**

* Returns a list of failed assertion result information (FormulaLinkAssertionResultInfo).

*

* @return list of failed assertion result information (FormulaLinkAssertionResultInfo)

*/

public List getFaildAssertionContextInfo() {

return assetionContextInfoList;

}

/**

* Clears the list of failed assertion result information (FormulaLinkAssertionResultInfo).

*/

public void clearFaildAssertionContextInfo() {

assetionContextInfoList.clear();

}

}

We set the created class to the formula processor.

FormulaLinkResultHandlerImpl formulaResultHandler = new FormulaLinkResultHandlerImpl();

formulaProc.setResultHandler(formulaResultHandler);

8.4.3 Execution of the instance evaluation

(HTMLFormUpdateServlet.java# validate method)

We explain here how to perform formula validations for the updated instance.

To do this, use validate() of the formula processor.

// Performs input instance validation

formulaProc.validate(input_ins, null, null);

8.4.4 Displaying the instance evaluation results and

evaluation errors

We explain here how to get evaluation results in the formula processor.

Using the implemented class of FormulaLinkResultHandler interface (as explained in subsection

2), we get evaluation results.

In this sample program, we get result information (FormulaLinkAssertionResultInfo) and create

error information (HTMLFormDataException) for showing on the form.

The error information is stored as an array in HTMLFormUpdateInstanceException, and is notified

in service() by throwing, which is the caller of the processing.

// Creates error information of failed assertions

List failedContextInfoList = formulaResultHandler.getFaildAssertionContextInfo();

if (failedContextInfoList != null && failedContextInfoList.size() > 0) {

int failCount = failedContextInfoList.size();

Page 65: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

57

HTMLFormDataException[] errors = new HTMLFormDataException[failCount];

for (int i = 0; i < failCount; i++) {

FormulaLinkAssertionResultInfo contextInfo =

(FormulaLinkAssertionResultInfo) failedContextInfoList.get(i);

// Sets assertion description to the error message

String message = contextInfo.getMessage();

// Transforms the assertion UserElement to the 'name' attribute value of the corresponding

to form tag

ArrayList failedUserElementList = contextInfo.getUserElementList();

ArrayList nameList = new ArrayList();

int userElementCount = failedUserElementList.size();

if (userElementCount > 0) {

// Gets from HTMLFormUpdateHandler the Map of the 'name' attribute value of UserElement

and the input form

Map userElementMap = formProc.getHTMLFormUpdaterHandler().getUserElementMap();

for (int j = 0; j < userElementCount; j++) {

UserElement ue = (UserElement) failedUserElementList.get(j);

if (userElementMap.containsKey(ue)) {

String name = (String) userElementMap.get(ue);

nameList.add(name);

}

}

}

String[] names = (String[]) nameList.toArray(new String[0]);

// Creates an input form value exception for each assertion, and stores it to the array.

HTMLFormDataException e = new HTMLFormDataException(message, names);

errors[i] = e;

}

throw new HTMLFormUpdateInstanceException(errors);

}

Page 66: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 8 Validating instance

58

Page 67: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 9 Notes

59

Chapter 9 Notes

Page 68: WebForm Development Guide - 富士通のソフトウェ …software.fujitsu.com/jp/manual/manualfiles/m120007/b1wd...WebForm Development Guide Java Interface(XBRL 2.1) ii iii iv Preface

Chapter 9 Notes

60

9.1 A note for creating XBRL processor object

Please note that needed is the following setting to XBRL processor object after creating it. This is

for enabling the rendering library.

HTMLFormStartServlet.java

// Creates an XBRL processor

XBRLProcessor xbrlProc = new XBRLProcessor();

// Enables the functions of rendering link processing

xbrlProc.setProperty( "http://www.fujitsu.com/xml/xwand/process-generic-linkbase", "yes");